From 4ede966dbb71a5ef969cd9c50324e125777bcb1f Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Fri, 5 Oct 2018 00:16:24 +0300 Subject: [PATCH] indexer.py: Fix logic error in SQL insert This was inserting correctly on the first run, but subsequent runs were inserting into the incorrect column on conflict. This made it seem like there were downloads for items where there were none. --- indexer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indexer.py b/indexer.py index ae6b620..2d5b3ae 100755 --- a/indexer.py +++ b/indexer.py @@ -88,7 +88,7 @@ def index_views(): data.append((item_id, item_views)) # do a batch insert of values from the current "page" of results - sql = 'INSERT INTO items(id, views) VALUES %s ON CONFLICT(id) DO UPDATE SET downloads=excluded.views' + sql = 'INSERT INTO items(id, views) VALUES %s ON CONFLICT(id) DO UPDATE SET views=excluded.views' psycopg2.extras.execute_values(cursor, sql, data, template='(%s, %s)') db.commit()