~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/jobs/ingest.py

  • Committer: Aaron Bentley
  • Date: 2013-04-08 18:57:16 UTC
  • mto: This revision was merged to the branch mainline in revision 189.
  • Revision ID: aaron@canonical.com-20130408185716-pszrrzantmrtm8yg
Retrieve number of days' worth of revisions from config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
from base64 import b64encode
 
5
import calendar
5
6
import contextlib
6
 
from datetime import datetime
 
7
from datetime import (
 
8
    datetime,
 
9
    timedelta,
 
10
)
7
11
import json
8
12
import logging
9
13
import os
180
184
        self.limit = limit
181
185
        self.since = since
182
186
 
 
187
    def setup(self):
 
188
        super(ChangelogIngestJob, self).setup()
 
189
        if self.since is None:
 
190
            days_of_revisions = settings.get('days_of_revisions')
 
191
            if days_of_revisions is not None:
 
192
                cutoff = datetime.utcnow() - timedelta(int(days_of_revisions))
 
193
                self.since = calendar.timegm(cutoff.timetuple())
 
194
 
183
195
    @staticmethod
184
196
    def _rev_info(r, branch):
185
197
        d = {