1
0
mirror of https://github.com/ilri/dspace-statistics-api.git synced 2024-12-22 20:52:19 +01:00

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.
This commit is contained in:
Alan Orth 2018-10-05 00:16:24 +03:00
parent 3580473a6d
commit 4ede966dbb
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -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()