Skip to content

Commit

Permalink
Delay reindexing for accepted proposals by 10 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 6, 2024
1 parent 16bf80e commit 97bceb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions assets/vue/ProposedPatterns.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<div class="change-confirmation"><i class="fas fa-sync fa-spin"></i> Updating proposal</div>
</div>
<div v-else-if="change.state === 'accepted'" class="col-12">
<div class="change-confirmation">Change has been accepted</div>
<div class="change-confirmation">Change has been accepted, reindexing related packages in 10 minutes</div>
</div>
<div v-else-if="change.state === 'rejected'" class="col-12">
<div class="change-confirmation">Proposal has been removed</div>
Expand Down Expand Up @@ -125,7 +125,7 @@ export default {
name: 'RecentChanges',
data() {
return {
params: {before: 0},
params: {before: 0, delay: 600},
changes: null,
changeUrl: '/licenses/proposed/meta',
total: null
Expand Down
4 changes: 3 additions & 1 deletion lib/Cavil/Controller/Snippet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ sub _create_pattern ($self, $packages, $validation) {
$validation->optional('trademark');
$validation->optional('export_restricted');
$validation->optional('contributor');
$validation->optional('delay')->num;
return $self->reply->json_validation_error if $validation->has_error;

my $owner_id = $self->users->id_for_login($self->current_user);
my $contributor = $validation->param('contributor');
my $contributor_id = $contributor ? $self->users->id_for_login($contributor) : undef;
my $delay = $validation->param('delay') // 0;

my $patterns = $self->patterns;
my $pattern = $patterns->create(
Expand All @@ -195,7 +197,7 @@ sub _create_pattern ($self, $packages, $validation) {
return $self->render(status => 409, error => 'Conflicting license pattern already exists') if $pattern->{conflict};

if (my $checksum = $validation->param('checksum')) { $patterns->remove_proposal($checksum) }
$self->packages->reindex($_, 3) for @$packages;
$self->packages->reindex($_, 3, [], $delay) for @$packages;
$self->render(packages => $packages, pattern => $pattern->{id});
}

Expand Down

0 comments on commit 97bceb3

Please sign in to comment.