Skip to content

Commit

Permalink
Leftover from last round of OAI-PMH updates
Browse files Browse the repository at this point in the history
  • Loading branch information
melmothx committed Nov 21, 2023
1 parent b6cef21 commit 41e57bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/AmuseWikiFarm/Archive/OAI/PMH.pm
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ sub update_site_records {
# Dlog_debug { "Files: $_ " } [ map { "$_->{file}" } @files ];
$self->logger->($timing->() . "Collected existing records\n");

my $records_updated = 0;
FILE:
foreach my $f (@files) {
if (my $file = delete $f->{file}) {
Expand Down Expand Up @@ -196,12 +197,12 @@ sub update_site_records {
$f->{metadata_type} = $dc_type;
my $sets = delete $f->{sets} || [];
my $rec = $site->oai_pmh_records->update_or_create($f, { key => 'identifier_site_id_unique' });
Dlog_debug { "Setting the record's sets $_" } [ map { $_->set_spec } @$sets ] if @$sets;
$records_updated++;
$rec->set_oai_pmh_sets($sets);
}
}
}
$self->logger->($timing->() . "Updated existing records\n");
$self->logger->($timing->() . "Updated $records_updated records\n");
if (my @removals = map { $_->{oai_pmh_record_id} } values %all) {
Dlog_info { "Marking those records as removed: $_" } \@removals;
$site->oai_pmh_records->set_deleted_flag_on_obsolete_records(\@removals);
Expand Down
5 changes: 4 additions & 1 deletion lib/AmuseWikiFarm/Schema/Result/OaiPmhRecord.pm
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,10 @@ sub dublin_core_record {
$data->{identifier} = [ $base_url . $self->identifier ];
$data->{format} = $self->metadata_format;
$data->{type} = $self->metadata_type;
push @{$data->{description}}, $self->metadata_format_description || '-';
# It should be always there at this point.
if (my $fdesc = $self->metadata_format_description) {
push @{$data->{description}}, $fdesc;
}
if ($obj->can('title_annotations')) {
foreach my $ann ($obj->title_annotations->public) {
my $annotation_type = $ann->annotation->annotation_type;
Expand Down
4 changes: 2 additions & 2 deletions script/amusewiki-oai-pmh-index
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ elsif (!$all) {

my $schema = AmuseWikiFarm::Schema->connect('amuse');

foreach my $site ($schema->resultset('Site')->search($search)) {
foreach my $site ($schema->resultset('Site')->search($search, { order_by => 'id' })) {
my $start = [ gettimeofday ];
my $oai_pmh = AmuseWikiFarm::Archive::OAI::PMH->new(site => $site,
logger => sub {
Expand All @@ -46,7 +46,7 @@ foreach my $site ($schema->resultset('Site')->search($search)) {
},
);
my $time = time();
$oai_pmh->update_site_records;
$oai_pmh->update_site_records({ refresh => 1 });
print "Updated OAI-PMH records for " . $site->id . " in " . (time() - $time) . " seconds\n";
}

Expand Down

0 comments on commit 41e57bb

Please sign in to comment.