Skip to content

Commit be2e2e0

Browse files
committed
Fix Sentry DSN loading on frontends
Fix Bootstrap tabs v-model dumili: Properly remove suggestions from previous OCR and sstory search results dumili: WIP show story search results in tooltip
1 parent 506be84 commit be2e2e0

File tree

10 files changed

+140
-71
lines changed

10 files changed

+140
-71
lines changed

apps/duckguessr/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ const app = createApp(App)
4141

4242
app.mount("#app");
4343

44-
if (process.env.SENTRY_DSN) {
44+
if (import.meta.env.VITE_SENTRY_DSN) {
4545
Sentry.init({
4646
app,
47-
dsn: "https://[email protected]/1385898",
47+
dsn: import.meta.env.VITE_SENTRY_DSN,
4848
integrations: [
4949
Sentry.browserTracingIntegration({ router }),
5050
Sentry.replayIntegration(),

apps/dumili/.eslintrc-auto-import.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"IssueWithPublicationcodeOptionalId": true,
3737
"MaybeRef": true,
3838
"MaybeRefOrGetter": true,
39+
"MedalLevels": true,
3940
"MedalPointsPerUser": true,
4041
"ModelSteps": true,
4142
"PropType": true,

apps/dumili/api/prisma/schema.prisma

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ model aiStorySuggestion {
207207
id Int @id @default(autoincrement())
208208
ocrPossibleStoryId Int? @unique(map: "ai_ocr_possible_story_id_unique") @map("ocr_possible_story_id")
209209
storySearchPossibleStoryId Int? @unique(map: "ai_story_search_possible_story_id_unique") @map("story_search_possible_story_id")
210-
aiOcrPossibleStory aiOcrPossibleStory? @relation(fields: [ocrPossibleStoryId], references: [id], onDelete: Restrict, onUpdate: Restrict, map: "ai_story_suggestion_ai_ocr_possible_story_id_fk")
211-
aiStorySearchPossibleStory aiStorySearchPossibleStory? @relation(fields: [storySearchPossibleStoryId], references: [id], onDelete: Restrict, onUpdate: Restrict, map: "ai_story_suggestion_ai_story_search_possible_story_id_fk")
210+
aiOcrPossibleStory aiOcrPossibleStory? @relation(fields: [ocrPossibleStoryId], references: [id], onDelete: Cascade, onUpdate: Restrict, map: "ai_story_suggestion_ai_ocr_possible_story_id_fk")
211+
aiStorySearchPossibleStory aiStorySearchPossibleStory? @relation(fields: [storySearchPossibleStoryId], references: [id], onDelete: Cascade, onUpdate: Restrict, map: "ai_story_suggestion_ai_story_search_possible_story_id_fk")
212212
storySuggestions storySuggestion[]
213213
214214
@@map("ai_story_suggestion")

apps/dumili/api/services/indexation/index.ts

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,30 +237,69 @@ const createAiStorySuggestions = async (
237237
if ("error" in results) {
238238
console.error(results.error);
239239
} else {
240-
const newAiResultId =
240+
let aiResultId =
241241
(
242242
await prisma.image.findUnique({
243243
where: {
244244
id: firstPageOfEntry.image.id,
245245
},
246246
})
247-
)?.[`${field}Id`] ??
248-
(
249-
await (
250-
prisma[field] as unknown as {
251-
create: typeof prisma.aiOcrResult.create;
252-
}
253-
).create({
254-
data: {},
255-
})
256-
).id;
247+
)?.[`${field}Id`];
248+
249+
if (aiResultId) {
250+
if (field === "aiOcrResult") {
251+
await prisma.storySuggestion.deleteMany({
252+
where: {
253+
aiStorySuggestion: {
254+
aiOcrPossibleStory: {
255+
resultId: aiResultId,
256+
},
257+
},
258+
},
259+
});
260+
await prisma.aiOcrPossibleStory.deleteMany({
261+
where: {
262+
resultId: aiResultId,
263+
},
264+
});
265+
} else {
266+
await prisma.storySuggestion.deleteMany({
267+
where: {
268+
aiStorySuggestion: {
269+
aiStorySearchPossibleStory: {
270+
resultId: aiResultId,
271+
},
272+
},
273+
},
274+
});
275+
await prisma.aiStorySearchPossibleStory.deleteMany({
276+
where: {
277+
resultId: aiResultId,
278+
},
279+
});
280+
}
281+
} else {
282+
if (field === "aiOcrResult") {
283+
aiResultId = (
284+
await prisma.aiOcrResult.create({
285+
data: {},
286+
})
287+
).id;
288+
} else {
289+
aiResultId = (
290+
await prisma.aiStorySearchResult.create({
291+
data: {},
292+
})
293+
).id;
294+
}
295+
}
257296

258297
await prisma.image.update({
259298
where: {
260299
id: firstPageOfEntry.image.id,
261300
},
262301
data: {
263-
[`${field}Id`]: newAiResultId,
302+
[`${field}Id`]: aiResultId,
264303
},
265304
});
266305
if (!results.stories.length) {
@@ -294,7 +333,7 @@ const createAiStorySuggestions = async (
294333
[field]: {
295334
// aiOcrResult or aiStorySearchResult
296335
connect: {
297-
id: newAiResultId,
336+
id: aiResultId,
298337
},
299338
},
300339
score: story.score,

apps/dumili/src/components/suggestions/StorySuggestionsTooltip.vue

Lines changed: 67 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -44,53 +44,44 @@
4444
show-empty
4545
:empty-text="$t('Aucun texte détecté')"
4646
/>
47-
<h4>{{ $t("Histoires potentielles") }}</h4>
48-
<template v-if="firstPageStorySearchResult">
49-
<b-table
50-
:fields="[
51-
{ key: 'storycode', label: $t('Code histoire') },
52-
{ key: 'title', label: $t('Titre') },
53-
]"
54-
show-empty
55-
:empty-text="$t('Aucune histoire trouvée')"
56-
:items="
57-
firstPageStorySearchResult.stories
58-
.filter(
59-
(
60-
possibleStory
61-
): possibleStory is typeof possibleStory & {
62-
aiStorySuggestion: {
63-
storySuggestion: { storycode: string };
64-
};
65-
} => !!possibleStory.aiStorySuggestion?.storySuggestion
66-
)
67-
.map(
68-
({
69-
aiStorySuggestion: {
70-
storySuggestion: { storycode },
71-
},
72-
}) => ({
73-
storycode,
74-
title: storyDetails[storycode].title,
75-
})
76-
)
77-
"
78-
>
79-
<template #cell(storycode)="row">
80-
<a
81-
class="text-nowrap"
82-
:href="`https://inducks.org/story.php?c=${encodeURIComponent(row.item.storycode)}`"
83-
target="_blank"
84-
>{{ row.item.storycode }}</a
85-
></template
86-
></b-table
87-
></template
88-
><template v-else>{{ $t("Non calculé") }}</template></template
89-
>
90-
<template v-else-if="!firstPage.image">{{
47+
</template>
48+
<template v-if="firstPageStorySearchResult">
49+
<h4>{{ $t("Résultats de la recherche par image") }}</h4>
50+
<b-table
51+
:fields="[
52+
{ key: 'storycode', label: $t('Code histoire') },
53+
{ key: 'title', label: $t('Titre') },
54+
]"
55+
show-empty
56+
:empty-text="$t('Aucune histoire trouvée')"
57+
:items="suggestedStories"
58+
>
59+
<template #cell(storycode)="row">
60+
<a
61+
class="text-nowrap"
62+
:href="`https://inducks.org/story.php?c=${encodeURIComponent(row.item!.storycode)}`"
63+
target="_blank"
64+
>{{ row.item!.storycode }}</a
65+
></template
66+
><template #cell(title)="row">
67+
{{ storyDetails[row.item!.storycode].title }}
68+
<b-col
69+
cols="6"
70+
class="d-flex justify-content-center story-first-page"
71+
:style="{
72+
backgroundImage: `url(${inducksCoverRoot.replace('f_auto', 'c_crop,h_0.5,x_0,w_1') + storyUrls[row.item!.storycode]})`,
73+
}"
74+
>
75+
</b-col>
76+
</template> </b-table
77+
></template>
78+
<template v-if="!firstPage.image">{{
9179
$t("Non calculé car la première page de l'entrée n'a pas d'image")
9280
}}</template>
93-
<template v-else>{{ $t("Non calculé") }}</template></template
81+
<template
82+
v-else-if="!firstPageOcrResult && !firstPageStorySearchResult"
83+
>{{ $t("Non calculé") }}</template
84+
></template
9485
><template v-else>{{
9586
$t(
9687
"Aucune suggestion car cette entrée n'est pas une histoire ni une couverture.",
@@ -110,7 +101,8 @@ const { entry } = defineProps<{
110101
}>();
111102
112103
const { indexation } = storeToRefs(suggestions());
113-
const { storyDetails } = storeToRefs(coa());
104+
const { storyUrls, storyDetails } = storeToRefs(coa());
105+
const { fetchStoryDetails } = coa();
114106
115107
const { overlay } = storeToRefs(ui());
116108
@@ -120,4 +112,33 @@ const firstPageOcrResult = computed(() => firstPage.value.image?.aiOcrResult);
120112
const firstPageStorySearchResult = computed(
121113
() => firstPage.value.image?.aiStorySearchResult,
122114
);
115+
116+
const inducksCoverRoot = `https://res.cloudinary.com/${import.meta.env.VITE_CLOUDINARY_CLOUDNAME}/image/upload/f_auto/inducks-covers/`;
117+
118+
const suggestedStories = computed(() =>
119+
firstPageStorySearchResult.value?.stories
120+
.map((possibleStory) =>
121+
entry.storySuggestions.find(
122+
({ aiStorySuggestionId }) =>
123+
aiStorySuggestionId === possibleStory.aiStorySuggestion?.id,
124+
),
125+
)
126+
.filter(
127+
(
128+
possibleStory,
129+
): possibleStory is typeof possibleStory & { storycode: string } =>
130+
!!possibleStory,
131+
),
132+
);
133+
134+
watch(
135+
suggestedStories,
136+
(value) => {
137+
const storycodes = value?.map(({ storycode }) => storycode);
138+
if (storycodes) {
139+
fetchStoryDetails(storycodes);
140+
}
141+
},
142+
{ immediate: true },
143+
);
123144
</script>

apps/dumili/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const app = createApp(App)
4949

5050
app.mount("#app");
5151

52-
if (process.env.SENTRY_DSN) {
52+
if (import.meta.env.VITE_SENTRY_DSN) {
5353
Sentry.init({
5454
app,
5555
dsn: process.env.VITE_SENTRY_DSN,

apps/dumili/src/pages/indexation/[id].vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</b-col>
1414
<TextEditor v-else-if="activeTabIndex === 2" />
1515
<b-container class="start-0 bottom-0 mw-100 pt-2" style="height: 35px"
16-
><b-tabs v-model="activeTabIndex" tabs align="center"
16+
><b-tabs v-model:index="activeTabIndex" tabs align="center"
1717
><b-tab
1818
v-for="{ id, label } of tabNames"
1919
:key="id"
@@ -111,8 +111,10 @@ watch(
111111
{ immediate: true },
112112
);
113113
114-
watch(activeTabIndex, (activeTabIndex) => {
115-
router.push(`#${tabNames[activeTabIndex].id}`);
114+
watch(activeTabIndex, (value) => {
115+
if (tabNames[value]) {
116+
router.push(`#${tabNames[value].id}`);
117+
}
116118
});
117119
</script>
118120

apps/edgecreator/src/components/ModelEdit.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<b-card id="edit-card" no-body>
33
<b-tabs
4-
v-model="editingStepStore.stepNumber"
4+
v-model:index="editingStepStore.stepNumber"
55
lazy
66
pills
77
card

apps/web/src/components/BookcaseBook.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@
5353
<h6 v-if="releaseDate">{{ $t("Sortie :") }} {{ releaseDate }}</h6>
5454
<h3>{{ $t("Table des matières") }}</h3>
5555
</template>
56-
<b-tabs v-if="entries" v-model="currentTabIndex" pills card vertical>
56+
<b-tabs
57+
v-if="entries"
58+
v-model:index="currentTabIndex"
59+
pills
60+
card
61+
vertical
62+
>
5763
<b-tab
5864
v-for="{
5965
storycode,

apps/web/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const app = createApp(App)
4848

4949
app.mount("#app");
5050

51-
if (import.meta.env.SENTRY_DSN) {
51+
if (import.meta.env.VITE_SENTRY_DSN) {
5252
Sentry.init({
5353
integrations: [
5454
Sentry.vueIntegration({
@@ -60,7 +60,7 @@ if (import.meta.env.SENTRY_DSN) {
6060
}),
6161
],
6262
app,
63-
dsn: "https://[email protected]/1385898",
63+
dsn: import.meta.env.VITE_SENTRY_DSN,
6464
tracesSampleRate: 1.0,
6565
});
6666
}

0 commit comments

Comments
 (0)