-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #667 from microsoft/dev
July Sprint 1 (Due July 15th) Release
- Loading branch information
Showing
80 changed files
with
1,993 additions
and
911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/api/src/interactors/query/GetUserActiveEngagementsInteractor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/*! | ||
* Copyright (c) Microsoft. All rights reserved. | ||
* Licensed under the MIT license. See LICENSE file in the project. | ||
*/ | ||
import { | ||
Engagement, | ||
EngagementStatus, | ||
QueryUserActiveEngagementsArgs | ||
} from '@cbosuite/schema/dist/provider-types' | ||
import { singleton } from 'tsyringe' | ||
import { Configuration } from '~components/Configuration' | ||
import { EngagementCollection } from '~db/EngagementCollection' | ||
import { DbEngagement } from '~db/types' | ||
import { createGQLEngagement } from '~dto' | ||
import { Interactor, RequestContext } from '~types' | ||
import { sortByDate } from '~utils' | ||
import { empty } from '~utils/noop' | ||
|
||
@singleton() | ||
export class GetUserActiveEngagementsInteractor | ||
implements Interactor<unknown, QueryUserActiveEngagementsArgs, Engagement[]> | ||
{ | ||
public constructor( | ||
protected engagements: EngagementCollection, | ||
protected config: Configuration | ||
) {} | ||
|
||
protected sortBy(a: DbEngagement, b: DbEngagement) { | ||
return sortByDate({ date: a.end_date as string }, { date: b.end_date as string }) | ||
} | ||
public async execute( | ||
_: unknown, | ||
{ orgId, userId, offset, limit }: QueryUserActiveEngagementsArgs, | ||
ctx: RequestContext | ||
): Promise<Engagement[]> { | ||
offset = offset ?? this.config.defaultPageOffset | ||
limit = limit ?? this.config.defaultPageLimit | ||
|
||
// out-of-org users should not see org engagements | ||
if (!ctx.identity?.roles.some((r) => r.org_id === orgId)) { | ||
return empty | ||
} | ||
|
||
const result = await this.engagements.items( | ||
{ offset, limit }, | ||
{ | ||
org_id: orgId, | ||
user_id: userId, | ||
status: { $nin: [EngagementStatus.Closed, EngagementStatus.Completed] } | ||
} | ||
) | ||
|
||
return result.items.sort(this.sortBy).map(createGQLEngagement) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ | |
}, | ||
"takePhotoMode": { | ||
"enabled": false | ||
}, | ||
"durableCache": { | ||
"enabled": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.