XF 2.1 Rebuilding reaction caches on posts

Jawsh

Active member
Is there a built in tool to rebuild reaction counts on posts? I've imported a lot of data from an old add-on into the new reaction table but none of that historic information shows unless you click to see the expanded menu. Only old xf_like table data is properly visible on the summary of each post.
 
Just to add to this: I determined there was no effective way to do what I wanted. I had to write a custom rebuild job.

That's not as much work as it sounds because you can safely rely on this in an extension of the Rebuild jobs. This is the native function you'd want to use to rebuild a content's reaction cache after manually importing data from something like the Dark Post Rating mod of XF1.

Code:
$this->app->repository('XF:Reaction')->rebuildContentReactionCache(
            $this->getContentType(),
            $id,
            false,
            true
        );

Just be aware this is a very, very slow job because it has to iterate over each item individually and run multiple queries on top of that. My dataset has 4.5 million posts and 29 million ratings to be re-cached. With 8 cores at 3.6GHz it's estimated to take about 5 hours.
 
Back
Top Bottom