Skip to content

Commit dcc8b65

Browse files
Merge branch 'glos-subscribe-to-jobs' into staging
2 parents c3123c4 + 8774f4b commit dcc8b65

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

perllib/Integrations/Confirm.pm

+34-19
Original file line numberDiff line numberDiff line change
@@ -393,31 +393,41 @@ GRAPHQL
393393
sub jobs_graphql_query {
394394
my ( $self, %args ) = @_;
395395

396-
my $job_numbers_str = join ',', @{ $args{job_numbers} };
396+
my @job_type_codes
397+
= keys %{ $self->config->{job_service_whitelist} // () };
397398

398399
my @status_codes
399400
= keys %{ $self->config->{job_reverse_status_mapping} // () };
400-
my $status_codes_str = join( ',', @status_codes );
401+
402+
my (
403+
$start_date,
404+
$end_date,
405+
$job_type_codes_str,
406+
$status_codes_str,
407+
) = (
408+
$args{start_date},
409+
$args{end_date},
410+
join( ',', @job_type_codes ),
411+
join( ',', @status_codes ),
412+
);
401413

402414
return <<"GRAPHQL"
403415
{
404416
jobs (
405417
filter: {
406-
jobNumber: {
407-
inList: [ $job_numbers_str ]
418+
entryDate: {
419+
greaterThanEquals: "$start_date"
420+
lessThanEquals: "$end_date"
408421
}
409422
}
410423
){
411-
description
412-
entryDate
413-
geometry
414-
jobNumber
415-
416-
jobType {
417-
code
418-
name
419-
}
420-
priority {
424+
jobType(
425+
filter: {
426+
code: {
427+
inList: [ $job_type_codes_str ]
428+
}
429+
}
430+
){
421431
code
422432
name
423433
}
@@ -432,6 +442,16 @@ sub jobs_graphql_query {
432442
loggedDate
433443
statusCode
434444
}
445+
446+
entryDate
447+
description
448+
geometry
449+
jobNumber
450+
451+
priority {
452+
code
453+
name
454+
}
435455
}
436456
}
437457
GRAPHQL
@@ -460,11 +480,6 @@ sub GetJobStatusLogs {
460480
sub GetJobs {
461481
my ($self, %args) = @_;
462482

463-
return []
464-
unless $args{job_numbers}
465-
&& ref $args{job_numbers} eq 'ARRAY'
466-
&& @{ $args{job_numbers} };
467-
468483
my $content = $self->perform_request_graphql( type => 'jobs', %args );
469484

470485
return [] unless $content->{data}{jobs};

perllib/Open311/Endpoint/Integration/Confirm.pm

+1-10
Original file line numberDiff line numberDiff line change
@@ -884,21 +884,12 @@ sub get_service_requests {
884884

885885
# Jobs
886886

887-
# We try to follow a similar pattern to Enquiries above; we find updated
888-
# jobs by first grabbing the status logs for the given time period, then
889-
# look up the details for each job associated with those status logs.
890-
891887
if ($self->handle_jobs) {
892-
my $status_logs = $integ->GetJobStatusLogs(
888+
my $jobs = $integ->GetJobs(
893889
start_date => $args->{start_date},
894890
end_date => $args->{end_date},
895891
);
896892

897-
my %uniq_job_numbers = map { $_->{jobNumber} => 1 } @$status_logs;
898-
899-
my $jobs
900-
= $integ->GetJobs( job_numbers => [ keys %uniq_job_numbers ] );
901-
902893
for my $job (@$jobs) {
903894
my $job_id = $job->{jobNumber};
904895

0 commit comments

Comments
 (0)