mirror of
https://github.com/ilri/dspace-statistics-api.git
synced 2024-11-22 22:35:06 +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:
parent
2d3b7620e3
commit
4b72f626d9
4
app.py
4
app.py
@ -25,7 +25,7 @@ class AllItemsResource:
|
|||||||
pages = round(cursor.fetchone()[0] / limit)
|
pages = round(cursor.fetchone()[0] / limit)
|
||||||
|
|
||||||
# get statistics, ordered by id, and use limit and offset to page through results
|
# 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)
|
results = cursor.fetchmany(limit)
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class ItemResource:
|
|||||||
"""Handles GET requests"""
|
"""Handles GET requests"""
|
||||||
|
|
||||||
cursor = db.cursor()
|
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()
|
results = cursor.fetchone()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ def index_views():
|
|||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
|
|
||||||
while results_current_page <= results_num_pages:
|
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', {
|
res = solr.query('statistics', {
|
||||||
'q':'type:2',
|
'q':'type:2',
|
||||||
@ -102,7 +102,7 @@ def index_downloads():
|
|||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
|
|
||||||
while results_current_page <= results_num_pages:
|
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', {
|
res = solr.query('statistics', {
|
||||||
'q':'type:0',
|
'q':'type:0',
|
||||||
|
Loading…
Reference in New Issue
Block a user