I would like hook_calculate to be extended a bit. I am writing a module that calculates digg like popularity (read popularity over time, more recent votes get more weight), and I am doing it though hook_calculate and adding the popularity as a function into the cache table via hook_calculate.

I want to only calculate popularity though during cron and not after every vote is placed. AND at the same time, I want every vote that is placed to be counted and averaged. SO the end result is I want to be able to calculate different cache functions at different times.

This patch shows how I did that. By passing $force_calculation to the hook, I know when the votes have been forced to recalculate (that is during cron). But there has to be a better way....

CommentFileSizeAuthor
force_recalculate_patch.txt527 bytesScott Reynolds

Comments

Scott Reynolds’s picture

and by different cache functions at different times i mean average and count right away and popularity (my custom cache function) on cron run

eaton’s picture

Status: Active » Closed (won't fix)

This is fixed in newer versions of the API, and the 4.x and 5.x branches are no longer supported.