Skip to content

Commit

Permalink
refactor(api): test cached groups
Browse files Browse the repository at this point in the history
  • Loading branch information
vplasencia committed Dec 4, 2023
1 parent 8b8d9dc commit c7a64f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions apps/api/src/app/groups/groups.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ export class GroupsController {
return groups.map((g) => mapGroupToResponseDTO(g))
}

@Get("/cachedgroups")
@ApiOperation({ description: "Returns the cached groups." })
@ApiCreatedResponse()
async getCachedGroups() {
const groups = await this.groupsService.getCachedGroups()

console.log("Controller", groups)

Check warning on line 58 in apps/api/src/app/groups/groups.controller.ts

View workflow job for this annotation

GitHub Actions / style

Unexpected console statement

Check warning on line 58 in apps/api/src/app/groups/groups.controller.ts

View workflow job for this annotation

GitHub Actions / style

Unexpected console statement

return groups
}

@Get(":group")
@ApiOperation({ description: "Returns a specific group." })
@ApiCreatedResponse({ type: Group })
Expand Down
8 changes: 7 additions & 1 deletion apps/api/src/app/groups/groups.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class GroupsService {
}

/**
* Initialises the service, caches groups and may sync contrac
* Initialises the service, caches groups and may sync contract
* groups if required.
*/
async initialize() {
Expand Down Expand Up @@ -630,6 +630,12 @@ export class GroupsService {
return group
}

async getCachedGroups() {
console.log("Service", Array.from(this.cachedGroups.keys()))

Check warning on line 634 in apps/api/src/app/groups/groups.service.ts

View workflow job for this annotation

GitHub Actions / style

Unexpected console statement

Check warning on line 634 in apps/api/src/app/groups/groups.service.ts

View workflow job for this annotation

GitHub Actions / style

Unexpected console statement

return Array.from(this.cachedGroups.keys())
}

/**
* Checks if a member belongs to a group.
* @param groupId Group id.
Expand Down

0 comments on commit c7a64f5

Please sign in to comment.