1
0
mirror of https://github.com/ilri/dspace-statistics-api.git synced 2024-12-25 14:04:29 +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:
Alan Orth 2018-09-23 13:24:30 +03:00
parent 84801a4ab5
commit b0d81a543c
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 10 additions and 4 deletions

5
app.py
View File

@ -2,10 +2,9 @@
# See DSpace Solr docs for tips about parameters
# https://wiki.duraspace.org/display/DSPACE/Solr
from config import SOLR_SERVER
from config import SOLR_CORE
import falcon
from SolrClient import SolrClient
from solr import solr_connection
class ItemResource:
@ -14,8 +13,6 @@ class ItemResource:
# Return HTTPBadRequest if id parameter is not present and valid
item_id = req.get_param_as_int("id", required=True, min=0)
solr = SolrClient(SOLR_SERVER)
# Get views
res = solr.query(SOLR_CORE, {
'q':'type:2 AND id:{0}'.format(item_id),

9
solr.py Normal file
View File

@ -0,0 +1,9 @@
from config import SOLR_SERVER
from SolrClient import SolrClient
def solr_connection():
connection = SolrClient(SOLR_SERVER)
return connection
# vim: set sw=4 ts=4 expandtab: