Skip to content

Commit

Permalink
dumili,dumili-api: Fix issue suggestion creation
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Jan 25, 2025
1 parent 9ecdaaa commit 9fe1c4a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion apps/dumili/api/services/indexation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ const listenEvents = (services: IndexationServices) => {
suggestion: Omit<
Prisma.issueSuggestionUncheckedCreateInput,
"indexationId"
> & { ai: boolean },
>,
) =>
prisma.issueSuggestion
.create({
Expand Down
14 changes: 8 additions & 6 deletions apps/dumili/src/components/suggestions/IssueSuggestionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
><template #unknown-text>{{ $t("Numéro inconnu") }}</template>
<template #customize-form>
<issue-select
@change="$event && createAndAcceptIssueSuggestion($event)" /></template
@change="
$event &&
createAndAcceptIssueSuggestion({
publicationcode: $event.publicationcode,
issuenumber: $event.issuenumber,
})
" /></template
><template #customize-text> {{ $t("Sélectionner...") }}</template>
</suggestion-list>
</template>
Expand All @@ -32,7 +38,6 @@ const { indexationSocket } = inject(dumiliSocketInjectionKey)!;
const createAndAcceptIssueSuggestion = async (data: {
publicationcode: string;
issuenumber: string;
issuecode: string;
}) => {
if (
!indexation.value?.issueSuggestions.some(
Expand All @@ -41,10 +46,7 @@ const createAndAcceptIssueSuggestion = async (data: {
issuenumber === data.issuenumber,
)
) {
await createIssueSuggestion({
...data,
ai: false,
});
await createIssueSuggestion(data);
}
nextTick(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const acceptIssueSuggestion = async (issuecode: string) => {
const { suggestionId } = await createIssueSuggestion({
publicationcode,
issuenumber,
ai: true,
});
await indexationSocket.value!.acceptIssueSuggestion(suggestionId);
selectedExistingCoverIssuecode.value = undefined;
Expand Down
7 changes: 3 additions & 4 deletions apps/dumili/src/composables/useHint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ export default () => {
}
await Promise.all(
results.covers.map(({ issuecode }) =>
indexationSocket.value!.createIssueSuggestion({
ai: true,
...issuecodeDetails.value[issuecode]!,
}),
indexationSocket.value!.createIssueSuggestion(
issuecodeDetails.value[issuecode]!,
),
),
);

Expand Down
4 changes: 1 addition & 3 deletions apps/dumili/src/stores/suggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ export const suggestions = defineStore("suggestions", () => {
};

const createIssueSuggestion = async (
suggestion: Pick<issueSuggestion, "publicationcode" | "issuenumber"> & {
ai: boolean;
},
suggestion: Pick<issueSuggestion, "publicationcode" | "issuenumber">,
) => indexationSocket.value!.createIssueSuggestion(suggestion);

const acceptedIssue = computed({
Expand Down

0 comments on commit 9fe1c4a

Please sign in to comment.