diff options
author | 2016-12-07 04:52:48 +0200 | |
---|---|---|
committer | 2016-12-07 04:52:48 +0200 | |
commit | 0522c4ccf0f4ca737572b8164cde6bb9c498ba7f (patch) | |
tree | 7655c4587601f3c522ec2b510922f3851ff77cfa | |
parent | sync: Don't forget to commit db transaction after all packages are synced (diff) | |
download | grumpy-0522c4ccf0f4ca737572b8164cde6bb9c498ba7f.tar.gz grumpy-0522c4ccf0f4ca737572b8164cde6bb9c498ba7f.tar.bz2 grumpy-0522c4ccf0f4ca737572b8164cde6bb9c498ba7f.zip |
sync: Increase the sync delta to 1 hour and print the sync count and oldest TS at start
-rw-r--r-- | backend/lib/sync.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/backend/lib/sync.py b/backend/lib/sync.py index 8c687c6..7ba583d 100644 --- a/backend/lib/sync.py +++ b/backend/lib/sync.py @@ -5,7 +5,7 @@ from datetime import datetime from .. import app, db from .models import Category, Maintainer, Package, PackageVersion -SYNC_BUFFER_SECS = 30*60 +SYNC_BUFFER_SECS = 60*60 #1 hour proj_url = "https://api.gentoo.org/metastructure/projects.xml" pkg_url_base = "https://packages.gentoo.org/" http_session = requests.session() @@ -154,7 +154,10 @@ def sync_versions(): for maintainer in Maintainer.query.all(): existing_maintainers[maintainer.email] = maintainer - for package in Package.query.filter(Package.last_sync_ts < ts).order_by(Package.last_sync_ts).all(): + packages_to_sync = Package.query.filter(Package.last_sync_ts < ts).order_by(Package.last_sync_ts).all() + print("Going to sync %d packages%s" % (len(packages_to_sync), (" (oldest sync UTC timestamp: %s)" % packages_to_sync[0].last_sync_ts if len(packages_to_sync) else ""))) + + for package in packages_to_sync: cnt += 1 data = http_session.get(pkg_url_base + "packages/" + package.full_name + ".json") if not data: |