Skip to content

Commit

Permalink
documents: add option to force harvesting records
Browse files Browse the repository at this point in the history
The second time `harvest-all` command is called, only records updated since last run are imported. With this new option, it forces to re-import all records.

* Adds a `--force` option to re-import all records.

Co-Authored-by: Sébastien Délèze <[email protected]>
  • Loading branch information
Sébastien Délèze committed Sep 11, 2020
1 parent 8bf14b4 commit b80674c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sonar/modules/documents/cli/oaiharvester.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,22 @@ def oai_config_info():
is_flag=True,
default=False,
help="Enqueue harvesting and return immediately.")
@click.option(
'-f',
'--force',
is_flag=True,
default=False,
help='Force to re-import records, (don\'t take care of last run date).'
)
@with_appcontext
@click.pass_context
def oai_config_harvest_all(ctx, max, enqueue):
def oai_config_harvest_all(ctx, max, enqueue, force):
"""Harvesting data for the set and the configuration.
:param ctx: App context.
:param max: Max records to harvest for each sources.
:param enqueue: Enqueue process or return immediately.
:param force: Force to re-import records.
"""
with current_app.app_context():
sources = OAIHarvestConfig.query.all()
Expand All @@ -127,4 +135,5 @@ def oai_config_harvest_all(ctx, max, enqueue):
name=name,
arguments=arguments,
enqueue=enqueue,
quiet=True)
quiet=True,
from_date='1900-01-01' if force else None)

0 comments on commit b80674c

Please sign in to comment.