Skip to content

Commit eff3c76

Browse files
authored
Merge pull request #131 from nalduu/rework_update_extents
Rework update extents for discovery metadata, added date range settings for stations, instruments, deployments and contributors, added `woudc-data-registry data update-date-ranges` CLI.
2 parents 28e9246 + 1432379 commit eff3c76

File tree

4 files changed

+301
-208
lines changed

4 files changed

+301
-208
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ woudc-data-registry data verify foo.dat -l
181181

182182
# ingest with only core metadata checks
183183
woudc-data-registry data ingest /path/to/dir -l
184+
185+
# update date ranges of all relevant tables with dates gathered from data_records
186+
woudc-data-registry data update-date-ranges
187+
# optional: update specific supported tables in comma seperated format. e.g.
188+
woudc-data-registry data update-date-ranges -m "Contributor,Deployment,Station,Instrument"
184189
```
185190

186191
#### Dobson Section Corrections

woudc_data_registry/controller.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363

6464
from woudc_data_registry.registry import Registry
6565

66-
from woudc_data_registry.generate_metadata import update_extents
66+
from woudc_data_registry.generate_metadata import (
67+
update_extents,
68+
update_data_submission_ranges)
6769
from woudc_data_registry.models import Contributor, DataRecord
6870
from woudc_data_registry.report import OperatorReport, RunReport, EmailSummary
6971
from woudc_data_registry.search import SearchIndex
@@ -376,10 +378,30 @@ def gather(ctx, path, verbosity):
376378
LOGGER.info("Done Gathering files")
377379

378380

381+
@click.command()
382+
@cli_options.OPTION_VERBOSITY
383+
@click.pass_context
384+
@click.option('--models', '-m',
385+
help=(
386+
'Model names to update. '
387+
'E.g. Contributor,Deployment,Station,Instrument'),
388+
is_flag=False)
389+
def update_date_ranges(cntx, models, verbosity):
390+
""" update the start and end dates of the contributors, instruments,
391+
stations, and deployments table from all data submissions"""
392+
registry = Registry()
393+
if models is not None: # update the specified tables
394+
tables = [model.strip() for model in models.split(',')]
395+
update_data_submission_ranges(registry, tables)
396+
else:
397+
update_data_submission_ranges(registry)
398+
399+
379400
data.add_command(ingest)
380401
data.add_command(verify)
381402
data.add_command(generate_emails, name='generate-emails')
382403
data.add_command(send_feedback, name='send-feedback')
383404
data.add_command(delete_record, name='delete-record')
384405
data.add_command(gather)
385406
data.add_command(publish_notification, name='publish-notification')
407+
data.add_command(update_date_ranges, name='update-date-ranges')

0 commit comments

Comments
 (0)