mirror of
https://github.com/ilri/dspace-statistics-api.git
synced 2024-11-26 08:08:19 +01:00
Compare commits
No commits in common. "787eec20ea69d82b42aebdfbffa3021bebd06af2" and "01e9756cf2c1323c5c949f8e613bbfd4c8749f40" have entirely different histories.
787eec20ea
...
01e9756cf2
@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Add ORDER BY to /items resource to make sure results are returned
|
- Add ORDER BY to /items resource to make sure results are returned
|
||||||
deterministically
|
deterministically
|
||||||
- Use `fl` parameter in indexer to return only the id field
|
- Use `fl` parameter in indexer to return only the id field
|
||||||
- Minor refactoring of imports for PEP8 style
|
|
||||||
|
|
||||||
## [1.3.2] - 2020-11-18
|
## [1.3.2] - 2020-11-18
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import falcon
|
import falcon
|
||||||
import psycopg2.extras
|
|
||||||
|
|
||||||
from .database import DatabaseManager
|
from .database import DatabaseManager
|
||||||
from .items import get_downloads, get_views
|
from .items import get_downloads, get_views
|
||||||
@ -121,6 +120,8 @@ class ItemResource:
|
|||||||
def on_get(self, req, resp, item_id):
|
def on_get(self, req, resp, item_id):
|
||||||
"""Handles GET requests"""
|
"""Handles GET requests"""
|
||||||
|
|
||||||
|
import psycopg2.extras
|
||||||
|
|
||||||
# Adapt Python’s uuid.UUID type to PostgreSQL’s uuid
|
# Adapt Python’s uuid.UUID type to PostgreSQL’s uuid
|
||||||
# See: https://www.psycopg.org/docs/extras.html
|
# See: https://www.psycopg.org/docs/extras.html
|
||||||
psycopg2.extras.register_uuid()
|
psycopg2.extras.register_uuid()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from .config import SOLR_SERVER
|
from .config import SOLR_SERVER
|
||||||
from .util import get_statistics_shards
|
|
||||||
|
|
||||||
|
|
||||||
def get_views(solr_date_string: str, items: list):
|
def get_views(solr_date_string: str, items: list):
|
||||||
@ -12,6 +11,7 @@ def get_views(solr_date_string: str, items: list):
|
|||||||
:parameter items (list): a list of item IDs
|
:parameter items (list): a list of item IDs
|
||||||
:returns: A dict of item IDs and views
|
:returns: A dict of item IDs and views
|
||||||
"""
|
"""
|
||||||
|
from .util import get_statistics_shards
|
||||||
shards = get_statistics_shards()
|
shards = get_statistics_shards()
|
||||||
|
|
||||||
# Join the UUIDs with "OR" and escape the hyphens for Solr
|
# Join the UUIDs with "OR" and escape the hyphens for Solr
|
||||||
@ -20,7 +20,6 @@ def get_views(solr_date_string: str, items: list):
|
|||||||
solr_query_params = {
|
solr_query_params = {
|
||||||
"q": f"id:({solr_items_string})",
|
"q": f"id:({solr_items_string})",
|
||||||
"fq": f"type:2 AND isBot:false AND statistics_type:view AND time:{solr_date_string}",
|
"fq": f"type:2 AND isBot:false AND statistics_type:view AND time:{solr_date_string}",
|
||||||
"fl": "id",
|
|
||||||
"facet": "true",
|
"facet": "true",
|
||||||
"facet.field": "id",
|
"facet.field": "id",
|
||||||
"facet.mincount": 1,
|
"facet.mincount": 1,
|
||||||
@ -62,6 +61,7 @@ def get_downloads(solr_date_string: str, items: list):
|
|||||||
:parameter items (list): a list of item IDs
|
:parameter items (list): a list of item IDs
|
||||||
:returns: A dict of item IDs and downloads
|
:returns: A dict of item IDs and downloads
|
||||||
"""
|
"""
|
||||||
|
from .util import get_statistics_shards
|
||||||
shards = get_statistics_shards()
|
shards = get_statistics_shards()
|
||||||
|
|
||||||
# Join the UUIDs with "OR" and escape the hyphens for Solr
|
# Join the UUIDs with "OR" and escape the hyphens for Solr
|
||||||
@ -70,7 +70,6 @@ def get_downloads(solr_date_string: str, items: list):
|
|||||||
solr_query_params = {
|
solr_query_params = {
|
||||||
"q": f"owningItem:({solr_items_string})",
|
"q": f"owningItem:({solr_items_string})",
|
||||||
"fq": f"type:0 AND isBot:false AND statistics_type:view AND bundleName:ORIGINAL AND time:{solr_date_string}",
|
"fq": f"type:0 AND isBot:false AND statistics_type:view AND bundleName:ORIGINAL AND time:{solr_date_string}",
|
||||||
"fl": "owningItem",
|
|
||||||
"facet": "true",
|
"facet": "true",
|
||||||
"facet.field": "owningItem",
|
"facet.field": "owningItem",
|
||||||
"facet.mincount": 1,
|
"facet.mincount": 1,
|
||||||
@ -103,5 +102,4 @@ def get_downloads(solr_date_string: str, items: list):
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
# vim: set sw=4 ts=4 expandtab:
|
# vim: set sw=4 ts=4 expandtab:
|
||||||
|
@ -1,11 +1,4 @@
|
|||||||
import datetime
|
|
||||||
import json
|
|
||||||
import re
|
|
||||||
|
|
||||||
import falcon
|
import falcon
|
||||||
import requests
|
|
||||||
|
|
||||||
from .config import SOLR_SERVER
|
|
||||||
|
|
||||||
|
|
||||||
def get_statistics_shards():
|
def get_statistics_shards():
|
||||||
@ -15,6 +8,11 @@ def get_statistics_shards():
|
|||||||
Returns:
|
Returns:
|
||||||
str:A list of Solr statistics shards separated by commas.
|
str:A list of Solr statistics shards separated by commas.
|
||||||
"""
|
"""
|
||||||
|
import re
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from .config import SOLR_SERVER
|
||||||
|
|
||||||
# Initialize an empty list for statistics core years
|
# Initialize an empty list for statistics core years
|
||||||
statistics_core_years = []
|
statistics_core_years = []
|
||||||
@ -60,6 +58,7 @@ def get_statistics_shards():
|
|||||||
|
|
||||||
|
|
||||||
def is_valid_date(date):
|
def is_valid_date(date):
|
||||||
|
import datetime
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Solr date format is: 2020-01-01T00:00:00Z
|
# Solr date format is: 2020-01-01T00:00:00Z
|
||||||
@ -79,6 +78,7 @@ def validate_items_post_parameters(req, resp, resource, params):
|
|||||||
|
|
||||||
Meant to be used as a `before` hook.
|
Meant to be used as a `before` hook.
|
||||||
"""
|
"""
|
||||||
|
import json
|
||||||
|
|
||||||
# Only attempt to read the POSTed request if its length is not 0 (or
|
# Only attempt to read the POSTed request if its length is not 0 (or
|
||||||
# rather, in the Python sense, if length is not a False-y value).
|
# rather, in the Python sense, if length is not a False-y value).
|
||||||
|
Loading…
Reference in New Issue
Block a user