-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: prepare start and endRetrospective for recurrence
Only refactored part of the functionality into different functions.
- Loading branch information
1 parent
dc6be15
commit 2d4e20a
Showing
6 changed files
with
365 additions
and
280 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
58 changes: 58 additions & 0 deletions
58
packages/server/graphql/mutations/helpers/safeCreateRetrospective.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,58 @@ | ||
import getRethink from '../../../database/rethinkDriver' | ||
import MeetingRetrospective from '../../../database/types/MeetingRetrospective' | ||
import generateUID from '../../../generateUID' | ||
import {MeetingTypeEnum} from '../../../postgres/types/Meeting' | ||
import {DataLoaderWorker} from '../../graphql' | ||
import createNewMeetingPhases from './createNewMeetingPhases' | ||
|
||
export const DEFAULT_PROMPT = 'What are you working on today? Stuck on anything?' | ||
|
||
const safeCreateRetrospective = async ( | ||
meetingSettings: { | ||
teamId: string | ||
facilitatorUserId: string | ||
totalVotes: number | ||
maxVotesPerGroup: number | ||
disableAnonymity: boolean | ||
templateId: string | ||
videoMeetingURL?: string | ||
}, | ||
dataLoader: DataLoaderWorker | ||
) => { | ||
const r = await getRethink() | ||
const {teamId, facilitatorUserId} = meetingSettings | ||
const meetingType: MeetingTypeEnum = 'retrospective' | ||
const [meetingCount, team] = await Promise.all([ | ||
r | ||
.table('NewMeeting') | ||
.getAll(teamId, {index: 'teamId'}) | ||
.filter({meetingType}) | ||
.count() | ||
.default(0) | ||
.run(), | ||
dataLoader.get('teams').loadNonNull(teamId) | ||
]) | ||
|
||
const organization = await r.table('Organization').get(team.orgId).run() | ||
const {showConversionModal} = organization | ||
|
||
const meetingId = generateUID() | ||
const phases = await createNewMeetingPhases( | ||
facilitatorUserId, | ||
teamId, | ||
meetingId, | ||
meetingCount, | ||
meetingType, | ||
dataLoader | ||
) | ||
|
||
return new MeetingRetrospective({ | ||
id: meetingId, | ||
meetingCount, | ||
phases, | ||
showConversionModal, | ||
...meetingSettings | ||
}) | ||
} | ||
|
||
export default safeCreateRetrospective |
Oops, something went wrong.