Skip to content

Commit

Permalink
chore(rethinkdb): SuggestedAction: Phase 3 (#10043)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <[email protected]>
Co-authored-by: Jordan Husney <[email protected]>
  • Loading branch information
mattkrick and jordanh authored Aug 5, 2024
1 parent 5829a11 commit 6c0cc36
Show file tree
Hide file tree
Showing 58 changed files with 805 additions and 1,576 deletions.
2 changes: 2 additions & 0 deletions codegen.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"Comment": "../../database/types/Comment#default as CommentDB",
"Company": "./types/Company#CompanySource",
"CreateGcalEventInput": "./types/CreateGcalEventInput#default",
"CreateGcalEventInput": "./types/CreateGcalEventInput#default",
"CreateImposterTokenPayload": "./types/CreateImposterTokenPayload#CreateImposterTokenPayloadSource",
"CreateStripeSubscriptionSuccess": "./types/CreateStripeSubscriptionSuccess#CreateStripeSubscriptionSuccessSource",
"CreateTaskPayload": "./types/CreateTaskPayload#CreateTaskPayloadSource",
Expand Down Expand Up @@ -117,6 +118,7 @@
"NotifyTeamArchived": "../../database/types/NotificationTeamArchived#default",
"Organization": "./types/Organization#OrganizationSource",
"TemplateScaleValue": "./types/TemplateScaleValue#TemplateScaleValueSource as TemplateScaleValueSourceDB",
"SuggestedAction": "../../postgres/types/index#SuggestedAction as SuggestedActionDB",
"TemplateScale": "../../postgres/types/index#TemplateScale as TemplateScaleDB",
"TemplateScaleRef": "../../postgres/types/index#TemplateScaleRef as TemplateScaleRefDB",
"Threadable": "./types/Threadable#ThreadableSource",
Expand Down
4 changes: 2 additions & 2 deletions packages/client/modules/demo/ClientGraphQLServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class ClientGraphQLServer extends (EventEmitter as GQLDemoEmitter) {
return {
viewer: {
...this.db.users[0],
newMeeting: {
meeting: {
...this.db.newMeeting,
reflectionGroups: (
this.db.newMeeting as {reflectionGroups: any[]}
Expand Down Expand Up @@ -301,7 +301,7 @@ class ClientGraphQLServer extends (EventEmitter as GQLDemoEmitter) {
return {
viewer: {
...this.db.users[0],
newMeeting: {
meeting: {
...this.db.newMeeting,
reflectionGroups: (
this.db.newMeeting as {reflectionGroups: any[]}
Expand Down
24 changes: 24 additions & 0 deletions packages/client/modules/demo/getDemoEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@ const query = graphql`
const getDemoEntities = async (text: string) => {
if (!text || text.length <= 2) return []
const remoteAtmosphere = new Atmosphere()

const TEST_REFLECTIONS = {
'Writing things down': [
{
lemma: 'thing',
name: 'things',
salience: 1
}
],
'Documenting things in Notion': [
{
lemma: 'thing',
name: 'things',
salience: 0.8
},
{
lemma: 'notion',
name: 'notion',
salience: 0.2
}
]
}
const cachedEntities = TEST_REFLECTIONS[text as keyof typeof TEST_REFLECTIONS]
if (cachedEntities) return cachedEntities
const res = await fetchQuery<getDemoEntitiesQuery>(remoteAtmosphere, query, {text}).toPromise()
return res?.getDemoEntities?.entities ?? []
}
Expand Down
8 changes: 2 additions & 6 deletions packages/client/modules/demo/handleCompletedDemoStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,8 @@ const addStageToBotScript = (stageId: string, db: RetroDemoDB, reflectionGroupId
delay: 1000,
variables
}
if (Math.random() > 0.1) {
ops.push({...baseOp, botId: 'bot1'})
}
if (Math.random() > 0.6) {
ops.push({...baseOp, botId: 'bot2'})
}
const botId = Math.random() > 0.5 ? 'bot1' : 'bot2'
ops.push({...baseOp, botId})
})
stageTasks.forEach((taskContent, idx) => {
const taskId = `botTask${stageId}:${idx}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MeetingSummaryEmail from './SummaryEmail/MeetingSummaryEmail/MeetingSumma
const query = graphql`
query MeetingSummaryEmailRootSSRQuery($meetingId: ID!) {
viewer {
newMeeting(meetingId: $meetingId) {
meeting(meetingId: $meetingId) {
meetingType
team {
id
Expand Down Expand Up @@ -42,9 +42,9 @@ const MeetingSummaryEmailRootSSR = (props: Props) => {
// viewer will be null on initial SSR render
if (!data?.viewer) return null
const {viewer} = data
const {newMeeting} = viewer
if (!newMeeting) return null
const {team} = newMeeting
const {meeting} = viewer
if (!meeting) return null
const {team} = meeting
const {id: teamId} = team
const options = {searchParams: meetingSummaryUrlParams}
const referrerUrl = makeAppURL(appOrigin, `new-summary/${meetingId}`, options)
Expand All @@ -53,7 +53,7 @@ const MeetingSummaryEmailRootSSR = (props: Props) => {
const emailCSVUrl = makeAppURL(appOrigin, `new-summary/${meetingId}/csv`, options)
return (
<MeetingSummaryEmail
meeting={newMeeting}
meeting={meeting}
referrer={'email'}
teamDashUrl={teamDashUrl}
meetingUrl={meetingUrl}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface Props extends WithMutationProps {
const query = graphql`
query ExportToCSVQuery($meetingId: ID!) {
viewer {
newMeeting(meetingId: $meetingId) {
meeting(meetingId: $meetingId) {
meetingType
team {
name
Expand Down Expand Up @@ -126,7 +126,7 @@ const query = graphql`
}
`

type Meeting = NonNullable<NonNullable<ExportToCSVQuery['response']['viewer']>['newMeeting']>
type Meeting = NonNullable<NonNullable<ExportToCSVQuery['response']['viewer']>['meeting']>
type ExportableTypeName = 'Task' | 'Reflection' | 'Comment' | 'Reply'

interface CSVPokerRow {
Expand Down Expand Up @@ -336,7 +336,7 @@ const ExportToCSV = (props: Props) => {
onCompleted()
if (!data) return
const {viewer} = data
const {newMeeting} = viewer
const {meeting: newMeeting} = viewer
if (!newMeeting) return
const rows = getRows(newMeeting)
if (rows.length === 0) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const query = graphql`
...DashTopBar_query
viewer {
...DashSidebar_viewer
newMeeting(meetingId: $meetingId) {
meeting(meetingId: $meetingId) {
...MeetingSummaryEmail_meeting
...MeetingLockedOverlay_meeting
id
Expand All @@ -49,7 +49,7 @@ const NewMeetingSummary = (props: Props) => {
const {urlAction, queryRef} = props
const data = usePreloadedQuery<NewMeetingSummaryQuery>(query, queryRef)
const {viewer} = data
const {newMeeting, teams} = viewer
const {meeting: newMeeting, teams} = viewer
const activeMeetings = teams.flatMap((team) => team.activeMeetings).filter(Boolean)
const {history} = useRouter()
useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ test.describe('retrospective-demo / group page', () => {

// Then it auto-generates a header
await expect(
page.locator(
`[data-cy=group-column-Start] [data-cy*="Start-group-"] input[value="Documenting things in"]`
)
page.locator(`[data-cy=group-column-Start] [data-cy*="Start-group-"] input[value="Things"]`)
).toBeVisible()

// Then it shows all cards when clicking the group
Expand Down Expand Up @@ -106,7 +104,9 @@ test.describe('retrospective-demo / group page', () => {
await page.type(stopTextbox, 'Making decisions in one-on-one meetings')
await page.press(stopTextbox, 'Enter')
await expect(
page.locator('[data-cy="reflection-column-Stop"] :text("Making decisions in one-on-one meetings")')
page.locator(
'[data-cy="reflection-column-Stop"] :text("Making decisions in one-on-one meetings")'
)
).toBeVisible()

await goToNextPhase(page)
Expand All @@ -119,7 +119,7 @@ test.describe('retrospective-demo / group page', () => {
// Then it auto-generates a header
await expect(
page.locator(
`[data-cy=group-column-Start] [data-cy*="Start-group-"] input[value="Documenting things in"]`
`[data-cy=group-column-Start] [data-cy*="Start-group-"] input[value="Things Notion"]`
)
).toBeVisible()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ test.describe('retrospective-demo / discuss page', () => {

// Then it auto-generates a header - we expect to see this in the sidebar on the discuss page
await expect(
page.locator(
`[data-cy=group-column-Start] [data-cy*="Start-group-"] input[value="Documenting things in"]`
)
page.locator(`[data-cy=group-column-Start] [data-cy*="Start-group-"] input[value="Things"]`)
).toBeVisible()

await goToNextPhase(page)
Expand All @@ -48,7 +46,7 @@ test.describe('retrospective-demo / discuss page', () => {
await page.click('button[aria-label="Toggle the sidebar"]')
}

await expect(page.locator('[data-cy=sidebar] :text("Documenting things in")')).toBeVisible()
await expect(page.locator('[data-cy=sidebar] :text("Things")')).toBeVisible()
})

test('shows all the groups in the sidebar', async ({page, isMobile}) => {
Expand Down
9 changes: 0 additions & 9 deletions packages/server/database/rethinkDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import NotificationTeamInvitation from './types/NotificationTeamInvitation'
import PasswordResetRequest from './types/PasswordResetRequest'
import PushInvitation from './types/PushInvitation'
import RetrospectivePrompt from './types/RetrospectivePrompt'
import SuggestedActionCreateNewTeam from './types/SuggestedActionCreateNewTeam'
import SuggestedActionInviteYourTeam from './types/SuggestedActionInviteYourTeam'
import SuggestedActionTryTheDemo from './types/SuggestedActionTryTheDemo'
import Task from './types/Task'

export type RethinkSchema = {
Expand Down Expand Up @@ -127,12 +124,6 @@ export type RethinkSchema = {
type: SlackNotification
index: 'teamId' | 'userId'
}
SuggestedAction: {
// tryRetroMeeting = 'tryRetroMeeting',
// tryActionMeeting = 'tryActionMeeting'
type: SuggestedActionCreateNewTeam | SuggestedActionInviteYourTeam | SuggestedActionTryTheDemo
index: 'userId' | 'teamId'
}
Task: {
type: Task
index:
Expand Down
30 changes: 0 additions & 30 deletions packages/server/database/types/SuggestedAction.ts

This file was deleted.

13 changes: 0 additions & 13 deletions packages/server/database/types/SuggestedActionCreateNewTeam.ts

This file was deleted.

17 changes: 0 additions & 17 deletions packages/server/database/types/SuggestedActionInviteYourTeam.ts

This file was deleted.

13 changes: 0 additions & 13 deletions packages/server/database/types/SuggestedActionTryTheDemo.ts

This file was deleted.

6 changes: 3 additions & 3 deletions packages/server/dataloader/customLoaderMakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export interface ReactablesKey {

export interface UserTasksKey {
first: number
after?: Date
after?: Date | null
userIds: string[]
teamIds: string[]
archived?: boolean
statusFilters: TaskStatusEnum[]
filterQuery?: string
statusFilters?: TaskStatusEnum[] | null
filterQuery?: string | null
includeUnassigned?: boolean
}

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

export const _suggestedActionsByUserId = foreignKeyLoaderMaker(
'_suggestedActions',
export const suggestedActionsByUserId = foreignKeyLoaderMaker(
'suggestedActions',
'userId',
async (userIds) => {
return selectSuggestedAction().where('userId', 'in', userIds).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 @@ -167,6 +167,6 @@ export const templateDimensions = primaryKeyLoaderMaker((ids: readonly string[])
return selectTemplateDimension().where('id', 'in', ids).execute()
})

export const _suggestedActions = primaryKeyLoaderMaker((ids: readonly string[]) => {
export const suggestedActions = primaryKeyLoaderMaker((ids: readonly string[]) => {
return selectSuggestedAction().where('id', 'in', ids).execute()
})
13 changes: 0 additions & 13 deletions packages/server/dataloader/rethinkForeignKeyLoaderMakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,6 @@ export const slackNotificationsByTeamId = new RethinkForeignKeyLoaderMaker(
}
)

export const suggestedActionsByUserId = new RethinkForeignKeyLoaderMaker(
'suggestedActions',
'userId',
async (userIds) => {
const r = await getRethink()
return r
.table('SuggestedAction')
.getAll(r.args(userIds), {index: 'userId'})
.filter((row: any) => row('removedAt').default(null).eq(null))
.run()
}
)

export const tasksByDiscussionId = new RethinkForeignKeyLoaderMaker(
'tasks',
'discussionId',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ export const newFeatures = new RethinkPrimaryKeyLoaderMaker('NewFeature')
export const notifications = new RethinkPrimaryKeyLoaderMaker('Notification')
export const slackAuths = new RethinkPrimaryKeyLoaderMaker('SlackAuth')
export const slackNotifications = new RethinkPrimaryKeyLoaderMaker('SlackNotification')
export const suggestedActions = new RethinkPrimaryKeyLoaderMaker('SuggestedAction')
export const tasks = new RethinkPrimaryKeyLoaderMaker('Task')
export const teamInvitations = new RethinkPrimaryKeyLoaderMaker('TeamInvitation')
3 changes: 0 additions & 3 deletions packages/server/graphql/mutations/dismissSuggestedAction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {GraphQLID, GraphQLNonNull} from 'graphql'
import getRethink from '../../database/rethinkDriver'
import getKysely from '../../postgres/getKysely'
import {getUserId} from '../../utils/authorization'
import standardError from '../../utils/standardError'
Expand All @@ -20,7 +19,6 @@ export default {
{suggestedActionId}: {suggestedActionId: string},
{authToken, dataLoader}: GQLContext
) => {
const r = await getRethink()
const now = new Date()
const viewerId = getUserId(authToken)

Expand All @@ -40,7 +38,6 @@ export default {
.set({removedAt: now})
.where('id', '=', suggestedActionId)
.execute()
await r.table('SuggestedAction').get(suggestedActionId).update({removedAt: now}).run()

// no need to publish since that'll only affect their other open tabs
return {
Expand Down
Loading

0 comments on commit 6c0cc36

Please sign in to comment.