diff options
author | Gilles Dartiguelongue <eva@gentoo.org> | 2017-01-22 18:12:53 +0100 |
---|---|---|
committer | Gilles Dartiguelongue <eva@gentoo.org> | 2017-01-22 18:12:53 +0100 |
commit | 01fe45522776507f8b9e5d973c2982f66d78b6db (patch) | |
tree | 0d06a66227a83cd34f700877f9f81224b13da6a1 /backend/lib | |
parent | sync: use dict facilities for key retrieval with a default (diff) | |
download | grumpy-01fe45522776507f8b9e5d973c2982f66d78b6db.tar.gz grumpy-01fe45522776507f8b9e5d973c2982f66d78b6db.tar.bz2 grumpy-01fe45522776507f8b9e5d973c2982f66d78b6db.zip |
sync: add detail points to sync_versions
Diffstat (limited to 'backend/lib')
-rw-r--r-- | backend/lib/sync.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/backend/lib/sync.py b/backend/lib/sync.py index 02e1116..22008ea 100644 --- a/backend/lib/sync.py +++ b/backend/lib/sync.py @@ -152,6 +152,12 @@ def sync_packages(): db.session.commit() def sync_versions(): + """Synchronize packages version data from packages.gentoo.org. + + For each package that has not been updated in the last SYNC_BUFFER_SECS, + pull package information and refresh its description, maintainers, + versions and keywords. + """ cnt = 0 ts = datetime.utcfromtimestamp(time.time() - SYNC_BUFFER_SECS) now = datetime.utcnow() @@ -172,9 +178,12 @@ def sync_versions(): pkg = data.json() print ("Updating package: %s" % package.full_name) + + # 1. refresh description if 'description' in pkg: package.description = pkg['description'] + # 2. refresh maintainers maintainers = [] for maint in pkg.get('maintainers', []): if 'email' not in maint or 'type' not in maint: @@ -198,6 +207,12 @@ def sync_versions(): # Intentionally outside if 'maintainers' in pkg, because if there are no maintainers in JSON, it's falled to maintainer-needed and we need to clean out old maintainer entries package.maintainers = maintainers # TODO: Retain order to know who is primary; retain description associated with the maintainership + + # TODO: 3. refresh versions + + # TODO: 4. refresh keywords + + # 5. mark package as refreshed package.last_sync_ts = now if not cnt % 100: |