You're probably wondering what would I need it for?
Here is the case. I have a view which is a ranking of nodes. The sorting is based on a field (math expression) which summarises points from other fields. I call this field "rank".
I need another field showing the position of a node (rank field value) from 1 hour ago. I need it for comparision with current rank field value to know whether the rank went up or down during 1 hour.
If the result of comparision will be <0, I display "arrow down" next to node. Otherwise I display "arrow up".
Any Idea how to store and get the value of a field from 1 h ago? Any module storing field values in database every set time?
Will appreciate any hints.
Regards
migajos
Comments
Comment #2
mustanggb commentedYou probably don't want to use (or more likely write) a module to update the "1 hour old" values for a field as it's not a very scaleable solution and is probably an unnecessary workload anyway.
Your best bet would probably be to join to the
node_revisiontable and ignore results where thechangedfield is older than 1 hour (where statement), then take only the oldest row (maybe you can figure out some SQL to do this, or maybe I'd be easier done in something likehook_views_pre_render()). Then if this join results inNULLthen obviously the value hasn't changed, if it doesn't then join to the relevant field value and check if it's higher or lower.If you need to inject some custom SQL then
hook_views_query_alter()might help you out.Comment #3
migajos commentedMustangGB. Thank You for reply and ideas! Appreciate it.
Comment #4
renatog commentedHi guys, good morning.
Thank you @MustangGB it makes sense and can help us.
Comment #5
renatog commented@migajos any questions about it please comment for us ok?
Thank you very much, guys.
Good Work and Good Week.
Regards.