mirror of
https://github.com/ilri/dspace-statistics-api.git
synced 2024-11-25 23:58:18 +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:
parent
3580473a6d
commit
4ede966dbb
@ -88,7 +88,7 @@ def index_views():
|
|||||||
data.append((item_id, item_views))
|
data.append((item_id, item_views))
|
||||||
|
|
||||||
# do a batch insert of values from the current "page" of results
|
# 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)')
|
psycopg2.extras.execute_values(cursor, sql, data, template='(%s, %s)')
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user