Move more expensive cache check to async task

If I haven't logged in for a few days and hit the flow list page, won't
this fire a check for each flow on that page?
On Dec 19, 2014 5:30 PM, "Eric Newcomer" <notifications@github.com> wrote:

> In temba/flows/models.py
> <https://github.com/nyaruka/rapidpro/pull/8#discussion-diff-22133327>:
>
> > @@ -844,10 +844,8 @@ def _check_for_cache_update(self):
> >          import random
> >          r.set(cache_check, 1, FLOW_STAT_CACHE_FREQUENCY + random.randint(0, 60 * 60))
> >
> > -        # check if our flow run count is the same, otherwise trigger rebuild
> > -        runs_started = self.runs.filter(contact__is_test=False).count()
> > -        if runs_started != self.get_total_runs():
> > -            calculate_flow_stats_task.delay(self.pk)
> > +        # check flow stats for accuracy, rebuilding if necessary
> > +        check_flow_stats_accuracy_task.delay(self.pk)
>
> This task is performed at most once a day per flow (it's only the quick
> redis check that happens on each request). It also spreads out that daily
> timer with a randomization factor. We want these checks to happen if all
> they do is access the data from the api. I don't think just waiting until
> the click the read page is enough.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/nyaruka/rapidpro/pull/8/files#r22133327>.
>