From 6321478e5d5b04572dacc54c86295732053470a8 Mon Sep 17 00:00:00 2001 From: thenav56 Date: Tue, 2 Jan 2024 13:30:28 +0545 Subject: [PATCH 1/3] Add Lead's isAssessment & hasAssessment in EntryFilter --- apps/entry/filter_set.py | 8 ++++++++ apps/entry/tests/test_schemas.py | 14 ++++++++++++++ schema.graphql | 8 ++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/apps/entry/filter_set.py b/apps/entry/filter_set.py index 98e6ffcc17..dad0ba5cf7 100644 --- a/apps/entry/filter_set.py +++ b/apps/entry/filter_set.py @@ -574,6 +574,8 @@ class EntryGQFilterSet(GrapheneFilterSetMixin, UserResourceGqlFilterSet): lead_authoring_organization_types = IDListFilter(method='authoring_organization_types_filter') lead_author_organizations = IDListFilter(field_name='lead__authors') lead_source_organizations = IDListFilter(field_name='lead__source') + lead_has_assessment = django_filters.BooleanFilter(method='lead_has_assessment_filter', help_text='Lead has assessment.') + lead_is_assessment = django_filters.BooleanFilter(field_name='lead__is_assessment_lead') search = django_filters.CharFilter(method='search_filter') created_by = IDListFilter() @@ -643,6 +645,12 @@ def lead_group_label_filter(self, queryset, name, value): return queryset.filter(entrygrouplabel__group__title__icontains=value) return queryset + def lead_has_assessment_filter(self, qs, _, value): + if value is None: + return qs + # TODO: We need to add new assessment module filter here after it is deployed + return qs.filter(lead__assessment__isnull=not value) + def authoring_organization_types_filter(self, qs, name, value): if value: qs = qs.annotate( diff --git a/apps/entry/tests/test_schemas.py b/apps/entry/tests/test_schemas.py index d3ce06dcf1..b3c85e39f4 100644 --- a/apps/entry/tests/test_schemas.py +++ b/apps/entry/tests/test_schemas.py @@ -9,6 +9,7 @@ from user.factories import UserFactory from geo.factories import RegionFactory, AdminLevelFactory, GeoAreaFactory from project.factories import ProjectFactory +from ary.factories import AssessmentFactory from lead.factories import LeadFactory from entry.factories import EntryFactory, EntryAttributeFactory from analysis_framework.factories import AnalysisFrameworkFactory, WidgetFactory @@ -248,6 +249,8 @@ def test_entry_query_filter(self): $leadPublishedOn: Date $leadPublishedOnGte: Date $leadPublishedOnLte: Date + $leadHasAssessment: Boolean + $leadIsAssessment: Boolean $leads: [ID!] $leadStatuses: [LeadStatusEnum!] $leadTitle: String @@ -282,6 +285,8 @@ def test_entry_query_filter(self): leadPublishedOn: $leadPublishedOn leadPublishedOnGte: $leadPublishedOnGte leadPublishedOnLte: $leadPublishedOnLte + leadHasAssessment: $leadHasAssessment + leadIsAssessment: $leadIsAssessment leads: $leads leadStatuses: $leadStatuses leadTitle: $leadTitle @@ -319,6 +324,7 @@ def test_entry_query_filter(self): assignee=[member1], priority=Lead.Priority.HIGH, status=Lead.Status.IN_PROGRESS, + is_assessment_lead=True, ) lead2 = LeadFactory.create( project=project, @@ -327,6 +333,7 @@ def test_entry_query_filter(self): assignee=[member2], authors=[org2, org3], priority=Lead.Priority.HIGH, + is_assessment_lead=True, ) lead3 = LeadFactory.create( project=project, @@ -361,6 +368,9 @@ def test_entry_query_filter(self): entry4_1 = EntryFactory.create( project=project, analysis_framework=af, lead=lead4, entry_type=Entry.TagType.EXCERPT, controlled=False) + # For assessment filters + AssessmentFactory.create(project=project, lead=lead1) + # create entry review comment for entry EntryReviewCommentFactory(entry=entry1_1, created_by=user, comment_type=EntryReviewComment.CommentType.COMMENT) EntryReviewCommentFactory(entry=entry2_1, created_by=member1, comment_type=EntryReviewComment.CommentType.CONTROL) @@ -408,6 +418,10 @@ def test_entry_query_filter(self): {'leadStatuses': [self.genum(Lead.Status.IN_PROGRESS), self.genum(Lead.Status.TAGGED)]}, [entry1_1, entry2_1, entry3_1, entry4_1] ), + ({'leadIsAssessment': True}, [entry1_1, entry2_1]), + ({'leadIsAssessment': False}, [entry3_1, entry4_1]), + ({'leadHasAssessment': True}, [entry1_1]), + ({'leadHasAssessment': False}, [entry2_1, entry3_1, entry4_1]), ({'hasComment': True}, [entry1_1, entry3_1]), ({'hasComment': False}, [entry2_1, entry4_1]), ({'isVerified': True}, [entry1_1, entry2_1]), diff --git a/schema.graphql b/schema.graphql index 044a077f8d..54f022c4ef 100644 --- a/schema.graphql +++ b/schema.graphql @@ -322,7 +322,7 @@ type AnalysisPillarType { analyzedEntriesCount: Int! statements: [AnalyticalStatementType!] discardedEntries(tags: [DiscardedEntryTagTypeEnum!], page: Int = 1, ordering: String, pageSize: Int): AnalysisPillarDiscardedEntryListType - entries(id: ID, excerpt: String, controlled: Boolean, createdAt: DateTime, createdAtGte: DateTime, createdAtLte: DateTime, modifiedAt: DateTime, modifiedAtGte: DateTime, modifiedAtLte: DateTime, createdBy: [ID!], modifiedBy: [ID!], leads: [ID!], leadCreatedBy: [ID!], leadPublishedOn: Date, leadPublishedOnGte: Date, leadPublishedOnLte: Date, leadTitle: String, leadAssignees: [ID!], leadStatuses: [LeadStatusEnum!], leadPriorities: [LeadPriorityEnum!], leadConfidentialities: [LeadConfidentialityEnum!], leadAuthoringOrganizationTypes: [ID!], leadAuthorOrganizations: [ID!], leadSourceOrganizations: [ID!], search: String, entryTypes: [EntryTagTypeEnum!], projectEntryLabels: [ID!], entriesId: [ID!], geoCustomShape: String, leadGroupLabel: String, filterableData: [EntryFilterDataInputType!], hasComment: Boolean, isVerified: Boolean, discarded: Boolean, excludeEntries: [ID!], page: Int = 1, ordering: String, pageSize: Int): AnalysisPillarEntryListType + entries(id: ID, excerpt: String, controlled: Boolean, createdAt: DateTime, createdAtGte: DateTime, createdAtLte: DateTime, modifiedAt: DateTime, modifiedAtGte: DateTime, modifiedAtLte: DateTime, createdBy: [ID!], modifiedBy: [ID!], leads: [ID!], leadCreatedBy: [ID!], leadPublishedOn: Date, leadPublishedOnGte: Date, leadPublishedOnLte: Date, leadTitle: String, leadAssignees: [ID!], leadStatuses: [LeadStatusEnum!], leadPriorities: [LeadPriorityEnum!], leadConfidentialities: [LeadConfidentialityEnum!], leadAuthoringOrganizationTypes: [ID!], leadAuthorOrganizations: [ID!], leadSourceOrganizations: [ID!], leadHasAssessment: Boolean, leadIsAssessment: Boolean, search: String, entryTypes: [EntryTagTypeEnum!], projectEntryLabels: [ID!], entriesId: [ID!], geoCustomShape: String, leadGroupLabel: String, filterableData: [EntryFilterDataInputType!], hasComment: Boolean, isVerified: Boolean, discarded: Boolean, excludeEntries: [ID!], page: Int = 1, ordering: String, pageSize: Int): AnalysisPillarEntryListType } input AnalysisPillarUpdateInputType { @@ -3168,6 +3168,8 @@ input EntriesFilterDataInputType { leadAuthoringOrganizationTypes: [ID!] leadAuthorOrganizations: [ID!] leadSourceOrganizations: [ID!] + leadHasAssessment: Boolean + leadIsAssessment: Boolean search: String entryTypes: [EntryTagTypeEnum!] projectEntryLabels: [ID!] @@ -3207,6 +3209,8 @@ type EntriesFilterDataType { leadPublishedOnGte: Date leadPublishedOnLte: Date leadTitle: String + leadHasAssessment: Boolean + leadIsAssessment: Boolean search: String geoCustomShape: String leadGroupLabel: String @@ -4516,7 +4520,7 @@ type ProjectDetailType { export(id: ID!): UserExportType exports(type: [ExportDataTypeEnum!], format: [ExportFormatEnum!], status: [ExportStatusEnum!], search: String, exportedAt: DateTime, exportedAtGte: DateTime, exportedAtLte: DateTime, page: Int = 1, ordering: String, pageSize: Int): UserExportListType entry(id: ID!): EntryType - entries(id: ID, excerpt: String, controlled: Boolean, createdAt: DateTime, createdAtGte: DateTime, createdAtLte: DateTime, modifiedAt: DateTime, modifiedAtGte: DateTime, modifiedAtLte: DateTime, createdBy: [ID!], modifiedBy: [ID!], leads: [ID!], leadCreatedBy: [ID!], leadPublishedOn: Date, leadPublishedOnGte: Date, leadPublishedOnLte: Date, leadTitle: String, leadAssignees: [ID!], leadStatuses: [LeadStatusEnum!], leadPriorities: [LeadPriorityEnum!], leadConfidentialities: [LeadConfidentialityEnum!], leadAuthoringOrganizationTypes: [ID!], leadAuthorOrganizations: [ID!], leadSourceOrganizations: [ID!], search: String, entryTypes: [EntryTagTypeEnum!], projectEntryLabels: [ID!], entriesId: [ID!], geoCustomShape: String, leadGroupLabel: String, filterableData: [EntryFilterDataInputType!], hasComment: Boolean, isVerified: Boolean, page: Int = 1, ordering: String, pageSize: Int): EntryListType + entries(id: ID, excerpt: String, controlled: Boolean, createdAt: DateTime, createdAtGte: DateTime, createdAtLte: DateTime, modifiedAt: DateTime, modifiedAtGte: DateTime, modifiedAtLte: DateTime, createdBy: [ID!], modifiedBy: [ID!], leads: [ID!], leadCreatedBy: [ID!], leadPublishedOn: Date, leadPublishedOnGte: Date, leadPublishedOnLte: Date, leadTitle: String, leadAssignees: [ID!], leadStatuses: [LeadStatusEnum!], leadPriorities: [LeadPriorityEnum!], leadConfidentialities: [LeadConfidentialityEnum!], leadAuthoringOrganizationTypes: [ID!], leadAuthorOrganizations: [ID!], leadSourceOrganizations: [ID!], leadHasAssessment: Boolean, leadIsAssessment: Boolean, search: String, entryTypes: [EntryTagTypeEnum!], projectEntryLabels: [ID!], entriesId: [ID!], geoCustomShape: String, leadGroupLabel: String, filterableData: [EntryFilterDataInputType!], hasComment: Boolean, isVerified: Boolean, page: Int = 1, ordering: String, pageSize: Int): EntryListType lead(id: ID!): LeadDetailType leads(text: String, url: String, createdAt: DateTime, createdAtGte: DateTime, createdAtLte: DateTime, modifiedAt: DateTime, modifiedAtGte: DateTime, modifiedAtLte: DateTime, createdBy: [ID!], modifiedBy: [ID!], ids: [ID!], excludeProvidedLeadsId: Boolean, sourceTypes: [LeadSourceTypeEnum!], priorities: [LeadPriorityEnum!], confidentiality: LeadConfidentialityEnum, statuses: [LeadStatusEnum!], extractionStatus: LeadExtractionStatusEnum, assignees: [ID!], authoringOrganizationTypes: [ID!], authorOrganizations: [ID!], sourceOrganizations: [ID!], hasEntries: Boolean, hasAssessment: Boolean, isAssessment: Boolean, entriesFilterData: EntriesFilterDataInputType, search: String, publishedOn: Date, publishedOnGte: Date, publishedOnLte: Date, emmEntities: String, emmKeywords: String, emmRiskFactors: String, hasDuplicates: Boolean, duplicatesOf: ID, ordering: [LeadOrderingEnum!], page: Int = 1, pageSize: Int): LeadListType leadGroup(id: ID!): LeadGroupType From 2ff5222a10314234617a4a8d3ecc44533b242fe2 Mon Sep 17 00:00:00 2001 From: thenav56 Date: Wed, 3 Jan 2024 16:02:38 +0545 Subject: [PATCH 2/3] Fix deep explore public snapshot issue --- apps/deep_explore/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/deep_explore/tasks.py b/apps/deep_explore/tasks.py index 0d19ff6543..9349e9c26a 100644 --- a/apps/deep_explore/tasks.py +++ b/apps/deep_explore/tasks.py @@ -197,7 +197,7 @@ def _save_snapshot( snapshot, generate_download_file=True, ): - file_content, errors = generate_query_snapshot(gql_query, {'fitler': filters}) + file_content, errors = generate_query_snapshot(gql_query, {'filter': filters}) if file_content is None: logger.error(f'Failed to generate: {errors}', exc_info=True) return From 141515a42bfdc947f74c96f325416a2124f540b9 Mon Sep 17 00:00:00 2001 From: rup-narayan-rajbanshi Date: Wed, 31 Jan 2024 11:55:22 +0545 Subject: [PATCH 3/3] Update lead_has_assessment in entry filter Use new assessment registry. --- apps/entry/filter_set.py | 3 +-- apps/entry/tests/test_schemas.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/entry/filter_set.py b/apps/entry/filter_set.py index dad0ba5cf7..a7f813752f 100644 --- a/apps/entry/filter_set.py +++ b/apps/entry/filter_set.py @@ -648,8 +648,7 @@ def lead_group_label_filter(self, queryset, name, value): def lead_has_assessment_filter(self, qs, _, value): if value is None: return qs - # TODO: We need to add new assessment module filter here after it is deployed - return qs.filter(lead__assessment__isnull=not value) + return qs.filter(lead__assessmentregistry__isnull=not value) def authoring_organization_types_filter(self, qs, name, value): if value: diff --git a/apps/entry/tests/test_schemas.py b/apps/entry/tests/test_schemas.py index b3c85e39f4..b4a49b2265 100644 --- a/apps/entry/tests/test_schemas.py +++ b/apps/entry/tests/test_schemas.py @@ -9,11 +9,11 @@ from user.factories import UserFactory from geo.factories import RegionFactory, AdminLevelFactory, GeoAreaFactory from project.factories import ProjectFactory -from ary.factories import AssessmentFactory from lead.factories import LeadFactory from entry.factories import EntryFactory, EntryAttributeFactory from analysis_framework.factories import AnalysisFrameworkFactory, WidgetFactory from organization.factories import OrganizationFactory, OrganizationTypeFactory +from assessment_registry.factories import AssessmentRegistryFactory from quality_assurance.factories import EntryReviewCommentFactory from lead.tests.test_schemas import TestLeadQuerySchema @@ -369,7 +369,7 @@ def test_entry_query_filter(self): project=project, analysis_framework=af, lead=lead4, entry_type=Entry.TagType.EXCERPT, controlled=False) # For assessment filters - AssessmentFactory.create(project=project, lead=lead1) + AssessmentRegistryFactory.create(project=project, lead=lead1) # create entry review comment for entry EntryReviewCommentFactory(entry=entry1_1, created_by=user, comment_type=EntryReviewComment.CommentType.COMMENT)