Skip to content

Commit de0db32

Browse files
committed
only set needs review if non name uuids
1 parent 3a9ae04 commit de0db32

File tree

8 files changed

+33
-32
lines changed

8 files changed

+33
-32
lines changed

src/main/webapp/app/config/constants/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,3 +458,5 @@ export const SOMATIC_GERMLINE_SETTING_KEY = 'oncokbCuration-somaticGermlineSetti
458458
export const DUPLICATE_THERAPY_ERROR_MESSAGE = 'Each therapy must be unique';
459459
export const EMPTY_THERAPY_ERROR_MESSAGE = 'You must include at least one drug for each therapy';
460460
export const THERAPY_ALREADY_EXISTS_ERROR_MESSAGE = 'Therapy already exists';
461+
462+
export const NEW_NAME_UUID_VALUE = 'name';

src/main/webapp/app/pages/curation/geneticTypeTabs/GeneticTypeTabs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { observer } from 'mobx-react';
66
import { IRootStore } from 'app/stores';
77
import { IGene } from 'app/shared/model/gene.model';
88
import DefaultBadge from 'app/shared/badge/DefaultBadge';
9-
import { geneMetaReviewHasUuids, getFirebaseMetaGenePath } from 'app/shared/util/firebase/firebase-utils';
9+
import { geneMetaReviewHasNonNameUuids, getFirebaseMetaGenePath } from 'app/shared/util/firebase/firebase-utils';
1010
import { GERMLINE_PATH, SOMATIC_GERMLINE_SETTING_KEY, SOMATIC_PATH } from 'app/config/constants/constants';
1111
import { onValue, ref, Unsubscribe } from 'firebase/database';
1212
import { MetaReview } from 'app/shared/model/firebase/firebase.model';
@@ -74,8 +74,8 @@ const GeneticTypeTabs = ({ geneEntity, geneticType, firebaseDb, location, histor
7474
const sharedStyle: React.CSSProperties = { fontSize: '0.8rem' };
7575

7676
const needsReview = {
77-
[GENETIC_TYPE.SOMATIC]: geneMetaReviewHasUuids(somaticMetaReview),
78-
[GENETIC_TYPE.GERMLINE]: geneMetaReviewHasUuids(germlineMetaReview),
77+
[GENETIC_TYPE.SOMATIC]: geneMetaReviewHasNonNameUuids(somaticMetaReview),
78+
[GENETIC_TYPE.GERMLINE]: geneMetaReviewHasNonNameUuids(germlineMetaReview),
7979
};
8080
if (needsReview[type]) {
8181
badges.push(

src/main/webapp/app/pages/curation/header/GeneticTypeTabHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { observer } from 'mobx-react';
44
import React, { useEffect, useState } from 'react';
55
import { onValue, ref } from 'firebase/database';
66
import { Meta } from 'app/shared/model/firebase/firebase.model';
7-
import { geneMetaReviewHasUuids, getFirebaseMetaGenePath } from 'app/shared/util/firebase/firebase-utils';
7+
import { geneMetaReviewHasNonNameUuids, getFirebaseMetaGenePath } from 'app/shared/util/firebase/firebase-utils';
88
import { PAGE_ROUTE } from 'app/config/constants/constants';
99
import { Button } from 'reactstrap';
1010
import { notifyError } from 'app/oncokb-commons/components/util/NotificationUtils';
@@ -60,7 +60,7 @@ const GeneticTypeTabHeader = ({
6060

6161
const getReviewButton = () => {
6262
let button: JSX.Element;
63-
if (geneMetaReviewHasUuids(meta?.review)) {
63+
if (geneMetaReviewHasNonNameUuids(meta?.review)) {
6464
if (isReviewing || isReviewFinished) {
6565
button = (
6666
<Button color="primary" onClick={handleReviewButtonClick} data-testid={GENE_HEADER_REVIEW_COMPLETE_BUTTON_ID}>

src/main/webapp/app/service/firebase/firebase-gene-review-service.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ describe('Firebase Gene Review Service', () => {
5151
jest.useFakeTimers().setSystemTime(DEFAULT_DATE);
5252

5353
// Use original implementation for certain methods
54-
mockMetaService.getUpdateObject.mockImplementation((add, hugoSymbol, isGermline, uuid) => {
54+
mockMetaService.getUpdateObject.mockImplementation((hugoSymbol, isGermline, uuidUpdateObjects) => {
5555
const originalMetaService = new FirebaseMetaService(mockFirebaseRepository, mockAuthStore);
56-
return originalMetaService.getUpdateObject(add, hugoSymbol, isGermline, uuid);
56+
return originalMetaService.getUpdateObject(hugoSymbol, isGermline, uuidUpdateObjects);
5757
});
5858

5959
mockHistoryService.getUpdateObject.mockImplementation((history, hugoSymbol, isGermline) => {

src/main/webapp/app/service/firebase/firebase-gene-review-service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class FirebaseGeneReviewService {
9898
const { hugoSymbol } = parseFirebaseGenePath(firebasePath) ?? {};
9999

100100
let updateObject = this.getGeneUpdateObject(updateValue, updatedReview!, firebasePath, uuid!);
101-
const metaUpdateObject = this.firebaseMetaService.getUpdateObject(!isChangeReverted, hugoSymbol!, isGermline, [uuid!]);
101+
const metaUpdateObject = this.firebaseMetaService.getUpdateObject(hugoSymbol!, isGermline, { [uuid!]: !isChangeReverted });
102102
updateObject = { ...updateObject, ...metaUpdateObject };
103103

104104
if (!shouldSave) {
@@ -265,7 +265,7 @@ export class FirebaseGeneReviewService {
265265
} else {
266266
throw new SentryError('Unexpect accept in review mode', { hugoSymbol, reviewLevel, isGermline, isAcceptAll });
267267
}
268-
const metaUpdateObject = this.firebaseMetaService.getUpdateObject(false, hugoSymbol, isGermline, [uuid]);
268+
const metaUpdateObject = this.firebaseMetaService.getUpdateObject(hugoSymbol, isGermline, { [uuid]: null });
269269
updateObject = { ...updateObject, ...metaUpdateObject };
270270
}
271271

@@ -327,7 +327,7 @@ export class FirebaseGeneReviewService {
327327
throw new SentryError('Unexpected reject in review mode', { hugoSymbol, reviewLevels, isGermline });
328328
}
329329

330-
const metaUpdateObject = this.firebaseMetaService.getUpdateObject(false, hugoSymbol, isGermline, [uuid]);
330+
const metaUpdateObject = this.firebaseMetaService.getUpdateObject(hugoSymbol, isGermline, { [uuid]: null });
331331
updateObject = { ...updateObject, ...metaUpdateObject };
332332

333333
try {
@@ -344,7 +344,7 @@ export class FirebaseGeneReviewService {
344344
let updateObject = await this.getCreateUpdateObject(hugoSymbol, reviewLevel, isGermline, action);
345345
updateObject = {
346346
...updateObject,
347-
...this.firebaseMetaService.getUpdateObject(false, hugoSymbol, isGermline, [reviewLevel.reviewInfo.uuid]),
347+
...this.firebaseMetaService.getUpdateObject(hugoSymbol, isGermline, { [reviewLevel.reviewInfo.uuid]: null }),
348348
};
349349
try {
350350
await this.firebaseRepository.update('/', updateObject);

src/main/webapp/app/service/firebase/firebase-gene-service.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { getErrorMessage } from 'app/oncokb-commons/components/alert/ErrorAlertU
3333
import { FirebaseDataStore } from 'app/stores/firebase/firebase-data.store';
3434
import { getTumorNameUuid, getUpdatedReview } from 'app/shared/util/firebase/firebase-review-utils';
3535
import { SentryError } from 'app/config/sentry-error';
36-
import { GERMLINE_PATH, GET_ALL_DRUGS_PAGE_SIZE } from 'app/config/constants/constants';
36+
import { GERMLINE_PATH, GET_ALL_DRUGS_PAGE_SIZE, NEW_NAME_UUID_VALUE } from 'app/config/constants/constants';
3737
import _ from 'lodash';
3838
import { getDriveAnnotations } from 'app/shared/util/core-drive-annotation-submission/core-drive-annotation-submission';
3939
import { DriveAnnotationApi } from 'app/shared/api/manual/drive-annotation-api';
@@ -254,13 +254,13 @@ export class FirebaseGeneService {
254254
updateObject = { ...updateObject, ...deleteArrayReturnVal.updateObject };
255255
}
256256
for (const id of [...nestedUuids, uuid]) {
257-
updateObject = { ...updateObject, ...this.firebaseMetaService.getUpdateObject(false, hugoSymbol, isGermline, [id]) };
257+
updateObject = { ...updateObject, ...this.firebaseMetaService.getUpdateObject(hugoSymbol, isGermline, { [id]: null }) };
258258
}
259259
} else {
260260
updateObject = {
261261
...updateObject,
262262
[`${getFirebaseGenePath(isGermline, hugoSymbol)}/${pathFromGene}_review`]: review,
263-
...this.firebaseMetaService.getUpdateObject(true, hugoSymbol, isGermline, [uuid]),
263+
...this.firebaseMetaService.getUpdateObject(hugoSymbol, isGermline, { [uuid]: true }),
264264
};
265265
}
266266

@@ -312,7 +312,7 @@ export class FirebaseGeneService {
312312
throw new SentryError('Could not resolve hugoSymbol', { tumorPath });
313313
}
314314

315-
let updateObject = { ...this.firebaseMetaService.getUpdateObject(true, hugoSymbol, isGermline, [tumorNameUuid]) };
315+
let updateObject = { ...this.firebaseMetaService.getUpdateObject(hugoSymbol, isGermline, { [tumorNameUuid]: NEW_NAME_UUID_VALUE }) };
316316
const pushResult = await this.firebaseRepository.push(tumorPath, newTumor, false);
317317
if (pushResult !== undefined) {
318318
updateObject = { ...updateObject, ...pushResult.pushUpdateObject };
@@ -397,7 +397,7 @@ export class FirebaseGeneService {
397397

398398
if (hugoSymbol !== undefined) {
399399
let updateObject = {
400-
...this.firebaseMetaService.getUpdateObject(true, hugoSymbol, isGermline, [newTreatment.name_uuid]),
400+
...this.firebaseMetaService.getUpdateObject(hugoSymbol, isGermline, { [newTreatment.name_uuid]: NEW_NAME_UUID_VALUE }),
401401
};
402402
const pushResult = await this.firebaseRepository.push(treatmentPath, newTreatment, false);
403403
if (pushResult !== undefined) {
@@ -457,12 +457,12 @@ export class FirebaseGeneService {
457457

458458
if (hugoSymbol !== undefined) {
459459
let updateObject = {
460-
...this.firebaseMetaService.getUpdateObject(true, hugoSymbol, isGermline, [newMutation.name_uuid]),
460+
...this.firebaseMetaService.getUpdateObject(hugoSymbol, isGermline, { [newMutation.name_uuid]: NEW_NAME_UUID_VALUE }),
461461
};
462462
if (mutationEffectDescription) {
463463
updateObject = {
464464
...updateObject,
465-
...this.firebaseMetaService.getUpdateObject(true, hugoSymbol, isGermline, [newMutation.mutation_effect.description_uuid]),
465+
...this.firebaseMetaService.getUpdateObject(hugoSymbol, isGermline, { [newMutation.mutation_effect.description_uuid]: true }),
466466
};
467467
}
468468

@@ -511,7 +511,7 @@ export class FirebaseGeneService {
511511
updateObject[rctPath] = newRelevantCancerTypes;
512512
updateObject[`${rctPath}_review`] = new Review(this.authStore.fullName, undefined, undefined, undefined, true);
513513
updateObject[`${rctPath}_uuid`] = uuid;
514-
const metaUpdateObject = this.firebaseMetaService.getUpdateObject(true, hugoSymbol!, isGermline, [uuid]);
514+
const metaUpdateObject = this.firebaseMetaService.getUpdateObject(hugoSymbol!, isGermline, { [uuid]: true });
515515
updateObject = { ...updateObject, ...metaUpdateObject };
516516
} else {
517517
const rctUpdateObject = await this.firebaseGeneReviewService.updateReviewableContent(
@@ -546,7 +546,7 @@ export class FirebaseGeneService {
546546
) => {
547547
const genePath = parseFirebaseGenePath(genomicIndicatorsPath);
548548
const newGenomicIndicator = new GenomicIndicator();
549-
const uuidsToReview: string[] = [];
549+
const uuidsToReview: { [key: string]: string | boolean | null } = {};
550550
const mutationList = this.firebaseMutationListStore.data;
551551
const pathogenicVariants = Object.values(mutationList ?? {}).find(mut => mut.name === PATHOGENIC_VARIANTS);
552552
let pathogenicVariantsNameUuid = pathogenicVariants?.name_uuid;
@@ -568,13 +568,13 @@ export class FirebaseGeneService {
568568
if (toReview) {
569569
newGenomicIndicator.name_review = _.cloneDeep(newReview);
570570
newGenomicIndicator.name_review.added = true;
571-
uuidsToReview.push(newGenomicIndicator.name_uuid);
571+
uuidsToReview[newGenomicIndicator.name_uuid] = NEW_NAME_UUID_VALUE;
572572
}
573573
if (description) {
574574
newGenomicIndicator.description = description;
575575
if (toReview) {
576576
newGenomicIndicator.description_review = newReview;
577-
uuidsToReview.push(newGenomicIndicator.description_uuid);
577+
uuidsToReview[newGenomicIndicator.description_uuid] = true;
578578
}
579579
}
580580

@@ -584,7 +584,7 @@ export class FirebaseGeneService {
584584
newGenomicIndicator.allele_state[asKey] = alleleState;
585585
if (toReview) {
586586
newGenomicIndicator.allele_state[`${asKey}_review`] = newReview;
587-
uuidsToReview.push(newGenomicIndicator.allele_state[`${asKey}_uuid`]);
587+
uuidsToReview[newGenomicIndicator.allele_state[`${asKey}_uuid`]] = true;
588588
}
589589
});
590590
}
@@ -602,7 +602,7 @@ export class FirebaseGeneService {
602602
}
603603

604604
if (toReview) {
605-
updateObject = { ...updateObject, ...this.firebaseMetaService.getUpdateObject(true, hugoSymbol, true, uuidsToReview) };
605+
updateObject = { ...updateObject, ...this.firebaseMetaService.getUpdateObject(hugoSymbol, true, uuidsToReview) };
606606
}
607607

608608
await this.firebaseRepository.update('/', updateObject);

src/main/webapp/app/service/firebase/firebase-meta-service.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,15 @@ export class FirebaseMetaService {
108108
await this.firebaseRepository.delete(getFirebaseMetaGenePath(isGermline, hugoSymbol));
109109
};
110110

111-
getUpdateObject = (add: boolean, hugoSymbol: string, isGermline: boolean, uuids: string[]) => {
111+
getUpdateObject = (hugoSymbol: string, isGermline: boolean, uuidUpdateObjects: { [key: string]: string | boolean | null }) => {
112112
const metaGenePath = getFirebaseMetaGenePath(isGermline, hugoSymbol);
113-
const uuidUpdateValue = add ? true : null;
114113
const updateObject: { [key: string]: string | boolean | null } = {
115114
[`${metaGenePath}/lastModifiedBy`]: this.authStore.fullName,
116115
[`${metaGenePath}/lastModifiedAt`]: new Date().getTime().toString(),
117116
};
118-
for (const uuid of uuids) {
117+
for (const [uuid, uuidUpdateValue] of Object.entries(uuidUpdateObjects)) {
119118
updateObject[`${metaGenePath}/review/${uuid}`] = uuidUpdateValue;
120-
if (!add) {
119+
if (uuidUpdateValue === null) {
121120
const uuidParts = this.getUuidParts(uuid);
122121
uuidParts.forEach(uuidPart => {
123122
updateObject[`${metaGenePath}/review/${uuidPart}`] = uuidUpdateValue;

src/main/webapp/app/shared/util/firebase/firebase-utils.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { APP_EXPANDED_DATETIME_FORMAT, CURRENT_REVIEWER } from 'app/config/constants/constants';
1+
import { APP_EXPANDED_DATETIME_FORMAT, CURRENT_REVIEWER, NEW_NAME_UUID_VALUE } from 'app/config/constants/constants';
22
import { FB_COLLECTION, FB_COLLECTION_PATH } from 'app/config/constants/firebase';
33
import { NestLevelType, RemovableNestLevel } from 'app/pages/curation/collapsible/NestLevel';
44
import { IDrug } from 'app/shared/model/drug.model';
@@ -84,7 +84,7 @@ export const getTxName = (drugList: readonly IDrug[], txUuidName: string | undef
8484
};
8585

8686
export const geneNeedsReview = (meta: Meta | null | undefined) => {
87-
return geneMetaReviewHasUuids(meta?.review);
87+
return geneMetaReviewHasNonNameUuids(meta?.review);
8888
};
8989

9090
export const mutationNeedsReview = (mutation: Mutation, review: MetaReview) => {
@@ -114,10 +114,10 @@ export const mutationNeedsReview = (mutation: Mutation, review: MetaReview) => {
114114
return false;
115115
};
116116

117-
export const geneMetaReviewHasUuids = (metaReview: MetaReview | undefined) => {
117+
export const geneMetaReviewHasNonNameUuids = (metaReview: MetaReview | undefined) => {
118118
let needsReview = false;
119119
if (metaReview) {
120-
needsReview = !!Object.keys(metaReview).find(key => isUuid(key));
120+
needsReview = Object.entries(metaReview).some(([key, val]) => isUuid(key) && val !== NEW_NAME_UUID_VALUE);
121121
}
122122
return needsReview;
123123
};

0 commit comments

Comments
 (0)