11import { ILengthAwarePagination } from 'knex-paginate' ;
22import { Job , JobForDisplay , JobStatus } from '../models/job' ;
3- import { allWorkItemsNoData } from '../models/work-item' ;
43import { keysToLowerCase } from '../util/object' ;
54import isUUID from '../util/uuid' ;
65import { getRequestRoot } from '../util/url' ;
@@ -50,7 +49,7 @@ async function handleStacRequest(
5049 } ) ;
5150
5251 if ( [ JobStatus . SUCCESSFUL , JobStatus . COMPLETE_WITH_ERRORS ] . includes ( job . status ) ) {
53- if ( stacDataLinks . length ) {
52+ if ( stacDataLinks . length > 0 ) {
5453 job . links = stacDataLinks ;
5554 const urlRoot = getRequestRoot ( req ) ;
5655 // default to s3 links
@@ -70,18 +69,13 @@ async function handleStacRequest(
7069 throw new RequestValidationError ( 'The requested paging parameters were out of bounds' ) ;
7170 }
7271 } else if ( job . status === JobStatus . SUCCESSFUL ) {
73- let allItemsAreNoData = false ;
74- await db . transaction ( async ( tx ) => {
75- allItemsAreNoData = await allWorkItemsNoData ( tx , jobId ) ;
76- } ) ;
77-
78- if ( allItemsAreNoData ) {
72+ if ( req . params . itemIndex ) {
73+ throw new NotFoundError ( `Service did not provide STAC items for job ${ jobId } ` ) ;
74+ } else {
7975 const urlRoot = getRequestRoot ( req ) ;
8076 const lType = linkType || 's3' ;
8177 const serializedJob = job . serialize ( urlRoot , lType ) ;
8278 res . json ( callback ( serializedJob , pagination ) ) ;
83- } else {
84- throw new NotFoundError ( `Service did not provide STAC items for job ${ jobId } ` ) ;
8579 }
8680 } else {
8781 throw new NotFoundError ( `Service did not provide STAC items for job ${ jobId } ` ) ;
0 commit comments