-
Notifications
You must be signed in to change notification settings - Fork 1
TSA-147: Allow a page to be confirmed again after undo #343
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d4270d5
TSA-147: * allow page reconfirmation after undo
MatiStb f25fba2
Merge branch 'main' into feat/TSA-147-allow-page-confirmed-after-undo
MatiStb cb01c10
TSA-147: * resolve merge conflicts with main
MatiStb 3e99757
Merge branch 'main' into feat/TSA-147-allow-page-confirmed-after-undo
anjoanka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
apps/backend/src/db/migrations/20260920100000_add_page_event_attempt.ts
This file contains hidden or 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,38 @@ | ||
| import { type Knex } from "knex"; | ||
|
|
||
| const TABLE_NAME = "page_event"; | ||
| const ATTEMPT_COLUMN = "attempt"; | ||
| const DEFAULT_ATTEMPT = 0; | ||
| const ONCE_INDEX = "page_event_once"; | ||
|
|
||
| async function down(knex: Knex): Promise<void> { | ||
| await knex.raw(` | ||
| DROP INDEX IF EXISTS ${ONCE_INDEX}; | ||
| `); | ||
|
|
||
| await knex.schema.alterTable(TABLE_NAME, (table) => { | ||
| table.dropColumn(ATTEMPT_COLUMN); | ||
| }); | ||
|
|
||
| await knex.raw(` | ||
| CREATE UNIQUE INDEX ${ONCE_INDEX} | ||
| ON ${TABLE_NAME} (page_id, transcription_id, event) | ||
| WHERE event IN ('confirm', 'correct', 'skip'); | ||
| `); | ||
| } | ||
|
|
||
| async function up(knex: Knex): Promise<void> { | ||
| await knex.schema.alterTable(TABLE_NAME, (table) => { | ||
| table.integer(ATTEMPT_COLUMN).notNullable().defaultTo(DEFAULT_ATTEMPT); | ||
| }); | ||
|
|
||
| await knex.raw(` | ||
| DROP INDEX ${ONCE_INDEX}; | ||
|
|
||
| CREATE UNIQUE INDEX ${ONCE_INDEX} | ||
| ON ${TABLE_NAME} (page_id, transcription_id, event, attempt) | ||
| WHERE event IN ('confirm', 'correct', 'skip'); | ||
| `); | ||
| } | ||
|
|
||
| export { down, up }; | ||
This file contains hidden or 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
1 change: 1 addition & 0 deletions
1
apps/backend/src/modules/jobs/libs/enums/page-event-name.enum.ts
This file contains hidden or 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,5 +1,6 @@ | ||
| const PageEventName = { | ||
| TRANSCRIBE_FAILED: "transcribe_failed", | ||
| UNDO: "undo", | ||
| } as const; | ||
|
|
||
| export { PageEventName }; |
This file contains hidden or 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,5 @@ | ||
| export { CLOSED_PAGE_STATUSES } from "./closed-page-statuses.constant.js"; | ||
| export { PAGE_EVENT_ATTEMPT_INCREMENT } from "./page-event-attempt-increment.constant.js"; | ||
| export { NUMBER_OF_PAGES_TO_INCREMENT } from "./page-number-increment.constant.js"; | ||
| export { REPROCESSABLE_PAGE_STATUSES } from "./reprocessable-page-statuses.constant.js"; | ||
| export { UNDOABLE_PAGE_STATUSES } from "./undoable-page-statuses.constant.js"; |
3 changes: 3 additions & 0 deletions
3
apps/backend/src/modules/pages/libs/constants/page-event-attempt-increment.constant.ts
This file contains hidden or 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,3 @@ | ||
| const PAGE_EVENT_ATTEMPT_INCREMENT = 1; | ||
|
|
||
| export { PAGE_EVENT_ATTEMPT_INCREMENT }; |
9 changes: 9 additions & 0 deletions
9
apps/backend/src/modules/pages/libs/constants/undoable-page-statuses.constant.ts
This file contains hidden or 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,9 @@ | ||
| import { PageStatus, type PageStatusValue } from "@transcripta/shared"; | ||
|
|
||
| const UNDOABLE_PAGE_STATUSES: ReadonlySet<PageStatusValue> = new Set([ | ||
| PageStatus.CONFIRMED, | ||
| PageStatus.CORRECTED, | ||
| PageStatus.SKIPPED, | ||
| ]); | ||
|
|
||
| export { UNDOABLE_PAGE_STATUSES }; |
1 change: 1 addition & 0 deletions
1
apps/backend/src/modules/pages/libs/enums/page-error-message.enum.ts
This file contains hidden or 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 hidden or 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
9 changes: 9 additions & 0 deletions
9
apps/backend/src/modules/pages/page-event/libs/types/page-event-create-undo-payload.type.ts
This file contains hidden or 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,9 @@ | ||
| type CreateUndoPageEventPayload = { | ||
| actorId: number; | ||
| attempt: number; | ||
| documentId: number; | ||
| pageId: number; | ||
| transcriptionId: number; | ||
| }; | ||
|
|
||
| export { type CreateUndoPageEventPayload }; |
1 change: 1 addition & 0 deletions
1
...ackend/src/modules/pages/page-event/libs/types/page-event-find-verification-event.type.ts
This file contains hidden or 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 hidden or 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,2 +1,3 @@ | ||
| export { type CreatePageEventPayload } from "./page-event-create-payload.type.js"; | ||
| export { type CreateUndoPageEventPayload } from "./page-event-create-undo-payload.type.js"; | ||
| export { type FindVerificationEventPayload } from "./page-event-find-verification-event.type.js"; |
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.