From a7329a6ae081ef02276784107a3c8d519cdd6679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Pumar?= Date: Tue, 16 Jul 2024 16:03:13 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Fix=20issue=20(#5238)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/annotation/container/fields/Record.vue | 4 ++-- .../v1/domain/entities/record/Records.test.ts | 8 ++------ argilla-frontend/v1/domain/entities/record/Records.ts | 8 ++------ .../domain/usecases/get-records-by-criteria-use-case.ts | 1 - .../domain/usecases/load-records-to-annotate-use-case.ts | 2 +- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/argilla-frontend/components/features/annotation/container/fields/Record.vue b/argilla-frontend/components/features/annotation/container/fields/Record.vue index ec445bb619..620c2c8aa1 100644 --- a/argilla-frontend/components/features/annotation/container/fields/Record.vue +++ b/argilla-frontend/components/features/annotation/container/fields/Record.vue @@ -47,7 +47,7 @@ export default { }, computed: { spanQuestionsAnswers() { - return this.record.questions + return this.record?.questions .filter((q) => q.isSpanType) .map((q) => ({ id: q.id, @@ -60,7 +60,7 @@ export default { deep: true, handler() { if ( - this.record.questions + this.record?.questions .filter((q) => q.isSpanType) .some((q) => q.isModified) ) { diff --git a/argilla-frontend/v1/domain/entities/record/Records.test.ts b/argilla-frontend/v1/domain/entities/record/Records.test.ts index 6c8a4bb52f..ee7bf1e2b7 100644 --- a/argilla-frontend/v1/domain/entities/record/Records.test.ts +++ b/argilla-frontend/v1/domain/entities/record/Records.test.ts @@ -1119,11 +1119,7 @@ describe("Records", () => { describe("EmptyQueueRecords", () => { describe("hasRecordsToAnnotate", () => { test("should be false always", () => { - const records = new EmptyQueueRecords( - createBasicRecordCriteria(), - 20, - [] - ); + const records = new EmptyQueueRecords(createBasicRecordCriteria(), []); const hasRecordsToAnnotate = records.hasRecordsToAnnotate; @@ -1134,7 +1130,7 @@ describe("EmptyQueueRecords", () => { describe("getRecordOn", () => { test("always should return the record configured by record criteria", () => { const recordCriteria = createBasicRecordCriteria(); - const records = new EmptyQueueRecords(recordCriteria, 20, []); + const records = new EmptyQueueRecords(recordCriteria, []); const hasRecordsToAnnotate = records.getRecordOn(recordCriteria.page); diff --git a/argilla-frontend/v1/domain/entities/record/Records.ts b/argilla-frontend/v1/domain/entities/record/Records.ts index d7e8a0bc73..4b487a9b86 100644 --- a/argilla-frontend/v1/domain/entities/record/Records.ts +++ b/argilla-frontend/v1/domain/entities/record/Records.ts @@ -132,11 +132,7 @@ export class RecordsWithReference extends Records { } export class EmptyQueueRecords extends Records { - constructor( - criteria: RecordCriteria, - total: number, - questions: Question[] = [] - ) { + constructor(criteria: RecordCriteria, questions: Question[] = []) { const nullRecord = new Record( undefined, criteria.datasetId, @@ -151,6 +147,6 @@ export class EmptyQueueRecords extends Records { null ); - super([nullRecord], total, false); + super([nullRecord], -1, false); } } diff --git a/argilla-frontend/v1/domain/usecases/get-records-by-criteria-use-case.ts b/argilla-frontend/v1/domain/usecases/get-records-by-criteria-use-case.ts index e596991aff..07b8897bf2 100644 --- a/argilla-frontend/v1/domain/usecases/get-records-by-criteria-use-case.ts +++ b/argilla-frontend/v1/domain/usecases/get-records-by-criteria-use-case.ts @@ -39,7 +39,6 @@ export class GetRecordsByCriteriaUseCase { if (recordsFromBackend.records.length === 0) { return new EmptyQueueRecords( criteria, - recordsFromBackend.total, questionsFromBackend.map((question) => { return new Question( question.id, diff --git a/argilla-frontend/v1/domain/usecases/load-records-to-annotate-use-case.ts b/argilla-frontend/v1/domain/usecases/load-records-to-annotate-use-case.ts index b0571e8688..05a5946e35 100644 --- a/argilla-frontend/v1/domain/usecases/load-records-to-annotate-use-case.ts +++ b/argilla-frontend/v1/domain/usecases/load-records-to-annotate-use-case.ts @@ -44,7 +44,7 @@ export class LoadRecordsToAnnotateUseCase { if (!isFilteringBySimilarity && !isNextRecordExist) { const newRecords = await this.getRecords.execute(criteria); - records.append(newRecords); + if (newRecords.hasRecordsToAnnotate) records.append(newRecords); isNextRecordExist = records.existsRecordOn(page);