diff options
author | Mart Raudsepp <leio@gentoo.org> | 2017-01-22 14:07:48 +0200 |
---|---|---|
committer | Mart Raudsepp <leio@gentoo.org> | 2017-01-22 14:07:48 +0200 |
commit | ed727d30df105b6852f5118baa5a454965b6f4ba (patch) | |
tree | cd61e5c4225106f165e3ed0a0d6b36559a27ebd6 /backend/lib/sync.py | |
parent | sync: use ORM magics in sync_packages (diff) | |
download | grumpy-ed727d30df105b6852f5118baa5a454965b6f4ba.tar.gz grumpy-ed727d30df105b6852f5118baa5a454965b6f4ba.tar.bz2 grumpy-ed727d30df105b6852f5118baa5a454965b6f4ba.zip |
sync: Use dict comprehension in sync_categories as well
Diffstat (limited to 'backend/lib/sync.py')
-rw-r--r-- | backend/lib/sync.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/backend/lib/sync.py b/backend/lib/sync.py index dbb44c2..c837c23 100644 --- a/backend/lib/sync.py +++ b/backend/lib/sync.py @@ -117,10 +117,8 @@ def sync_categories(): data = http_session.get(url) # TODO: Handle response error (if not data) categories = data.json() - existing_categories = {} # TODO: Use UPSERT instead (on_conflict_do_update) if we can rely on postgresql:9.5 - for cat in Category.query.all(): - existing_categories[cat.name] = cat + existing_categories = {cat.name: cat for cat in Category.query.all()} for category in categories: if category['name'] in existing_categories: existing_categories[category['name']].description = category['description'] |