Skip to content

Commit

Permalink
update suggest group titles
Browse files Browse the repository at this point in the history
  • Loading branch information
nickoferrall committed Dec 9, 2024
1 parent b073840 commit ecd3f1b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
1 change: 1 addition & 0 deletions packages/client/mutations/AutogroupMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ graphql`
reflectionGroups {
id
title
smartTitle
reflections {
id
plaintextContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Input = {
}

const updateGroupTitle = async (input: Input) => {
console.log('in update group...')
const {reflections, reflectionGroupId, meetingId, teamId, dataLoader} = input
if (reflections.length === 1) {
// For single reflection, use its content as the title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import dndNoise from 'parabol-client/utils/dndNoise'
import getKysely from '../../../../postgres/getKysely'
import updateGroupTitle from '../updateGroupTitle'
import {GQLContext} from './../../../graphql'
import updateSmartGroupTitle from './updateSmartGroupTitle'

const addReflectionToGroup = async (
reflectionId: string,
Expand All @@ -14,10 +15,9 @@ const addReflectionToGroup = async (
const reflection = await dataLoader.get('retroReflections').load(reflectionId)
if (!reflection) throw new Error('Reflection not found')
const {reflectionGroupId: oldReflectionGroupId, meetingId: reflectionMeetingId} = reflection
const [reflectionGroup, oldReflectionGroup] = await Promise.all([
dataLoader.get('retroReflectionGroups').loadNonNull(reflectionGroupId),
dataLoader.get('retroReflectionGroups').loadNonNull(oldReflectionGroupId)
])
const reflectionGroup = await dataLoader
.get('retroReflectionGroups')
.loadNonNull(reflectionGroupId)
dataLoader.get('retroReflectionGroups').clear(reflectionGroupId)
dataLoader.get('retroReflectionGroups').clear(oldReflectionGroupId)

Expand Down Expand Up @@ -56,17 +56,11 @@ const addReflectionToGroup = async (
.get('retroReflectionsByGroupId')
.load(oldReflectionGroupId)

const oldGroupHasSingleReflectionCustomTitle =
oldReflectionGroup.title !== oldReflectionGroup.smartTitle && oldReflections.length === 0
const newGroupHasSmartTitle = reflectionGroup.title === reflectionGroup.smartTitle

if (oldGroupHasSingleReflectionCustomTitle && newGroupHasSmartTitle) {
// Edge case of dragging a single card with a custom group name on a group with smart name
await pg
.updateTable('RetroReflectionGroup')
.set({title: oldReflectionGroup.title, smartTitle: smartTitle ?? ''})
.where('id', '=', reflectionGroupId)
.execute()
if (smartTitle) {
// smartTitle exists when autogrouping or resetting groups
await updateSmartGroupTitle(reflectionGroupId, smartTitle)
reflectionGroup.smartTitle = smartTitle
reflectionGroup.title = smartTitle
} else {
const meeting = await dataLoader.get('newMeetings').loadNonNull(meetingId)
await updateGroupTitle({
Expand Down

0 comments on commit ecd3f1b

Please sign in to comment.