diff options
author | 2017-01-22 13:57:24 +0200 | |
---|---|---|
committer | 2017-01-22 13:57:24 +0200 | |
commit | fab9c6f0ce09830aa95fc3bdfe09c03663094660 (patch) | |
tree | dc43edecc75da76ddc4531e8fd7a636b33bb6379 /backend | |
parent | sync: use dict-comprehension in sync_packages (diff) | |
download | grumpy-fab9c6f0ce09830aa95fc3bdfe09c03663094660.tar.gz grumpy-fab9c6f0ce09830aa95fc3bdfe09c03663094660.tar.bz2 grumpy-fab9c6f0ce09830aa95fc3bdfe09c03663094660.zip |
sync: Fix pkg sync for packages that have a same named pkg in another category
Also fixes an InstrumentedList issue due to change from the categories.packages
relationship from dynamic loading to select in commit 8d90fa1009 having broken
that earlier
Diffstat (limited to 'backend')
-rw-r--r-- | backend/lib/sync.py | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/backend/lib/sync.py b/backend/lib/sync.py index d292291..7c499b5 100644 --- a/backend/lib/sync.py +++ b/backend/lib/sync.py @@ -131,12 +131,6 @@ def sync_categories(): def sync_packages(): for category in Category.query.all(): - if not category.packages: - print('Category %s has no packages' % category.name) - existing_packages = [] - else: - existing_packages = category.packages.all() - data = http_session.get(pkg_url_base + "categories/" + category.name + ".json") if not data: print("No JSON data for category %s" % category.name) # FIXME: Better handling; mark category as inactive/gone? @@ -144,7 +138,7 @@ def sync_packages(): packages = data.json()['packages'] # TODO: Use UPSERT instead (on_conflict_do_update) - existing_packages = {pkg.name: pkg for pkg in Package.query.all()} + existing_packages = {pkg.name: pkg for pkg in category.packages} for package in packages: if package['name'] in existing_packages: |