{
desc => q/
Options (optional).
- report_all => bypass response throttling and receive all URL sub-process responses.
- Not recommened for remote clients, because it can be a lot of data.
+ report_all => bypass response throttling and return all URL sub-process
+ responses to the caller. Not recommened for remote (web, etc.) clients,
+ because it can be a lot of data.
+ resume_attempt => atttempt_id. Resume verification after a failure.
+ resume_with_new_attempt => If true, resume from resume_attempt, but
+ create a new attempt to track the resumption.
/,
type => 'hash'
}
return $e->die_event unless $e->checkauth;
return $e->die_event unless $e->allowed('VERIFY_URL');
- my $session = $e->retrieve_url_verify_session($session_id) or return $e->die_event;
+ my $session = $e->retrieve_url_verify_session($session_id)
+ or return $e->die_event;
+
+ my $attempt_id = $options->{resume_attempt};
if (!$url_ids) {
- my $ids = $e->json_query({
+
+ my $query = {
select => {uvu => ['id']},
from => {
uvu => { # url
join => { cbreb => { # bucket
join => { uvs => { # session
filter => {id => $session_id}
- }} # noisses
- }} # tekcub
- } # meti tekcub
- } # lru
+ }}
+ }}
+ }
+ }
}
- });
+ };
+
+ if ($attempt_id) {
+ $logger->info("url: resuming attempt $attempt_id");
+
+ # when resuming an existing attempt (that presumably failed
+ # mid-processing), we only want to process URLs that either
+ # have no linked url_verification or have an un-completed
+ # url_verification.
+ $query->{from}->{uvu}->{uvuv} = {
+ type => 'left',
+ filter => {attempt => $attempt_id}
+ };
+
+ $query->{where} = {
+ '+uvuv' => {
+ '-or' => [
+ {id => undef}, # no verification started
+ {res_code => undef} # verification started but did no complete
+ ]
+ }
+ };
+ }
+
+ my $ids = $e->json_query($query);
$url_ids = [ map {$_->{id}} @$ids ];
}
my $url_count = scalar(@$url_ids);
$logger->info("url: processing $url_count URLs");
- my $attempt = Fieldmapper::url_verify::verification_attempt->new;
- $attempt->session($session_id);
- $attempt->usr($e->requestor->id);
- $attempt->start_time('now');
+ my $attempt;
+ if ($attempt_id and !$options->{resume_with_new_attempt}) {
- $e->create_url_verify_verification_attempt($attempt) or return $e->die_event;
- $e->commit;
+ $attempt = $e->retrieve_url_verification_attempt($attempt_id)
+ or return $e->die_event;
+
+ # no data was written
+ $e->rollback;
+
+ } else {
+
+ $attempt = Fieldmapper::url_verify::verification_attempt->new;
+ $attempt->session($session_id);
+ $attempt->usr($e->requestor->id);
+ $attempt->start_time('now');
+
+ $e->create_url_verify_verification_attempt($attempt)
+ or return $e->die_event;
+
+ $e->commit;
+ }
+
+ # END DB TRANSACTION
- # Now ycle through the URLs in batches.
+ # Now cycle through the URLs in batches.
my $batch_size = 5; # TODO: org setting
my $delay = 2; # TODO: org setting