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

fix: proposal logbook sometimes show wrong content #1046

Merged
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
3 changes: 3 additions & 0 deletions CI/ESS/e2e/.env.backend-next
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ RABBITMQ_PASSWORD="rabbitmq"
REGISTER_DOI_URI="https://mds.test.datacite.org/doi"
REGISTER_METADATA_URI="https://mds.test.datacite.org/metadata"
SITE="ESS"
ADMIN_GROUPS=admin,ingestor,archivemanager
CREATE_DATASET_GROUPS=group1,group2,group3
DELETE_GROUPS=archivemanager
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ export class ViewProposalPageComponent implements OnInit, OnDestroy {
this.vm$.subscribe((vm) => {
if (vm.proposal) {
this.proposal = vm.proposal;
this.store.dispatch(
fetchLogbookAction({ name: this.proposal.proposalId })
);

}
})
);
Expand All @@ -116,6 +114,9 @@ export class ViewProposalPageComponent implements OnInit, OnDestroy {
this.store.dispatch(
fetchProposalDatasetsAction({ proposalId: params.id })
);
this.store.dispatch(
fetchLogbookAction({ name: params.id })
);
})
);

Expand Down
2 changes: 1 addition & 1 deletion src/app/state-management/actions/logbooks.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const clearLogbookAction = createAction("[Logbook] Clear Logbook");

export const fetchCountAction = createAction(
"[Logbook] Fetch Count",
props<{ name: string }>()
props<{ name?: string; pid?: string }>()
);
export const fetchCountCompleteAction = createAction(
"[Logbook] Fetch Count Complete",
Expand Down
26 changes: 16 additions & 10 deletions src/app/state-management/effects/logbooks.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export class LogbookEffects {
return this.actions$.pipe(
ofType(fromActions.fetchLogbookAction),
concatLatestFrom(() => this.filters$),
mergeMap(([{ name }, filters]) =>
this.logbookApi
mergeMap(([{ name }, filters]) =>{
return this.logbookApi
.findByName(encodeURIComponent(name), JSON.stringify(filters))
.pipe(
timeout(3000),
Expand All @@ -44,7 +44,9 @@ export class LogbookEffects {
fromActions.fetchCountAction({ name }),
]),
catchError(() => of(fromActions.fetchLogbookFailedAction()))
)
);
}

)
);
});
Expand All @@ -59,7 +61,8 @@ export class LogbookEffects {
.pipe(
timeout(3000),
mergeMap((logbook) => [
fromActions.fetchLogbookCompleteAction({ logbook })
fromActions.fetchLogbookCompleteAction({ logbook }),
fromActions.fetchCountAction({ pid })
]),
catchError(() => of(fromActions.fetchDatasetLogbookFailedAction()))
)
Expand All @@ -71,15 +74,18 @@ export class LogbookEffects {
return this.actions$.pipe(
ofType(fromActions.fetchCountAction),
concatLatestFrom(() => this.filters$),
mergeMap(([{ name }, filters]) => {
mergeMap(([{ name,pid }, filters]) => {
const { skip, limit, sortField, ...theRest } = filters;
return this.logbookApi
.findByName(encodeURIComponent(name), JSON.stringify(theRest))
return (name ? this.logbookApi
.findByName(encodeURIComponent(name), JSON.stringify(theRest)) : this.logbookApi
.findDatasetLogbook(encodeURIComponent(pid), JSON.stringify(theRest)))
.pipe(
map((logbook: Logbook) =>
fromActions.fetchCountCompleteAction({
map((logbook: Logbook) => {
return fromActions.fetchCountCompleteAction({
count: logbook.messages.length,
})
});
}

),
catchError(() => of(fromActions.fetchCountFailedAction()))
);
Expand Down