From 4324861748108d8127ba865deccc4dea58b7e209 Mon Sep 17 00:00:00 2001 From: Aditya Khatri Date: Wed, 6 Sep 2023 22:53:31 +0545 Subject: [PATCH] Update analysis report snapshot schema --- apps/analysis/models.py | 2 +- apps/analysis/public_schema.py | 2 +- apps/analysis/schema.py | 2 +- apps/commons/schema_snapshots.py | 318 ++++++++++--------------------- 4 files changed, 107 insertions(+), 217 deletions(-) diff --git a/apps/analysis/models.py b/apps/analysis/models.py index 90ada578a1..fc87613085 100644 --- a/apps/analysis/models.py +++ b/apps/analysis/models.py @@ -565,7 +565,7 @@ class AnalysisReport(UserResource): @staticmethod def get_latest_snapshot(slug=None, report_id=None): - if slug is None or id is None: + if slug is None and report_id is None: return queryset = AnalysisReportSnapshot.objects.filter( report__is_public=True, diff --git a/apps/analysis/public_schema.py b/apps/analysis/public_schema.py index eb395fcd4f..b03fc412ed 100644 --- a/apps/analysis/public_schema.py +++ b/apps/analysis/public_schema.py @@ -12,5 +12,5 @@ class Query: ) @staticmethod - def resolve_analysis_report_snapshot(root, info, slug, **kwargs) -> typing.Optional[AnalysisReportSnapshot]: + def resolve_public_analysis_report_snapshot(root, info, slug, **kwargs) -> typing.Optional[AnalysisReportSnapshot]: return AnalysisReport.get_latest_snapshot(slug=slug) diff --git a/apps/analysis/schema.py b/apps/analysis/schema.py index f0926e72a4..513b1aee76 100644 --- a/apps/analysis/schema.py +++ b/apps/analysis/schema.py @@ -646,7 +646,7 @@ def resolve_published_by(root, info, **_): return resolve_user_field(root, info, 'published_by') @staticmethod - def resolve_uploads(root, info, **_): + def resolve_files(root, info, **_): # TODO: Maybe filter this out? # For now # - organization logos diff --git a/apps/commons/schema_snapshots.py b/apps/commons/schema_snapshots.py index 72f3b712eb..0278e5a011 100644 --- a/apps/commons/schema_snapshots.py +++ b/apps/commons/schema_snapshots.py @@ -183,229 +183,119 @@ class DeepExplore: class AnalysisReport: Snapshot = ''' - query MyQuery($projectID: ID!, $reportID: ID!) { - project(id: $projectID) { - analysisReport(id: $reportID) { - id - analysis - isPublic - slug - subTitle - title - organizations { + fragment OrganizationGeneralResponse on OrganizationType { + id + title + verified + shortName + logo { + id + } + mergedAs { id title shortName - mergedAs { - id - title - shortName - longName - } - } - configuration { - bodyStyle { - gap - } - containerStyle { - background { - color - opacity - } - border { - color - opacity - style - width - } - padding { - bottom - left - right - top - } - } - headerStyle { - background { - color - opacity - } - border { - color - opacity - style - width - } - padding { - bottom - left - right - top - } - subTitle { - align - color - family - size - weight - } - title { - align - color - family - size - weight - } - } - headingContentStyle { - h1 { - align - color - family - size - weight - } - h2 { - align - color - family - size - weight - } - h3 { - align - color - family - size - weight - } - h4 { - align - color - family - size - weight - } - } - imageContentStyle { - caption { - align - color - family - size - weight - } - fit - } - pageStyle { - background { - color - opacity - } - margin { - bottom - left - right - top - } - } - textContentStyle { - content { - align - color - family - size - weight - } - } - urlContentStyle { - url - } - } - containers { - id - row - column - width - height - contentConfiguration { - heading { - content - contentStyle { - content { - align - color - family - size - weight - } - } - variant - } - image { - altText - caption - } - text { - content - contentStyle { - content { - align - color - family - size - weight - } - } - } - url { - url - } - } - contentData { - data - id - upload { + logo { id - } } - contentStyle { - heading { - background { - color - opacity - } - border { - color - opacity - style - width - } - padding { - bottom - left - right - top - } - subTitle { - align - color - family - size - weight + } + } + fragment TextStyle on AnalysisReportTextStyleType { + align + color + family + size + weight + } + fragment PaddingStyle on AnalysisReportPaddingStyleType { + top + bottom + right + left + } + fragment BorderStyle on AnalysisReportBorderStyleType { + color + opacity + style + width + } + query MyQuery($projectID: ID!, $reportID: ID!) { + project(id: $projectID) { + analysisReport(id: $reportID) { + id + analysis + title + subTitle + slug + organizations { + ...OrganizationGeneralResponse } - title { - align - color - family - size - weight + containers { + id + clientId + row + column + width + height + contentType + style { + border { + ...BorderStyle + } + padding { + ...PaddingStyle + } + background { + color + opacity + } + } + contentData { + clientId + data + id + upload { + id + file { + id + } + } + } + contentConfiguration { + heading { + content + variant + style { + content { + ...TextStyle + } + } + } + image { + altText + caption + style { + caption { + ...TextStyle + } + fit + } + } + text { + content + style { + content { + ...TextStyle + } + } + } + url { + url + } + } } - } } - } } - } } '''