bitbucket: Fix full lister with fallback [start, end] if not provided

Related T1826
This commit is contained in:
Antoine R. Dumont (@ardumont) 2019-06-21 15:36:37 +02:00
parent b3463ecddc
commit e129e48c31
No known key found for this signature in database
GPG key ID: 52E2E9840D10C3B8

View file

@ -2,10 +2,12 @@
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
from urllib import parse
import datetime
import logging
import iso8601
from urllib import parse
from swh.lister.bitbucket.models import BitBucketModel
from swh.lister.core.indexing_lister import IndexingHttpLister
@ -39,6 +41,21 @@ class BitBucketLister(IndexingHttpLister):
repos = response.json()['values']
return [self.get_model_from_repo(repo) for repo in repos]
def db_first_index(self):
"""For the first time listing, there is no data in db, so fallback to the
bitbucket starting year.
"""
return super().db_first_index() or '2008-01-01T00:00:00Z'
def db_last_index(self):
"""For the first time listing, there is no data in db, so fallback to the time
of the first run as max date.
"""
return super().db_last_index() or datetime.datetime.now(
tz=datetime.timezone.utc).isoformat()
def request_uri(self, identifier):
return super().request_uri(identifier or '1970-01-01')