Skip to content

Commit

Permalink
fix: summary does not load indefinitely if there are no votes
Browse files Browse the repository at this point in the history
  • Loading branch information
nickoferrall committed Jan 10, 2025
1 parent dead68c commit c814666
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const WholeMeetingSummary = (props: Props) => {
const reflections = reflectionGroups?.flatMap((group) => group.reflections) // reflectionCount hasn't been calculated yet so check reflections length
const hasMoreThanOneReflection = reflections?.length && reflections.length > 1
if (!hasMoreThanOneReflection || !organization.useAI || !hasAiApiKey) return null
if (!wholeMeetingSummary) return <WholeMeetingSummaryLoading />
if (wholeMeetingSummary === undefined) return <WholeMeetingSummaryLoading /> // summary is undefined if it hasn't been generated yet. it's null if unsuccessful
return <WholeMeetingSummaryResult meetingRef={meeting} />
} else if (meeting.__typename === 'TeamPromptMeeting') {
const {summary: wholeMeetingSummary, responses, organization} = meeting
Expand Down
16 changes: 13 additions & 3 deletions packages/server/graphql/mutations/helpers/generateRetroSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import {DataLoaderWorker} from '../../graphql'
import canAccessAI from './canAccessAI'
import {transformRetroToAIFormat} from './transformRetroToAIFormat'

const setSummaryToNull = async (meetingId: string) => {
const pg = getKysely()
await pg.updateTable('NewMeeting').set({summary: null}).where('id', '=', meetingId).execute()
return null
}

export const generateRetroSummary = async (
meetingId: string,
dataLoader: DataLoaderWorker,
Expand All @@ -15,11 +21,13 @@ export const generateRetroSummary = async (

const team = await dataLoader.get('teams').loadNonNull(teamId)
const isAISummaryAccessible = await canAccessAI(team, 'retrospective', dataLoader)
if (!isAISummaryAccessible) return null
if (!isAISummaryAccessible) {
return setSummaryToNull(meetingId)
}

const transformedMeeting = await transformRetroToAIFormat(meetingId, dataLoader)
if (!transformedMeeting || transformedMeeting.length === 0) {
return null
return setSummaryToNull(meetingId)
}

const yamlData = yaml.dump(transformedMeeting, {
Expand All @@ -28,7 +36,9 @@ export const generateRetroSummary = async (

const manager = new OpenAIServerManager()
const newSummary = await manager.generateSummary(yamlData, prompt)
if (!newSummary) return null
if (!newSummary) {
return setSummaryToNull(meetingId)
}

const pg = getKysely()
await pg
Expand Down

0 comments on commit c814666

Please sign in to comment.