vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Help on thread merging (https://vborg.vbsupport.ru/showthread.php?t=264944)

thehawkVB 06-09-2011 11:14 AM

Help on thread merging
 
Good morning.

I would like your help to understand how can I implement a change to the way threads are merged together. My problem is that I don't want the posts to be sorted by date after I merge but want ALL posts from the second to thread to appear at the very bottom of the first one, the destination one.

Now of course it could be done by changing the date/time of the posts during the merging process like for example if I merge thread B into thread A at midnight, all posts of thread B will start at midnight + 2 minutes, midnight + 4 minutes and so on, but this would still cause a problem in case thread B has a lot of posts as I may end up with the last post's time set at 03:05 with someone posting a post at 02:05.

Any idea how I can achieve what I want or I'm asking for something impossible to achieve? :(

Thank you.

kh99 06-11-2011 02:21 PM

It seems to me the only way to do this would be to add a field to the post table and use that in the query when ordering the posts for a thread.

thehawkVB 06-11-2011 02:35 PM

So if I understand correctly:

a. Add a new field - example: orderid - to the vb_post table
b. Run a query to fill the value of orderid in ALL existing posts in the table, ordering by the date/time of the post and starting from 1 in order to avoid having orderid = 0 for existing posts
c. Change the way thread posts are retrieved so as they are sorted by this new field "orderid"
d. When merging thread B into thread A, take the last orderid of thread A(example: 71) and insert all posts from thread B starting with orderid 72

Is that correct? :)

kh99 06-11-2011 02:40 PM

That is what I was thinking. But it might be easier if you make an orderid field and default it to 0, and leave it as is for normal threads. Then when merging threads, find the highest value of that field and increase it by one, and set the posts for the thread you want to come second to that new value (i.e 1 if it is the first time you're merging. Or maybe have a text field that you can fill in when merging so you can control the order of posts).

Then when showing a thread order by orderid then dateline (or whatever field it already uses).

Edit: Another thought, maybe you could avoid adding a column to the post table (which might be good if you already have a large number of post) by making a new table with just postid and orderid (and maybe an index on postid), then join that table in the showthread query. (But I'm not a db expert or anything).


All times are GMT. The time now is 04:00 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01771 seconds
  • Memory Usage 1,711KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete