mirror of
https://github.com/ilri/dspace-statistics-api.git
synced 2024-11-21 22:05:02 +01:00
Refactor project structure
This follows guidance from several well-known Python best practices guides. Basically, the idea is create a package for the application that is comprised of several re-usable modules. See: https://docs.python-guide.org/writing/structure/ See: https://realpython.com/python-application-layouts/
This commit is contained in:
parent
754663f062
commit
c027f01b48
@ -24,11 +24,11 @@ Set up the environment variables for Solr and PostgreSQL:
|
||||
|
||||
Index the Solr statistics core to populate the PostgreSQL database:
|
||||
|
||||
$ ./indexer.py
|
||||
$ python -m dspace_statistics_api.indexer
|
||||
|
||||
Run the REST API:
|
||||
|
||||
$ gunicorn app:api
|
||||
$ gunicorn dspace_statistics_api.app:api
|
||||
|
||||
Test to see if there are any statistics:
|
||||
|
||||
|
0
dspace_statistics_api/__init__.py
Normal file
0
dspace_statistics_api/__init__.py
Normal file
@ -1,4 +1,4 @@
|
||||
from database import database_connection
|
||||
from .database import database_connection
|
||||
import falcon
|
||||
|
||||
db = database_connection()
|
@ -1,7 +1,7 @@
|
||||
from config import DATABASE_NAME
|
||||
from config import DATABASE_USER
|
||||
from config import DATABASE_PASS
|
||||
from config import DATABASE_HOST
|
||||
from .config import DATABASE_NAME
|
||||
from .config import DATABASE_USER
|
||||
from .config import DATABASE_PASS
|
||||
from .config import DATABASE_HOST
|
||||
import psycopg2, psycopg2.extras
|
||||
|
||||
def database_connection():
|
@ -30,10 +30,10 @@
|
||||
# See: https://solrclient.readthedocs.io/en/latest/SolrClient.html
|
||||
# See: https://wiki.duraspace.org/display/DSPACE/Solr
|
||||
|
||||
from database import database_connection
|
||||
from .database import database_connection
|
||||
import json
|
||||
import psycopg2.extras
|
||||
from solr import solr_connection
|
||||
from .solr import solr_connection
|
||||
|
||||
def index_views():
|
||||
# get total number of distinct facets for items with a minimum of 1 view,
|
@ -1,4 +1,4 @@
|
||||
from config import SOLR_SERVER
|
||||
from .config import SOLR_SERVER
|
||||
from SolrClient import SolrClient
|
||||
|
||||
def solr_connection():
|
Loading…
Reference in New Issue
Block a user