XF 2.2 A problem of time and space

Robert9

Well-known member
You have items with an item_id and an item_date.
Your sort is item_date ASC, item_id ASC

Your items are (for this example i use weekdays, it is easier to write than timestamps!)

Monday, 12
Wednesday, 10
Friday, 22


Now you want to move the 22 to the second place.
Change item_date => Tuesday, where item_id = 22

Monday, 12
Tuesday, 22
Wednesday, 10

Ok, so far. But ...


Wednesday, 10
Wednesday, 12
Wednesday, 22

How can I move the 22 to the second place?
Yes, I can, if I change the item_date for all or some of them

for all items, do
start with Monday
first item => Monday
day+2
second item => Wednesday
day+2
third item => Friday

and now

Change item_date => Tuesday, where item_id = 22


Imagine we have 3200 items in a row;
instead of weekdays, we have timestamps

I need to move #3199 to #4, I test if there is a time gap between #3 and old #4;
if so, I can move.

But if there is no time gap between #3 and old #4, what can I do?

Check #5, #6, #7 ... if there is one with enough time difference to update all between #3 and the #found_one?
Then update only these, then move?

Should I do something like a crawler ...
item_date += 2, where item_id = x
watch next one, time ok?
If not
item_date += 2, where item_id = next one
repeat until ok

Is there a mystic magic mysql-function to say:
give all my items a new value for the field item_date from 1 to x with difference = +10
or better: give all my items a new value for the field item_date from now to past with difference = -10
 
Last edited:
Ideas so far
  • search a item near with a difference for date big enough to set all date_values new.
  • do a crawler, start with one, check dates, increase, check next date ...
  • do a cron job and recalc dates for all items in the night to have always space between.
 
Top Bottom