@cronjobs.register
def fix_current_revisions():
    try:
        # Sends all writes to the master DB. Slaves are readonly.
        pin_this_thread()

        docs = Document.objects.all()

        for d in docs:
            revs = Revision.objects.filter(document=d, is_approved=True)
            revs = list(revs.order_by('-reviewed')[:1])

            if len(revs):
                rev = revs[0]

                if d.current_revision != rev:
                    d.current_revision = rev
                    d.save()
                    print d.get_absolute_url()
                    statsd.incr('wiki.cron.fix-current-revision')
    finally:
        unpin_this_thread()
Fixes documents that have the current_revision set incorrectly.
dataset/ETHPy150Open mozilla/kitsune/kitsune/wiki/cron.py/fix_current_revisions