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

Update string substitution format

Instead of doing numbered strings I will just depend on the order,
at least to be consistent.
This commit is contained in:
Alan Orth 2018-09-25 02:19:29 +03:00
parent 2d3b7620e3
commit 4b72f626d9
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 4 additions and 4 deletions

4
app.py
View File

@ -25,7 +25,7 @@ class AllItemsResource:
pages = round(cursor.fetchone()[0] / limit)
# get statistics, ordered by id, and use limit and offset to page through results
cursor.execute('SELECT id, views, downloads FROM items ORDER BY id ASC LIMIT {0} OFFSET {1}'.format(limit, offset))
cursor.execute('SELECT id, views, downloads FROM items ORDER BY id ASC LIMIT {} OFFSET {}'.format(limit, offset))
results = cursor.fetchmany(limit)
cursor.close()
@ -50,7 +50,7 @@ class ItemResource:
"""Handles GET requests"""
cursor = db.cursor()
cursor.execute('SELECT views, downloads FROM items WHERE id={0}'.format(item_id))
cursor.execute('SELECT views, downloads FROM items WHERE id={}'.format(item_id))
results = cursor.fetchone()
cursor.close()

View File

@ -55,7 +55,7 @@ def index_views():
cursor = db.cursor()
while results_current_page <= results_num_pages:
print('Page {0} of {1}.'.format(results_current_page, results_num_pages))
print('Page {} of {}.'.format(results_current_page, results_num_pages))
res = solr.query('statistics', {
'q':'type:2',
@ -102,7 +102,7 @@ def index_downloads():
cursor = db.cursor()
while results_current_page <= results_num_pages:
print('Page {0} of {1}.'.format(results_current_page, results_num_pages))
print('Page {} of {}.'.format(results_current_page, results_num_pages))
res = solr.query('statistics', {
'q':'type:0',