Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On demand search bugfixes #1931

Merged
merged 6 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ export class ScenesListComponent implements OnInit, OnDestroy, AfterContentInit
}

private loadDummyProducts(scenes: CMRProduct[]) {

const scenesToLoad = scenes
.slice(0, this.numberProductsInList)
.filter(s => s.isDummyProduct)
Expand Down
4 changes: 4 additions & 0 deletions src/app/services/hyp3.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ export class Hyp3Service {
jobOptions.name = options.projectName;
}

if (!jobOptions.name) {
delete jobOptions.name;
}

return jobOptions;
});
}
Expand Down
21 changes: 18 additions & 3 deletions src/app/store/scenes/scenes.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export const initState: ScenesState = {
export function scenesReducer(state = initState, action: ScenesActions): ScenesState {
switch (action.type) {
case ScenesActionType.SET_SCENES: {
let subproducts: CMRProduct[] = []
let subproducts: CMRProduct[] = [];

let searchResults = action.payload.products.map(p =>
p.metadata.productType === 'BURST' ? ({
...p,
Expand All @@ -91,6 +92,12 @@ export function scenesReducer(state = initState, action: ScenesActions): ScenesS

const products = searchResults
.reduce((total, product) => {
if (product.isDummyProduct && isAlreadyLoaded(product, state.products[product.id])) {
total[product.id] = state.products[product.id];

return total;
}

total[product.id] = product;

return total;
Expand All @@ -111,14 +118,14 @@ export function scenesReducer(state = initState, action: ScenesActions): ScenesS
groupCriteria = product.id;
}
}

const scene = total[groupCriteria] || [];

total[groupCriteria] = [...scene, product.id];
return total;
}, {});

for (const [groupId, productNames] of Object.entries(productGroups)) {

(<string[]>productNames).sort(
(a, b) => products[a].bytes - products[b].bytes
).reverse();
Expand Down Expand Up @@ -152,10 +159,13 @@ export function scenesReducer(state = initState, action: ScenesActions): ScenesS
const product = cmrData[jobProduct.name];

if(!!product) {
if (!jobProduct.metadata.job) {
return;
}
let job = {
...jobProduct.metadata.job,
job_parameters: {
...jobProduct.metadata.job.job_parameters,
...jobProduct.metadata.job?.job_parameters,
}
};
const jobFile = !!job.files ?
Expand All @@ -177,6 +187,7 @@ export function scenesReducer(state = initState, action: ScenesActions): ScenesS
bytes: jobFile.size,
groupId: job.job_id,
id: job.job_id,
isDummyProduct: false,
metadata: {
...product.metadata,
fileName: jobFile.filename || '',
Expand Down Expand Up @@ -567,6 +578,10 @@ const productsForScene = (selected, state) => {
}).reverse();
};

const isAlreadyLoaded = (product, oldProduct) => {
return !!oldProduct && !oldProduct.isDummyProduct && product.isDummyProduct;
}

export const getAreProductsLoaded = createSelector(
getScenes,
state => state.length > 0
Expand Down
12 changes: 6 additions & 6 deletions src/app/store/search/search.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,18 +372,18 @@ export class SearchEffects {
const jobs = jobsRes.hyp3Jobs;

const granuleNames = this.getAllGranulesFromJobs(jobs);
const asfApiListQuery = this.dummyProducts$(granuleNames);
const fakeApiListQuery = this.dummyProducts$(granuleNames);

return asfApiListQuery.pipe(
map(products => {
return products
return fakeApiListQuery.pipe(
map(dummyProducts => {
return dummyProducts
.reduce((prodsByName, p) => {
prodsByName[p.name] = p;
return prodsByName;
}, {});
}),
map(products => {
return this.hyp3JobToProducts(jobs, products);
map(dummyProducts => {
return this.hyp3JobToProducts(jobs, dummyProducts);
}),
withLatestFrom(this.store$.select(getIsCanceled)),
map(([products, isCanceled]) =>
Expand Down
Loading