-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pageversionとsourceTextsの関係を修正 pageversionが違ってもnumberと内容が同じなら同一と判定 ジョブ…
…のバージョンシステムの導入 (#143)
- Loading branch information
Showing
16 changed files
with
235 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { createHash } from "node:crypto"; | ||
import { prisma } from "~/utils/prisma"; | ||
|
||
export async function getOrCreateSourceTextIdAndPageVersionSourceText( | ||
text: string, | ||
number: number, | ||
pageVersionId: number, | ||
): Promise<number> { | ||
const textHash = Buffer.from( | ||
createHash("sha256").update(text).digest("hex"), | ||
"hex", | ||
); | ||
|
||
return prisma.$transaction(async (tx) => { | ||
const sourceText = await tx.sourceText.upsert({ | ||
where: { | ||
textHash_number: { | ||
textHash, | ||
number, | ||
}, | ||
}, | ||
update: {}, | ||
create: { | ||
text, | ||
number, | ||
textHash, | ||
}, | ||
}); | ||
|
||
await tx.pageVersionSourceText.upsert({ | ||
where: { | ||
pageVersionId_sourceTextId: { | ||
pageVersionId, | ||
sourceTextId: sourceText.id, | ||
}, | ||
}, | ||
update: {}, | ||
create: { | ||
pageVersionId, | ||
sourceTextId: sourceText.id, | ||
}, | ||
}); | ||
|
||
return sourceText.id; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export const REDIS_URL = process.env.REDIS_URL || "redis://localhost:6379"; | ||
export const MAX_CHUNK_SIZE = 20000; | ||
export const AI_MODEL = "gemini-1.5-flash"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.