|
63 | 63 |
|
64 | 64 | from woudc_data_registry.registry import Registry |
65 | 65 |
|
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) |
67 | 69 | from woudc_data_registry.models import Contributor, DataRecord |
68 | 70 | from woudc_data_registry.report import OperatorReport, RunReport, EmailSummary |
69 | 71 | from woudc_data_registry.search import SearchIndex |
@@ -376,10 +378,30 @@ def gather(ctx, path, verbosity): |
376 | 378 | LOGGER.info("Done Gathering files") |
377 | 379 |
|
378 | 380 |
|
| 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 | + |
379 | 400 | data.add_command(ingest) |
380 | 401 | data.add_command(verify) |
381 | 402 | data.add_command(generate_emails, name='generate-emails') |
382 | 403 | data.add_command(send_feedback, name='send-feedback') |
383 | 404 | data.add_command(delete_record, name='delete-record') |
384 | 405 | data.add_command(gather) |
385 | 406 | data.add_command(publish_notification, name='publish-notification') |
| 407 | +data.add_command(update_date_ranges, name='update-date-ranges') |
0 commit comments