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

migajos created an issue. See original summary.

mustanggb’s picture

You 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_revision table and ignore results where the changed field 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 like hook_views_pre_render()). Then if this join results in NULL then 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.

migajos’s picture

MustangGB. Thank You for reply and ideas! Appreciate it.

renatog’s picture

Status: Active » Reviewed & tested by the community

Hi guys, good morning.

Thank you @MustangGB it makes sense and can help us.

renatog’s picture

Status: Reviewed & tested by the community » Fixed

@migajos any questions about it please comment for us ok?

Thank you very much, guys.

Good Work and Good Week.

Regards.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.