Skip to content

Commit eb38f95

Browse files
committed
added optional delay to item indexing
1 parent b8f572b commit eb38f95

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

config/application.yml.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ statistics_db:
1313
username: 'dspace_statistics'
1414
password: 'dspace_statistics'
1515
work_dir: '/tmp'
16+
delay: 0
1617
create_zip_archive: false
1718
log_path: 'logs'
1819
log_file: 'statistics-reports.log'

dspace_reports/item_indexer.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import math
22
import sys
33

4+
from time import sleep
5+
46
from lib.oai import DSpaceOai
57
from lib.database import Database
68
from dspace_reports.indexer import Indexer
@@ -19,6 +21,9 @@ def __init__(self, config, logger):
1921
# Set time periods to only month and year as all can cause Solr to crash
2022
self.time_periods = ['month', 'year', 'all']
2123

24+
# Set crawl delay from config
25+
self.delay = config['delay']
26+
2227
def index(self):
2328
# Get list of identifiers from OAI-PMH feed
2429
records = self.oai.get_records()
@@ -190,6 +195,9 @@ def index_item_views(self, time_period='all'):
190195
# Commit changes to database
191196
db.commit()
192197

198+
if self.delay:
199+
sleep(self.delay)
200+
193201
results_current_page += 1
194202

195203
def index_item_downloads(self, time_period='all'):
@@ -298,4 +306,7 @@ def index_item_downloads(self, time_period='all'):
298306
# Commit changes to database
299307
db.commit()
300308

309+
if self.delay:
310+
sleep(self.delay)
311+
301312
results_current_page += 1

0 commit comments

Comments
 (0)