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: drop sourceLang, targetLang and id columns #17792

Draft
wants to merge 70 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
891f67a
feat: AI description - DB model + frontend + backend (fetch only)
hbjORbj Nov 14, 2024
805bbe4
fix types and add validation to backend
hbjORbj Nov 15, 2024
f932ffb
improve log
hbjORbj Nov 15, 2024
a253bef
improve
hbjORbj Nov 15, 2024
40cfd93
import type
hbjORbj Nov 15, 2024
0409d2c
add EventTypeTranslationRepository
hbjORbj Nov 15, 2024
b0011fc
fix replexica error
hbjORbj Nov 15, 2024
0d2b1d9
fix replexica error
hbjORbj Nov 15, 2024
ddeb075
fix
hbjORbj Nov 15, 2024
e7bbb6a
fix test
hbjORbj Nov 15, 2024
6acc067
wip
hbjORbj Nov 15, 2024
239fbfe
Merge branch 'feat/i18n-description-1' into feat/i18n-description-2
hbjORbj Nov 15, 2024
664d42b
wip
hbjORbj Nov 15, 2024
c91bb94
add createManyDescriptionTranslations method
hbjORbj Nov 15, 2024
4b609b6
improve logic
hbjORbj Nov 15, 2024
4f46d6e
refactor
hbjORbj Nov 15, 2024
1fa31d0
fix merge conflict
hbjORbj Nov 15, 2024
5fdc738
Merge branch 'feat/i18n-description-1' into feat/i18n-description-2
hbjORbj Nov 15, 2024
5d36de4
update replexica type
hbjORbj Nov 15, 2024
39e4995
Merge branch 'feat/i18n-description-1' into feat/i18n-description-2
hbjORbj Nov 15, 2024
c88dbe0
improve typing
hbjORbj Nov 15, 2024
d6ba7ff
Renamed descriptionTranslations to fieldTranslations
keithwillcode Nov 15, 2024
bbb1202
Merge remote-tracking branch 'origin/main' into feat/i18n-description-1
hbjORbj Nov 16, 2024
c8ac86c
Merge branch 'feat/i18n-description-1' into feat/i18n-description-2
hbjORbj Nov 16, 2024
4a5a4bb
log errors in replexica service
hbjORbj Nov 16, 2024
7db2cb5
handle translations in background
hbjORbj Nov 16, 2024
5ba3198
don't create, upsert instead
hbjORbj Nov 17, 2024
88c82b6
make sure that description is updated
hbjORbj Nov 17, 2024
56c1596
simplify
hbjORbj Nov 17, 2024
5df55d8
fix
hbjORbj Nov 17, 2024
ff2e495
Update packages/trpc/server/routers/viewer/eventTypes/update.handler.ts
keithwillcode Nov 18, 2024
f9d925f
Merge remote-tracking branch 'origin/main' into feat/i18n-description-2
hbjORbj Nov 19, 2024
d062e4b
improve filter logic in frontend
hbjORbj Nov 19, 2024
5d8f1da
implement background job using Tasker
hbjORbj Nov 19, 2024
fc66b63
update schema
hbjORbj Nov 19, 2024
931f113
update schema again
hbjORbj Nov 19, 2024
4ef0bc6
rename
hbjORbj Nov 19, 2024
681d0ed
rename id to uid
hbjORbj Nov 19, 2024
6b5f3d5
add migration
hbjORbj Nov 19, 2024
77791d5
fix type
hbjORbj Nov 19, 2024
36c89f3
update
hbjORbj Nov 19, 2024
0f742de
update schema and migration sql
hbjORbj Nov 20, 2024
696e0f9
fix migration
hbjORbj Nov 20, 2024
74f6357
fix type check
hbjORbj Nov 20, 2024
7713f26
fix type check 2
hbjORbj Nov 20, 2024
e4d5cda
improve find logic in EventMeta
hbjORbj Nov 20, 2024
2959532
add more validation
hbjORbj Nov 20, 2024
02248ff
add logger
hbjORbj Nov 20, 2024
e567b22
rename
hbjORbj Nov 20, 2024
d80b8b3
upgrade replexica/sdk to 0.7.0
hbjORbj Nov 20, 2024
4ab441a
upgrade replexica to 0.7.0
hbjORbj Nov 20, 2024
a1dc799
use batchLocalizeText
hbjORbj Nov 20, 2024
2f2b19f
add comments
hbjORbj Nov 20, 2024
b5cb6dc
Merge remote-tracking branch 'origin/main' into feat/i18n-description-2
hbjORbj Nov 20, 2024
c84c947
override browser locale if user is a signed in calcom user
hbjORbj Nov 20, 2024
2ecae32
fix type in replexica
hbjORbj Nov 20, 2024
e8e68e3
fix migration sql
hbjORbj Nov 20, 2024
e8b6e89
fix type
hbjORbj Nov 20, 2024
4c48f81
use dynamic import
hbjORbj Nov 20, 2024
b29eacf
do not use batchLocalizeText
hbjORbj Nov 20, 2024
7dcbd5f
chore: drop sourceLang, targetLang and id columns
hbjORbj Nov 22, 2024
8bcaf5f
fix
hbjORbj Nov 22, 2024
01baae3
Merge remote-tracking branch 'origin/main' into feat/i18n-description-2
hbjORbj Nov 22, 2024
ebb7a81
Merge branch 'feat/i18n-description-2' into chore/update-event-type-t…
hbjORbj Nov 22, 2024
fa8eef6
add more validations
hbjORbj Nov 22, 2024
9d0e964
fix type error
hbjORbj Nov 22, 2024
0470cf5
address comment
hbjORbj Nov 22, 2024
afa4eb0
Merge branch 'feat/i18n-description-2' into chore/update-event-type-t…
hbjORbj Nov 22, 2024
2c53756
Merge remote-tracking branch 'origin/main' into chore/update-event-ty…
hbjORbj Nov 25, 2024
770ab65
Merge branch 'main' into chore/update-event-type-trans-schema
hbjORbj Nov 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ export async function translateEventTypeDescription(payload: string): Promise<vo
eventTypeId,
sourceLocale: userLocale,
targetLocale,
// Keep old fields during transition
sourceLang: userLocale, // TODO: remove after migration
targetLang: targetLocale, // TODO: remove after migration
translatedText,
userId,
}))
Expand Down
24 changes: 7 additions & 17 deletions packages/lib/server/repository/eventTypeTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { EventTypeAutoTranslatedField } from "@calcom/prisma/enums";

export type CreateEventTypeDescriptionTranslation = Omit<
EventTypeTranslation,
| "id" // TODO: remove after migration
| "uid"
| "createdAt"
| "createdBy"
Expand All @@ -20,23 +19,14 @@ export class EventTypeTranslationRepository {
static async upsertManyDescriptionTranslations(translations: Array<CreateEventTypeDescriptionTranslation>) {
return await Promise.all(
translations.map(({ userId, ...translation }) => {
const whereClause = translation.targetLang // TODO: remove after migration
? {
eventTypeId_field_targetLang: {
eventTypeId: translation.eventTypeId,
field: EventTypeAutoTranslatedField.DESCRIPTION,
targetLang: translation.targetLang,
},
}
: {
eventTypeId_field_targetLocale: {
eventTypeId: translation.eventTypeId,
field: EventTypeAutoTranslatedField.DESCRIPTION,
targetLocale: translation.targetLocale,
},
};
return prisma.eventTypeTranslation.upsert({
where: whereClause,
where: {
eventTypeId_field_targetLocale: {
eventTypeId: translation.eventTypeId,
field: EventTypeAutoTranslatedField.DESCRIPTION,
targetLocale: translation.targetLocale,
},
},
update: {
translatedText: translation.translatedText,
updatedBy: userId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Warnings:

- The primary key for the `EventTypeTranslation` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `EventTypeTranslation` table. All the data in the column will be lost.
- You are about to drop the column `sourceLang` on the `EventTypeTranslation` table. All the data in the column will be lost.
- You are about to drop the column `targetLang` on the `EventTypeTranslation` table. All the data in the column will be lost.
- Made the column `uid` on table `EventTypeTranslation` required. This step will fail if there are existing NULL values in that column.

*/
-- DropIndex
DROP INDEX "EventTypeTranslation_eventTypeId_field_targetLang_idx";

-- DropIndex
DROP INDEX "EventTypeTranslation_eventTypeId_field_targetLang_key";

-- AlterTable
ALTER TABLE "EventTypeTranslation" DROP CONSTRAINT "EventTypeTranslation_pkey",
DROP COLUMN "id",
DROP COLUMN "sourceLang",
DROP COLUMN "targetLang",
ALTER COLUMN "uid" SET NOT NULL,
ADD CONSTRAINT "EventTypeTranslation_pkey" PRIMARY KEY ("uid");
7 changes: 1 addition & 6 deletions packages/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -1633,13 +1633,10 @@ enum EventTypeAutoTranslatedField {
}

model EventTypeTranslation {
id String @id @default(cuid())
uid String?
uid String @id @default(cuid())
eventType EventType @relation(fields: [eventTypeId], references: [id], onDelete: Cascade)
eventTypeId Int
field EventTypeAutoTranslatedField
sourceLang String
targetLang String
sourceLocale String
targetLocale String
translatedText String @db.Text
Expand All @@ -1650,8 +1647,6 @@ model EventTypeTranslation {
creator User @relation("CreatedEventTypeTranslations", fields: [createdBy], references: [id])
updater User? @relation("UpdatedEventTypeTranslations", fields: [updatedBy], references: [id], onDelete: SetNull)

@@unique([eventTypeId, field, targetLang]) // TODO: remove after migration
@@unique([eventTypeId, field, targetLocale])
@@index([eventTypeId, field, targetLang]) // TODO: remove after migration
@@index([eventTypeId, field, targetLocale])
}
Loading