Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: last updates time bug in workspace #349

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

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions src/modules/workspace/controllers/collection.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ export class collectionController {
user.name,
requestDto?.folderId,
);
// update the updateAt timestamp
await this.workSpaceService.update(workspaceId, {});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of updating the timestamp here, call workspaceRepository.update inside collectionRequestService.addRequest.

const responseData = new ApiResponseService(
"Success",
HttpStatusCode.OK,
Expand Down Expand Up @@ -316,7 +318,8 @@ export class collectionController {
requestId,
requestDto,
);

// update the updateAt timestamp
await this.workSpaceService.update(workspaceId, {});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

const responseData = new ApiResponseService(
"Success",
HttpStatusCode.OK,
Expand Down Expand Up @@ -354,7 +357,8 @@ export class collectionController {
requestDto,
);
const collection = await this.collectionService.getCollection(collectionId);

// update the updateAt timestamp
await this.workSpaceService.update(workspaceId, {});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

const responseData = new ApiResponseService(
"Success",
HttpStatusCode.OK,
Expand Down
88 changes: 61 additions & 27 deletions src/modules/workspace/repositories/workspace.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ export class WorkspaceRepository {
activeSync: collection.activeSync,
},
},
$set: {
updatedAt: new Date(),
},
},
);
}
Expand All @@ -137,21 +140,28 @@ export class WorkspaceRepository {
): Promise<UpdateResult> {
const _id = new ObjectId(workspaceId);
const collection_id = new ObjectId(collectionId);
return this.db
.collection(Collections.WORKSPACE)
.updateOne(
{ _id, "collection.id": collection_id },
{ $set: { "collection.$.name": name } },
);
return this.db.collection(Collections.WORKSPACE).updateOne(
{ _id, "collection.id": collection_id },
{
$set: { "collection.$.name": name },
updatedAt: new Date(),
},
);
}
async deleteCollectioninWorkspace(
workspaceId: string,
collectionsArray: CollectionDto[],
): Promise<UpdateResult> {
const _id = new ObjectId(workspaceId);
return this.db
.collection(Collections.WORKSPACE)
.updateOne({ _id }, { $set: { collection: collectionsArray } });
return this.db.collection(Collections.WORKSPACE).updateOne(
{ _id },
{
$set: {
collection: collectionsArray,
updatedAt: new Date(),
},
},
);
}

async addEnvironmentInWorkspace(
Expand All @@ -169,6 +179,9 @@ export class WorkspaceRepository {
type: environment.type,
},
},
$set: {
updatedAt: new Date(),
},
},
);
}
Expand All @@ -178,9 +191,15 @@ export class WorkspaceRepository {
environmentsArray: EnvironmentDto[],
): Promise<UpdateResult> {
const _id = new ObjectId(workspaceId);
return this.db
.collection(Collections.WORKSPACE)
.updateOne({ _id }, { $set: { environments: environmentsArray } });
return this.db.collection(Collections.WORKSPACE).updateOne(
{ _id },
{
$set: {
environments: environmentsArray,
updatedAt: new Date(),
},
},
);
}

async updateEnvironmentinWorkspace(
Expand All @@ -190,12 +209,15 @@ export class WorkspaceRepository {
): Promise<UpdateResult> {
const _id = new ObjectId(workspaceId);
const environment_id = new ObjectId(environmentId);
return this.db
.collection(Collections.WORKSPACE)
.updateOne(
{ _id, "environments.id": environment_id },
{ $set: { "environments.$.name": name } },
);
return this.db.collection(Collections.WORKSPACE).updateOne(
{ _id, "environments.id": environment_id },
{
$set: {
"environments.$.name": name,
updatedAt: new Date(),
},
},
);
}

/**
Expand All @@ -221,6 +243,9 @@ export class WorkspaceRepository {
name: testflow.name,
},
},
$set: {
updatedAt: new Date(),
},
},
);
return response;
Expand All @@ -240,9 +265,15 @@ export class WorkspaceRepository {
testflowsArray: TestflowInfoDto[],
): Promise<UpdateResult> {
const _id = new ObjectId(workspaceId);
const response = await this.db
.collection(Collections.WORKSPACE)
.updateOne({ _id }, { $set: { testflows: testflowsArray } });
const response = await this.db.collection(Collections.WORKSPACE).updateOne(
{ _id },
{
$set: {
testflows: testflowsArray,
updatedAt: new Date(),
},
},
);
return response;
}

Expand All @@ -262,12 +293,15 @@ export class WorkspaceRepository {
name: string,
): Promise<UpdateResult> {
const _id = new ObjectId(workspaceId);
const response = await this.db
.collection(Collections.WORKSPACE)
.updateOne(
{ _id, "testflows.id": testflowId },
{ $set: { "testflows.$.name": name } },
);
const response = await this.db.collection(Collections.WORKSPACE).updateOne(
{ _id, "testflows.id": testflowId },
{
$set: {
"testflows.$.name": name,
updatedAt: new Date(),
},
},
);
return response;
}
}