~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/scripts/garbo.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-02 23:44:26 UTC
  • mfrom: (13589.1.1 revert-r13574)
  • Revision ID: launchpad@pqm.canonical.com-20110802234426-z03j07sj334l9ay0
[r=wgrant][rollback=13574] Revert r13574. It crashes when the flag is
 enabled, see bug #810290.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
 
40
40
from canonical.config import config
41
41
from canonical.database import postgresql
42
 
from canonical.database.constants import UTC_NOW
43
42
from canonical.database.sqlbase import (
44
43
    cursor,
45
44
    session_store,
727
726
class BugHeatUpdater(TunableLoop):
728
727
    """A `TunableLoop` for bug heat calculations."""
729
728
 
730
 
    maximum_chunk_size = 5000
 
729
    maximum_chunk_size = 1000
731
730
 
732
731
    def __init__(self, log, abort_time=None, max_heat_age=None):
733
732
        super(BugHeatUpdater, self).__init__(log, abort_time)
761
760
 
762
761
        See `ITunableLoop`.
763
762
        """
764
 
        chunk_size = int(chunk_size + 0.5)
 
763
        # We multiply chunk_size by 1000 for the sake of doing updates
 
764
        # quickly.
 
765
        chunk_size = int(chunk_size * 1000)
 
766
 
 
767
        transaction.begin()
765
768
        outdated_bugs = self._outdated_bugs[:chunk_size]
766
 
        # We don't use outdated_bugs.set() here to work around
767
 
        # Storm Bug #820290.
768
 
        outdated_bug_ids = [bug.id for bug in outdated_bugs]
769
 
        self.log.debug("Updating heat for %s bugs", len(outdated_bug_ids))
770
 
        IMasterStore(Bug).find(
771
 
            Bug, Bug.id.is_in(outdated_bug_ids)).set(
772
 
                heat=SQL('calculate_bug_heat(Bug.id)'),
773
 
                heat_last_updated=UTC_NOW)
 
769
        self.log.debug("Updating heat for %s bugs" % outdated_bugs.count())
 
770
        outdated_bugs.set(
 
771
            heat=SQL('calculate_bug_heat(Bug.id)'),
 
772
            heat_last_updated=datetime.now(pytz.utc))
 
773
 
774
774
        transaction.commit()
775
775
 
776
776