Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rethinkdb): SuggestedAction: Phase 3 #10043

Merged
merged 19 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove duplicate entry for CreateGcalEventInput.

The entry for CreateGcalEventInput is duplicated, which can cause confusion and potential errors in the code generation process.

- "CreateGcalEventInput": "./types/CreateGcalEventInput#default",

Committable suggestion was skipped due to low confidence.

"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
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
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
14 changes: 3 additions & 11 deletions packages/server/graphql/mutations/helpers/bootstrapNewUser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import getRethink from '../../../database/rethinkDriver'
import AuthToken from '../../../database/types/AuthToken'
import TimelineEventJoinedParabol from '../../../database/types/TimelineEventJoinedParabol'
import User from '../../../database/types/User'
Expand All @@ -21,7 +20,6 @@ const bootstrapNewUser = async (
isOrganic: boolean,
dataLoader: DataLoaderWorker
) => {
const r = await getRethink()
const {
id: userId,
createdAt,
Expand Down Expand Up @@ -115,14 +113,9 @@ const bootstrapNewUser = async (
return Promise.all([
acceptTeamInvitation(team, userId, dataLoader),
isOrganic
? Promise.all([
pg.insertInto('SuggestedAction').values(inviteYourTeam).execute(),
r.table('SuggestedAction').insert(inviteYourTeam).run()
])
: Promise.all([
pg.insertInto('SuggestedAction').values(actions).execute(),
r.table('SuggestedAction').insert(actions).run()
]),
? pg.insertInto('SuggestedAction').values(inviteYourTeam).execute()
: pg.insertInto('SuggestedAction').values(actions).execute(),
,
analytics.autoJoined(newUser, teamId)
])
})
Expand All @@ -147,7 +140,6 @@ const bootstrapNewUser = async (
analytics.newOrg(newUser, orgId, teamId, true)
} else {
await pg.insertInto('SuggestedAction').values(actions).execute()
await r.table('SuggestedAction').insert(actions).run()
}

analytics.accountCreated(newUser, !isOrganic, isPatient0)
Expand Down
10 changes: 0 additions & 10 deletions packages/server/graphql/mutations/helpers/createTeamAndLeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,5 @@ export default async function createTeamAndLeader(
// add meeting settings
r.table('MeetingSettings').insert(meetingSettings).run()
])
const hasSuggestedAction = await r
.table('SuggestedAction')
.getAll(userId, {index: 'userId'})
.filter({type: 'inviteYourTeam'})
.count()
.ge(1)
.run()
if (!hasSuggestedAction) {
await r.table('SuggestedAction').insert(suggestedAction).run()
}
dataLoader.clearAll(['teams', 'users', 'teamMembers', 'timelineEvents', 'meetingSettings'])
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface SuggestedAction {
"""
* The timestamp the action was removed at
"""
removedAt: DateTime!
removedAt: DateTime

"""
The specific type of suggested action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type SuggestedActionCreateNewTeam implements SuggestedAction {
"""
* The timestamp the action was removed at
"""
removedAt: DateTime!
removedAt: DateTime

"""
The specific type of suggested action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type SuggestedActionInviteYourTeam implements SuggestedAction {
"""
* The timestamp the action was removed at
"""
removedAt: DateTime!
removedAt: DateTime

"""
The specific type of suggested action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type SuggestedActionTryActionMeeting implements SuggestedAction {
"""
* The timestamp the action was removed at
"""
removedAt: DateTime!
removedAt: DateTime

"""
The specific type of suggested action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type SuggestedActionTryRetroMeeting implements SuggestedAction {
"""
* The timestamp the action was removed at
"""
removedAt: DateTime!
removedAt: DateTime

"""
The specific type of suggested action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type SuggestedActionTryTheDemo implements SuggestedAction {
"""
* The timestamp the action was removed at
"""
removedAt: DateTime!
removedAt: DateTime

"""
The specific type of suggested action
Expand Down
Loading
Loading