mirror of
				https://github.com/ilri/dspace-statistics-api.git
				synced 2025-11-03 22:19:09 +01:00 
			
		
		
		
	Compare commits
	
		
			7 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						15c3299b99
	
				 | 
					
					
						|||
| d36be5ee50 | |||
| 2f45d27554 | |||
| b8356f7a87 | |||
| 2136dc79ce | |||
| ed60120cef | |||
| c027f01b48 | 
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
 | 
			
		||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 | 
			
		||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 | 
			
		||||
 | 
			
		||||
### [0.6.0] - 2018-10-31
 | 
			
		||||
## Changed
 | 
			
		||||
- Refactor project structure (note breaking changes to API and indexing invocation, see contrib and README.md)
 | 
			
		||||
 | 
			
		||||
### [0.5.2] - 2018-10-28
 | 
			
		||||
## Changed
 | 
			
		||||
- Update library versions in requirements.txt
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 | 
			
		||||
Test to see if there are any statistics:
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ Group=nogroup
 | 
			
		||||
WorkingDirectory=/var/lib/dspace-statistics-api
 | 
			
		||||
ExecStart=/var/lib/dspace-statistics-api/venv/bin/gunicorn \
 | 
			
		||||
          --bind 127.0.0.1:5000                             \
 | 
			
		||||
          app:api
 | 
			
		||||
          dspace_statistics_api.app
 | 
			
		||||
ExecReload=/bin/kill -s HUP $MAINPID
 | 
			
		||||
ExecStop=/bin/kill -s TERM $MAINPID
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ Environment=DATABASE_HOST=localhost
 | 
			
		||||
User=nobody
 | 
			
		||||
Group=nogroup
 | 
			
		||||
WorkingDirectory=/var/lib/dspace-statistics-api
 | 
			
		||||
ExecStart=/var/lib/dspace-statistics-api/venv/bin/python indexer.py
 | 
			
		||||
ExecStart=/var/lib/dspace-statistics-api/venv/bin/python -m dspace_statistics_api.indexer
 | 
			
		||||
 | 
			
		||||
[Install]
 | 
			
		||||
WantedBy=multi-user.target
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										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()
 | 
			
		||||
@@ -63,10 +63,7 @@ class ItemResource:
 | 
			
		||||
 | 
			
		||||
        cursor.close()
 | 
			
		||||
 | 
			
		||||
def on_exit(api):
 | 
			
		||||
    print("Shutting down DB")
 | 
			
		||||
 | 
			
		||||
api = falcon.API()
 | 
			
		||||
api = application = falcon.API()
 | 
			
		||||
api.add_route('/items', AllItemsResource())
 | 
			
		||||
api.add_route('/item/{item_id:int}', ItemResource())
 | 
			
		||||
 | 
			
		||||
@@ -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():
 | 
			
		||||
							
								
								
									
										5
									
								
								indexer.py → dspace_statistics_api/indexer.py
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										5
									
								
								indexer.py → dspace_statistics_api/indexer.py
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							@@ -1,4 +1,3 @@
 | 
			
		||||
#!/usr/bin/env python
 | 
			
		||||
#
 | 
			
		||||
# indexer.py
 | 
			
		||||
#
 | 
			
		||||
@@ -30,10 +29,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():
 | 
			
		||||
		Reference in New Issue
	
	Block a user