Skip to content

Commit

Permalink
add arg to format metadata just for OSF sources
Browse files Browse the repository at this point in the history
e.g.
```
python manage.py format_metadata_records <format> --osf-source-configs
```
  • Loading branch information
aaxelb committed Mar 4, 2021
1 parent b4e7142 commit 5af4bb4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions share/management/commands/format_metadata_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from share.models.jobs import IngestJob
from share.tasks import ingest
from share.util.extensions import Extensions
from share.util.osf import osf_sources


CHUNK_SIZE = 2000
Expand All @@ -19,6 +20,7 @@ def add_arguments(self, parser):

source_config_group = parser.add_mutually_exclusive_group(required=True)
source_config_group.add_argument('--source-config', '-c', action='append', help='format data from these source configs')
source_config_group.add_argument('--osf-source-configs', '-o', action='store_true', help='format data from OSF source configs')
source_config_group.add_argument('--all-source-configs', '-a', action='store_true', help='format data from *all* source configs')

parser.add_argument('--suid-start-id', '-s', type=int, default=0, help='resume based on the previous run\'s last successful suid')
Expand Down Expand Up @@ -54,6 +56,7 @@ def handle(self, *args, **options):

def get_source_config_ids(self, options):
source_config_labels = options['source_config']
osf_source_configs = options['osf_source_configs']
all_source_configs = options['all_source_configs']

if all_source_configs:
Expand All @@ -62,6 +65,13 @@ def get_source_config_ids(self, options):
source__is_deleted=False,
).values_list('id', flat=True))

if osf_source_configs:
return tuple(SourceConfig.objects.filter(
disabled=False,
source__is_deleted=False,
source__in=osf_sources(),
).values_list('id', flat=True))

ids_and_labels = SourceConfig.objects.filter(
label__in=source_config_labels,
source__is_deleted=False,
Expand Down

0 comments on commit 5af4bb4

Please sign in to comment.