From e129e48c317f517e162407106db210d9ea3d297d Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont (@ardumont)" <antoine.romain.dumont@gmail.com> Date: Fri, 21 Jun 2019 15:36:37 +0200 Subject: [PATCH] bitbucket: Fix full lister with fallback [start, end] if not provided Related T1826 --- swh/lister/bitbucket/lister.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/swh/lister/bitbucket/lister.py b/swh/lister/bitbucket/lister.py index a51fea75..2c00c68c 100644 --- 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 @@ 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') -- GitLab