Skip to content

Commit

Permalink
refactor: redundant code
Browse files Browse the repository at this point in the history
- checkQueryMatchingKey -> unused
- this.request.params.workItem -> replace to upsInstanceUID
- fixed typo of `this.isDeletionLock`
  • Loading branch information
Chinlinlee committed May 30, 2023
1 parent 98b3f34 commit f819367
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions api/dicom-web/controller/UPS-RS/service/subscribe.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ class SubscribeService extends BaseWorkItemService {
if (this.upsInstanceUID === SUBSCRIPTION_FIXED_UIDS.GlobalUID ||
this.upsInstanceUID === SUBSCRIPTION_FIXED_UIDS.FilteredGlobalUID) {

this.checkQueryMatchingKey();
this.query = convertAllQueryToDICOMTag(this.request.query);
await this.createOrUpdateGlobalSubscription();
} else {
let workItem = await this.findOneWorkItem(this.request.params.workItem);
let workItem = await this.findOneWorkItem(this.upsInstanceUID);
await this.createOrUpdateSubscription(workItem);
this.addUpsEvent(UPS_EVENT_TYPE.StateReport, this.upsInstanceUID, this.stateReportOf(workItem), [this.subscriberAeTitle]);
}
Expand Down Expand Up @@ -109,14 +108,14 @@ class SubscribeService extends BaseWorkItemService {
_id: subscription._id
}, {
$set: {
isDeletionLock: this.isDeletionLock,
isDeletionLock: this.deletionLock,
subscribed: subscribed
},
$addToSet: {
workItems: workItem.dicomJson._id
}
});
subscription.isDeletionLock = this.isDeletionLock;
subscription.isDeletionLock = this.deletionLock;
subscription.subscribed = subscribed;
return updatedSubscription;
}
Expand Down Expand Up @@ -168,19 +167,6 @@ class SubscribeService extends BaseWorkItemService {
}
}

checkQueryMatchingKey() {
let hexRegex = /[0-9a-fA-F]/g;
for(let key in this.request.query) {
if (!hexRegex.test(key) || key.length !== 8) {
throw new DicomWebServiceError(
DicomWebStatusCodes.InvalidArgumentValue,
`Invalid Argument: ${key}`,
400
);
}
}
}

async findOneGlobalSubscription() {

let globalSubscription = await globalSubscriptionModel.findOne({
Expand Down

0 comments on commit f819367

Please sign in to comment.