diff --git a/swh/lister/bitbucket/lister.py b/swh/lister/bitbucket/lister.py --- a/swh/lister/bitbucket/lister.py +++ b/swh/lister/bitbucket/lister.py @@ -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 @@ 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')