From d79278f75bcaebb5aba6afa2678f920cfbc3fb46 Mon Sep 17 00:00:00 2001 From: Sairam Charan Date: Tue, 25 Jun 2024 12:25:22 +0530 Subject: [PATCH 1/5] feat: WEB-2336 added a new key to whisp data structure --- schema.gql | 2 ++ src/interfaces/whisp.interface.ts | 1 + src/whisp/whisp.entity.ts | 3 +++ src/whisp/whisp.input.ts | 5 +++++ src/whisp/whisp.schema.ts | 9 +++++++++ 5 files changed, 20 insertions(+) diff --git a/schema.gql b/schema.gql index 07536e102..2fd3ccc1c 100644 --- a/schema.gql +++ b/schema.gql @@ -60,6 +60,7 @@ type Whisp { tags: [Tag!] data: JSONObject attachments: [WhispAttachment!] + dataIndexKey: String } """ @@ -129,6 +130,7 @@ input WhispInputType { applicationID: String plantID: String locationID: String + dataIndexKey: String manual: Boolean openedBy: String openedById: String diff --git a/src/interfaces/whisp.interface.ts b/src/interfaces/whisp.interface.ts index 12657445d..df3220d7b 100644 --- a/src/interfaces/whisp.interface.ts +++ b/src/interfaces/whisp.interface.ts @@ -16,6 +16,7 @@ export interface IWhisp extends Document { openedById: string; closedBy: string; closedById: string; + dataIndexKey: string; timestamp: Date; updated: Date; expirationDate?: Date; diff --git a/src/whisp/whisp.entity.ts b/src/whisp/whisp.entity.ts index a7a3273ad..aae1766e1 100644 --- a/src/whisp/whisp.entity.ts +++ b/src/whisp/whisp.entity.ts @@ -70,4 +70,7 @@ export class Whisp { @Field(() => [WhispAttachment], { nullable: true }) attachments?: WhispAttachment[]; + + @Field({ nullable: true }) + dataIndexKey?: string; } diff --git a/src/whisp/whisp.input.ts b/src/whisp/whisp.input.ts index ee8ddec87..c79198459 100644 --- a/src/whisp/whisp.input.ts +++ b/src/whisp/whisp.input.ts @@ -61,6 +61,11 @@ export class WhispInputType { @IsOptional() locationID?: string; + @Field(() => String, { nullable: true }) + @IsString() + @IsOptional() + dataIndexKey?: string; + @Field(() => Boolean, { nullable: true }) @IsBoolean() @IsOptional() diff --git a/src/whisp/whisp.schema.ts b/src/whisp/whisp.schema.ts index 0119acaa3..007fb5082 100644 --- a/src/whisp/whisp.schema.ts +++ b/src/whisp/whisp.schema.ts @@ -16,6 +16,7 @@ export const whispSchema = new mongoose.Schema({ closedById: String, timestamp: Date, updated: Date, + dataIndexKey: String, expirationDate: { type: Date, expires: 0 }, timeToLiveSec: Number, data: Object, @@ -33,6 +34,14 @@ whispSchema.index({ closed: 1, timestamp: 1, type: 1, + dataIndexKey: 1 +}); + +whispSchema.index({ + dataIndexKey: 1, + applicationID: 1, + closed: 1, + type: 1 }); mongoose.model('Whisp', whispSchema); From 6ab0a3b610faca26c9e175eb39f485ec88a28be9 Mon Sep 17 00:00:00 2001 From: Sairam Charan Date: Tue, 25 Jun 2024 12:29:23 +0530 Subject: [PATCH 2/5] feat: WEB-2336 lint fix --- src/whisp/whisp.schema.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/whisp/whisp.schema.ts b/src/whisp/whisp.schema.ts index 007fb5082..de8191f86 100644 --- a/src/whisp/whisp.schema.ts +++ b/src/whisp/whisp.schema.ts @@ -34,14 +34,14 @@ whispSchema.index({ closed: 1, timestamp: 1, type: 1, - dataIndexKey: 1 + dataIndexKey: 1, }); whispSchema.index({ dataIndexKey: 1, applicationID: 1, closed: 1, - type: 1 + type: 1, }); mongoose.model('Whisp', whispSchema); From 768a4bf99872b926122e5b0a4b64ba0414e92a44 Mon Sep 17 00:00:00 2001 From: Sairam Charan Date: Tue, 25 Jun 2024 13:56:07 +0530 Subject: [PATCH 3/5] feat: WEB-2336 removed extra index --- src/whisp/whisp.schema.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/whisp/whisp.schema.ts b/src/whisp/whisp.schema.ts index de8191f86..3967d8b69 100644 --- a/src/whisp/whisp.schema.ts +++ b/src/whisp/whisp.schema.ts @@ -37,11 +37,4 @@ whispSchema.index({ dataIndexKey: 1, }); -whispSchema.index({ - dataIndexKey: 1, - applicationID: 1, - closed: 1, - type: 1, -}); - mongoose.model('Whisp', whispSchema); From 1aa1ff2550415bba294297b27f85696de99289c0 Mon Sep 17 00:00:00 2001 From: Sairam Charan Date: Tue, 25 Jun 2024 14:03:14 +0530 Subject: [PATCH 4/5] feat: WEB-2336 removed dataindex from default index --- src/whisp/whisp.schema.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/whisp/whisp.schema.ts b/src/whisp/whisp.schema.ts index 3967d8b69..1dbc85d4a 100644 --- a/src/whisp/whisp.schema.ts +++ b/src/whisp/whisp.schema.ts @@ -34,7 +34,13 @@ whispSchema.index({ closed: 1, timestamp: 1, type: 1, +}); + +whispSchema.index({ dataIndexKey: 1, + applicationID: 1, + closed: 1, + type: 1 }); mongoose.model('Whisp', whispSchema); From ebfbc52a39e74b92f4ef09d9fcb62e5830c1ff65 Mon Sep 17 00:00:00 2001 From: Sairam Charan Date: Tue, 25 Jun 2024 14:03:56 +0530 Subject: [PATCH 5/5] feat: WEB-2336 lint fix --- src/whisp/whisp.schema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/whisp/whisp.schema.ts b/src/whisp/whisp.schema.ts index 1dbc85d4a..3f257bd06 100644 --- a/src/whisp/whisp.schema.ts +++ b/src/whisp/whisp.schema.ts @@ -40,7 +40,7 @@ whispSchema.index({ dataIndexKey: 1, applicationID: 1, closed: 1, - type: 1 + type: 1, }); mongoose.model('Whisp', whispSchema);