Skip to content

Commit

Permalink
chore(rethinkdb): AgendaItem: Phase 3 (#10109)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <[email protected]>
  • Loading branch information
mattkrick authored Aug 16, 2024
1 parent 60f50bd commit bd802d5
Show file tree
Hide file tree
Showing 37 changed files with 455 additions and 627 deletions.
5 changes: 4 additions & 1 deletion codegen.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
"config": {
"contextType": "../graphql#GQLContext",
"mappers": {
"RemoveAgendaItemPayload": "./types/RemoveAgendaItemPayload#RemoveAgendaItemPayloadSource",
"AddAgendaItemPayload": "./types/AddAgendaItemPayload#AddAgendaItemPayloadSource",
"UpdateAgendaItemPayload": "./types/UpdateAgendaItemPayload#UpdateAgendaItemPayloadSource",
"TeamMeetingSettings": "../../postgres/types/index#MeetingSettings as TeamMeetingSettingsDB",
"TeamPromptMeetingSettings": "../../postgres/types/index#MeetingSettings as TeamMeetingSettingsDB",
"PokerMeetingSettings": "../../postgres/types/index#PokerMeetingSettings as PokerMeetingSettingsDB",
Expand All @@ -66,7 +69,7 @@
"AddTeamMemberIntegrationAuthSuccess": "./types/AddTeamMemberIntegrationAuthPayload#AddTeamMemberIntegrationAuthSuccessSource",
"AddTranscriptionBotSuccess": "./types/AddTranscriptionBotSuccess#AddTranscriptionBotSuccessSource",
"AddedNotification": "./types/AddedNotification#AddedNotificationSource",
"AgendaItem": "../../database/types/AgendaItem#default as AgendaItemDB",
"AgendaItem": "../../postgres/types/index#AgendaItem as AgendaItemDB",
"ArchiveTeamPayload": "./types/ArchiveTeamPayload#ArchiveTeamPayloadSource",
"AtlassianIntegration": "../../postgres/queries/getAtlassianAuthByUserIdTeamId#AtlassianAuth as AtlassianAuthDB",
"AuthTokenPayload": "./types/AuthTokenPayload#AuthTokenPayloadSource",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import useHotkey from '../../../../hooks/useHotkey'
import useMutationProps from '../../../../hooks/useMutationProps'
import useTooltip from '../../../../hooks/useTooltip'
import AddAgendaItemMutation from '../../../../mutations/AddAgendaItemMutation'
import {positionAfter} from '../../../../shared/sortOrder'
import makeFieldColorPalette from '../../../../styles/helpers/makeFieldColorPalette'
import makePlaceholderStyles from '../../../../styles/helpers/makePlaceholderStyles'
import {PALETTE} from '../../../../styles/paletteV3'
import ui from '../../../../styles/ui'
import getNextSortOrder from '../../../../utils/getNextSortOrder'
import toTeamMemberId from '../../../../utils/relay/toTeamMemberId'

const AgendaInputBlock = styled('div')({
Expand Down Expand Up @@ -123,7 +123,7 @@ const AgendaInput = (props: Props) => {
const newAgendaItem = {
content,
pinned: false,
sortOrder: getNextSortOrder(agendaItems),
sortOrder: positionAfter(agendaItems.at(-1)?.sortOrder ?? ''),
teamId,
teamMemberId: toTeamMemberId(teamId, atmosphere.viewerId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import useAtmosphere from '../../../../hooks/useAtmosphere'
import useEventCallback from '../../../../hooks/useEventCallback'
import useGotoStageId from '../../../../hooks/useGotoStageId'
import UpdateAgendaItemMutation from '../../../../mutations/UpdateAgendaItemMutation'
import {getSortOrder} from '../../../../shared/sortOrder'
import {navItemRaised} from '../../../../styles/elevation'
import {AGENDA_ITEM, SORT_STEP} from '../../../../utils/constants'
import dndNoise from '../../../../utils/dndNoise'
import {AGENDA_ITEM} from '../../../../utils/constants'
import AgendaItem from '../AgendaItem/AgendaItem'
import AgendaListEmptyState from './AgendaListEmptyState'

Expand Down Expand Up @@ -83,17 +83,7 @@ const AgendaList = (props: Props) => {
return
}

let sortOrder
if (destination.index === 0) {
sortOrder = destinationItem.sortOrder - SORT_STEP + dndNoise()
} else if (destination.index === agendaItems.length - 1) {
sortOrder = destinationItem.sortOrder + SORT_STEP + dndNoise()
} else {
const offset = source.index > destination.index ? -1 : 1
sortOrder =
(agendaItems[destination.index + offset]!.sortOrder + destinationItem.sortOrder) / 2 +
dndNoise()
}
const sortOrder = getSortOrder(agendaItems, source.index, destination.index)
UpdateAgendaItemMutation(
atmosphere,
{updatedAgendaItem: {id: sourceItem.id, sortOrder}},
Expand Down
14 changes: 0 additions & 14 deletions packages/client/validation/makeAgendaItemSchema.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/client/validation/makeUpdateAgendaItemSchema.ts

This file was deleted.

5 changes: 0 additions & 5 deletions packages/server/database/rethinkDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import TeamInvitation from '../database/types/TeamInvitation'
import {AnyMeeting, AnyMeetingTeamMember} from '../postgres/types/Meeting'
import getRethinkConfig from './getRethinkConfig'
import {R} from './stricterR'
import AgendaItem from './types/AgendaItem'
import Comment from './types/Comment'
import MassInvitation from './types/MassInvitation'
import NotificationKickedOut from './types/NotificationKickedOut'
Expand All @@ -24,10 +23,6 @@ import RetrospectivePrompt from './types/RetrospectivePrompt'
import Task from './types/Task'

export type RethinkSchema = {
AgendaItem: {
type: AgendaItem
index: 'teamId' | 'meetingId'
}
Comment: {
type: Comment
index: 'discussionId'
Expand Down
61 changes: 0 additions & 61 deletions packages/server/database/types/AgendaItem.ts

This file was deleted.

8 changes: 4 additions & 4 deletions packages/server/dataloader/foreignKeyLoaderMakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ export const teamPromptResponsesByMeetingId = foreignKeyLoaderMaker(
getTeamPromptResponsesByMeetingIds
)

export const _pgagendaItemsByTeamId = foreignKeyLoaderMaker(
'_pgagendaItems',
export const agendaItemsByTeamId = foreignKeyLoaderMaker(
'agendaItems',
'teamId',
async (teamIds) => {
return selectAgendaItems()
Expand All @@ -184,8 +184,8 @@ export const _pgagendaItemsByTeamId = foreignKeyLoaderMaker(
}
)

export const _pgagendaItemsByMeetingId = foreignKeyLoaderMaker(
'_pgagendaItems',
export const agendaItemsByMeetingId = foreignKeyLoaderMaker(
'agendaItems',
'meetingId',
async (meetingIds) => {
return selectAgendaItems().where('meetingId', 'in', meetingIds).orderBy('sortOrder').execute()
Expand Down
2 changes: 1 addition & 1 deletion packages/server/dataloader/primaryKeyLoaderMakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ export const meetingSettings = primaryKeyLoaderMaker((ids: readonly string[]) =>
return selectMeetingSettings().where('id', 'in', ids).execute()
})

export const _pgagendaItems = primaryKeyLoaderMaker((ids: readonly string[]) => {
export const agendaItems = primaryKeyLoaderMaker((ids: readonly string[]) => {
return selectAgendaItems().where('id', 'in', ids).execute()
})
27 changes: 0 additions & 27 deletions packages/server/dataloader/rethinkForeignKeyLoaderMakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,6 @@ export const activeMeetingsByTeamId = new RethinkForeignKeyLoaderMaker(
}
)

export const agendaItemsByTeamId = new RethinkForeignKeyLoaderMaker(
'agendaItems',
'teamId',
async (teamIds) => {
const r = await getRethink()
return r
.table('AgendaItem')
.getAll(r.args(teamIds), {index: 'teamId'})
.filter({isActive: true})
.orderBy('sortOrder')
.run()
}
)

export const agendaItemsByMeetingId = new RethinkForeignKeyLoaderMaker(
'agendaItems',
'meetingId',
async (meetingIds) => {
const r = await getRethink()
return r
.table('AgendaItem')
.getAll(r.args(meetingIds), {index: 'meetingId'})
.orderBy('sortOrder')
.run()
}
)

export const commentsByDiscussionId = new RethinkForeignKeyLoaderMaker(
'comments',
'discussionId',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import RethinkPrimaryKeyLoaderMaker from './RethinkPrimaryKeyLoaderMaker'
/**
* all rethink dataloader types which also must exist in {@link rethinkDriver/RethinkSchema}
*/
export const agendaItems = new RethinkPrimaryKeyLoaderMaker('AgendaItem')
export const comments = new RethinkPrimaryKeyLoaderMaker('Comment')
export const reflectPrompts = new RethinkPrimaryKeyLoaderMaker('ReflectPrompt')
export const massInvitations = new RethinkPrimaryKeyLoaderMaker('MassInvitation')
Expand Down
84 changes: 0 additions & 84 deletions packages/server/graphql/mutations/addAgendaItem.ts

This file was deleted.

Loading

0 comments on commit bd802d5

Please sign in to comment.