mirror of
https://github.com/ilri/dspace-statistics-api.git
synced 2024-11-24 23:30:18 +01:00
Refactor Solr components
This makes it so we only need to define and connect once and then we can re-use the connection everywhere else.
This commit is contained in:
parent
84801a4ab5
commit
b0d81a543c
5
app.py
5
app.py
@ -2,10 +2,9 @@
|
|||||||
# See DSpace Solr docs for tips about parameters
|
# See DSpace Solr docs for tips about parameters
|
||||||
# https://wiki.duraspace.org/display/DSPACE/Solr
|
# https://wiki.duraspace.org/display/DSPACE/Solr
|
||||||
|
|
||||||
from config import SOLR_SERVER
|
|
||||||
from config import SOLR_CORE
|
from config import SOLR_CORE
|
||||||
import falcon
|
import falcon
|
||||||
from SolrClient import SolrClient
|
from solr import solr_connection
|
||||||
|
|
||||||
|
|
||||||
class ItemResource:
|
class ItemResource:
|
||||||
@ -14,8 +13,6 @@ class ItemResource:
|
|||||||
# Return HTTPBadRequest if id parameter is not present and valid
|
# Return HTTPBadRequest if id parameter is not present and valid
|
||||||
item_id = req.get_param_as_int("id", required=True, min=0)
|
item_id = req.get_param_as_int("id", required=True, min=0)
|
||||||
|
|
||||||
solr = SolrClient(SOLR_SERVER)
|
|
||||||
|
|
||||||
# Get views
|
# Get views
|
||||||
res = solr.query(SOLR_CORE, {
|
res = solr.query(SOLR_CORE, {
|
||||||
'q':'type:2 AND id:{0}'.format(item_id),
|
'q':'type:2 AND id:{0}'.format(item_id),
|
||||||
|
Loading…
Reference in New Issue
Block a user