From 73e6f53deb18238180871708227ad19511295873 Mon Sep 17 00:00:00 2001 From: Victor Zeinstra Date: Thu, 12 Oct 2023 10:51:25 +0200 Subject: [PATCH 1/6] chore: fix types --- .../documents/api/documents.service.ts | 55 +++++++++---------- .../informationsEdit/InformationsContent.tsx | 1 - .../editInformation.mapping.ts | 17 ++++-- .../frontend/src/modules/informations/type.ts | 1 - 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/targets/frontend/src/modules/documents/api/documents.service.ts b/targets/frontend/src/modules/documents/api/documents.service.ts index 8516f1bee..9267625d1 100644 --- a/targets/frontend/src/modules/documents/api/documents.service.ts +++ b/targets/frontend/src/modules/documents/api/documents.service.ts @@ -51,34 +51,33 @@ export class DocumentsService { return { name, title, - blocks: blocks.map( - ({ - file, - img, - type, - content, - contentDisplayMode, - contents, - }) => { - return { - size: file?.size, - type, - imgUrl: img?.url, - fileUrl: file?.url, - markdown: content, - blockDisplayMode: contentDisplayMode, - contents: contents?.length - ? contents.map(({ document }) => { - return { - title: document.title, - cdtnId: document.cdtnId, - source: document.source, - }; - }) - : undefined, - }; - } - ), + blocks: blocks.map((block) => { + return { + type: block.type, + markdown: block.content, + ...(block.type === "graphic" + ? { + size: block.file?.size, + imgUrl: block.img?.url, + fileUrl: block.file?.url, + } + : {}), + ...(block.type === "content" + ? { + blockDisplayMode: block.contentDisplayMode, + contents: block.contents?.length + ? block.contents.map(({ document }) => { + return { + title: document.title, + cdtnId: document.cdtnId, + source: document.source, + }; + }) + : undefined, + } + : {}), + }; + }), references: references?.length ? [ { diff --git a/targets/frontend/src/modules/informations/components/informationsEdit/InformationsContent.tsx b/targets/frontend/src/modules/informations/components/informationsEdit/InformationsContent.tsx index 354b9a585..e26c1fc78 100644 --- a/targets/frontend/src/modules/informations/components/informationsEdit/InformationsContent.tsx +++ b/targets/frontend/src/modules/informations/components/informationsEdit/InformationsContent.tsx @@ -127,7 +127,6 @@ export const InformationsContent = ({ appendBlock({ type: "markdown", content: "", - contents: [], }) } > diff --git a/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mapping.ts b/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mapping.ts index a92cc6504..47d4a055c 100644 --- a/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mapping.ts +++ b/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mapping.ts @@ -64,14 +64,19 @@ const mapInformationContentsBlocks = ( }, data: blocks?.map((block, blockIndex) => { - const file = mapInformationContentsBlocksFile(block.file); - const img = mapInformationContentsBlocksFile(block.img); - const contents = mapInformationContentsBlocksContents(block.contents); return { ...removeTypename(block), - file, - img, - contents, + ...(block.type === "graphic" + ? { + file: block.file, + img: block.img, + } + : {}), + ...(block.type === "content" + ? { + contents: block.contents, + } + : {}), order: blockIndex + 1, }; }) ?? [], diff --git a/targets/frontend/src/modules/informations/type.ts b/targets/frontend/src/modules/informations/type.ts index 8adf7b907..54f6916b9 100644 --- a/targets/frontend/src/modules/informations/type.ts +++ b/targets/frontend/src/modules/informations/type.ts @@ -42,7 +42,6 @@ export const informationContentBlockSchema = z.object({ id: z.string().uuid().nullable().optional(), content: z.string(), type: z.string({ required_error: "un type doit ĂȘtre renseigner" }), - order: z.number().nullable().optional(), }); From 41ce871ba93cce45b11ae4950d19d459b215c133 Mon Sep 17 00:00:00 2001 From: Martial Maillot Date: Thu, 12 Oct 2023 14:14:21 +0200 Subject: [PATCH 2/6] fix: use mapping to create graphql request --- .../components/informationsEdit/editInformation.mapping.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mapping.ts b/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mapping.ts index 47d4a055c..586da74c6 100644 --- a/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mapping.ts +++ b/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mapping.ts @@ -68,13 +68,13 @@ const mapInformationContentsBlocks = ( ...removeTypename(block), ...(block.type === "graphic" ? { - file: block.file, - img: block.img, + file: mapInformationContentsBlocksFile(block.file), + img: mapInformationContentsBlocksFile(block.img), } : {}), ...(block.type === "content" ? { - contents: block.contents, + contents: mapInformationContentsBlocksContents(block.contents), } : {}), order: blockIndex + 1, From 8c987fffb284f05d7a4ba7379e6dde3d44374ac9 Mon Sep 17 00:00:00 2001 From: Martial Maillot Date: Thu, 12 Oct 2023 17:07:27 +0200 Subject: [PATCH 3/6] fix: issues with mapping and requests --- .../informationsEdit/Informations.query.ts | 115 ++++++++---------- .../informationsEdit/InformationsEdit.tsx | 8 +- .../__tests__/editInformation.mapping.test.ts | 40 ++++++ .../editInformation.mapping.ts | 5 +- .../editInformation.mutation.ts | 92 +++++++------- 5 files changed, 152 insertions(+), 108 deletions(-) create mode 100644 targets/frontend/src/modules/informations/components/informationsEdit/__tests__/editInformation.mapping.test.ts diff --git a/targets/frontend/src/modules/informations/components/informationsEdit/Informations.query.ts b/targets/frontend/src/modules/informations/components/informationsEdit/Informations.query.ts index 845f55a00..942a38aac 100644 --- a/targets/frontend/src/modules/informations/components/informationsEdit/Informations.query.ts +++ b/targets/frontend/src/modules/informations/components/informationsEdit/Informations.query.ts @@ -1,85 +1,74 @@ -import { CombinedError, useQuery } from "urql"; +import { CombinedError, OperationContext, useQuery } from "urql"; import { format, parseISO } from "date-fns"; import { Information } from "../../type"; +import { gql } from "@urql/core"; -const informationsQuery = `query informations($id: uuid) { - information_informations( - where: { - id: { _eq: $id } - } - ) { - description +const informationsQuery = gql` + query informations($id: uuid) { + information_informations(where: { id: { _eq: $id } }) { + description + id + intro + metaDescription + metaTitle + referenceLabel + sectionDisplayMode + title + updatedAt + dismissalProcess + contents(order_by: { order: asc }) { id - intro - metaDescription - metaTitle - referenceLabel - sectionDisplayMode + name title - updatedAt - dismissalProcess - contents( - order_by: {order: asc} - ) { + referenceLabel + order + blocks(order_by: { order: asc }) { id - name - title - referenceLabel + content order - blocks( - order_by: {order: asc} - ) { + type + file { id - content - order - type - file { - id - url - altText - size - } - img { - id - url - altText - size - } - contentDisplayMode - contents( - order_by: {order: asc} - ) { - id - document { - cdtnId: cdtn_id - source - title - slug - } - } + url + altText + size } - references( - order_by: {order: asc} - ) { + img { id url - type - title - order + altText + size + } + contentDisplayMode + contents(order_by: { order: asc }) { + id + document { + cdtnId: cdtn_id + source + title + slug + } } } - references( - order_by: {order: asc} - ) { + references(order_by: { order: asc }) { id url type title order } + } + references(order_by: { order: asc }) { + id + url + type + title + order + } } - }`; + } +`; export type QueryInformation = Information; @@ -99,12 +88,13 @@ export type InformationsQueryResult = { data?: InformationsResult; error?: CombinedError; fetching: boolean; + reexecuteQuery: (opts?: Partial | undefined) => void; }; export const useInformationsQuery = ({ id, }: InformationsQueryProps): InformationsQueryResult => { - const [{ data, error, fetching }] = useQuery({ + const [{ data, error, fetching }, reexecuteQuery] = useQuery({ query: informationsQuery, requestPolicy: "cache-and-network", variables: { @@ -124,5 +114,6 @@ export const useInformationsQuery = ({ : undefined, error, fetching, + reexecuteQuery, }; }; diff --git a/targets/frontend/src/modules/informations/components/informationsEdit/InformationsEdit.tsx b/targets/frontend/src/modules/informations/components/informationsEdit/InformationsEdit.tsx index 9f46b6870..cf2b3d717 100644 --- a/targets/frontend/src/modules/informations/components/informationsEdit/InformationsEdit.tsx +++ b/targets/frontend/src/modules/informations/components/informationsEdit/InformationsEdit.tsx @@ -19,7 +19,11 @@ export type EditInformationProps = { }; export const InformationsEdit = ({ id }: EditInformationProps): JSX.Element => { - const { data: information, fetching } = useInformationsQuery({ id }); + const { + data: information, + fetching, + reexecuteQuery, + } = useInformationsQuery({ id }); const router = useRouter(); const [snack, setSnack] = useState<{ @@ -74,7 +78,7 @@ export const InformationsEdit = ({ id }: EditInformationProps): JSX.Element => { onUpsert={async (upsertData) => { try { const idUpsert = await onUpsert(upsertData); - await router.push(`/informations/${idUpsert}`); + reexecuteQuery({ requestPolicy: "network-only" }); setSnack({ open: true, severity: "success", diff --git a/targets/frontend/src/modules/informations/components/informationsEdit/__tests__/editInformation.mapping.test.ts b/targets/frontend/src/modules/informations/components/informationsEdit/__tests__/editInformation.mapping.test.ts new file mode 100644 index 000000000..8a4dc40c5 --- /dev/null +++ b/targets/frontend/src/modules/informations/components/informationsEdit/__tests__/editInformation.mapping.test.ts @@ -0,0 +1,40 @@ +import { getRawColumns } from "../editInformation.mapping"; + +test("All rows should be included (with null value also)", () => { + const rows = getRawColumns({ + id: "58d8f41e-b31b-47a2-a9d9-f079773ae86a", + name: "Cas 1", + title: "Cas 1", + referenceLabel: null, + order: 1, + blocks: [ + { + id: "f0e86b70-475d-4156-9df7-06a9fdf6e6e1", + content: "Toto", + type: "markdown", + order: 1, + }, + { + id: "ebe5f760-4907-47be-88bb-edc244a7849d", + content: "test", + type: "markdown", + order: 2, + }, + { + id: "cfadf03c-f540-4904-bc27-69877f9d9be9", + content: "Test 3", + type: "markdown", + order: 3, + }, + { + id: "73223a87-e142-44e8-9cfb-d1353e1bf71d", + content: "Test 4", + type: "markdown", + order: 4, + }, + ], + references: [], + }); + + expect(rows).toEqual(["id", "name", "title", "referenceLabel", "order"]); +}); diff --git a/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mapping.ts b/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mapping.ts index 586da74c6..16ed3646e 100644 --- a/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mapping.ts +++ b/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mapping.ts @@ -14,10 +14,11 @@ const removeTypename = (obj: any) => { return obj; }; -const getRawColumns = (obj?: any): string[] => { +export const getRawColumns = (obj?: any): string[] => { if (!obj) return []; return Object.entries(obj).reduce((result, [key, value]) => { - if (key === "__typename" || typeof value === "object") return result; + if (key === "__typename" || (value && typeof value === "object")) + return result; return [...result, key]; }, []); }; diff --git a/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mutation.ts b/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mutation.ts index f8ecb48e7..2aab85279 100644 --- a/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mutation.ts +++ b/targets/frontend/src/modules/informations/components/informationsEdit/editInformation.mutation.ts @@ -4,51 +4,59 @@ import { Information } from "../../type"; import { mapInformation } from "./editInformation.mapping"; import { getElementsToDelete } from "src/lib/mutationUtils"; +import { gql } from "@urql/core"; -export const informationMutation = ` -mutation edit_information( - $upsert: information_informations_insert_input!, - $contentIdsToDelete: [uuid!], - $referenceIdsToDelete: [uuid!], - $contentBlockIdsToDelete: [uuid!], - $contentBlockContentIdsToDelete: [uuid!], - $contentReferenceIdsToDelete: [uuid!] -) { - insert_information_informations_one( - object: $upsert, - on_conflict: { - constraint: informations_pkey, - update_columns: [description,intro, metaTitle, metaDescription,referenceLabel,sectionDisplayMode] - } - ) { - id - } - delete_information_informations_references ( - where: {id: {_in: $referenceIdsToDelete}} - ) { - affectedRows: affected_rows - } - delete_information_informations_contents ( - where: {id: {_in: $contentIdsToDelete}} - ) { - affectedRows: affected_rows - } - delete_information_informations_contents_references ( - where: {id: {_in: $contentReferenceIdsToDelete}} - ) { - affectedRows: affected_rows - } - delete_information_informations_contents_blocks ( - where: {id: {_in: $contentBlockIdsToDelete}} +export const informationMutation = gql` + mutation edit_information( + $upsert: information_informations_insert_input! + $contentIdsToDelete: [uuid!] + $referenceIdsToDelete: [uuid!] + $contentBlockIdsToDelete: [uuid!] + $contentBlockContentIdsToDelete: [uuid!] + $contentReferenceIdsToDelete: [uuid!] ) { - affectedRows: affected_rows - } - delete_information_informations_contents_blocks_contents ( - where: {id: {_in: $contentBlockContentIdsToDelete}} - ) { - affectedRows: affected_rows + delete_information_informations_references( + where: { id: { _in: $referenceIdsToDelete } } + ) { + affectedRows: affected_rows + } + delete_information_informations_contents( + where: { id: { _in: $contentIdsToDelete } } + ) { + affectedRows: affected_rows + } + delete_information_informations_contents_references( + where: { id: { _in: $contentReferenceIdsToDelete } } + ) { + affectedRows: affected_rows + } + delete_information_informations_contents_blocks( + where: { id: { _in: $contentBlockIdsToDelete } } + ) { + affectedRows: affected_rows + } + delete_information_informations_contents_blocks_contents( + where: { id: { _in: $contentBlockContentIdsToDelete } } + ) { + affectedRows: affected_rows + } + insert_information_informations_one( + object: $upsert + on_conflict: { + constraint: informations_pkey + update_columns: [ + description + intro + metaTitle + metaDescription + referenceLabel + sectionDisplayMode + ] + } + ) { + id + } } -} `; export type EditInformationMutationResult = { From ac81d71e89517901a58ae14e26a4729c4993b6ce Mon Sep 17 00:00:00 2001 From: Martial Maillot Date: Fri, 13 Oct 2023 09:17:24 +0200 Subject: [PATCH 4/6] fix: issues with publish --- .../frontend/src/modules/documents/api/documents.service.ts | 1 + .../src/modules/informations/api/informations.query.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/targets/frontend/src/modules/documents/api/documents.service.ts b/targets/frontend/src/modules/documents/api/documents.service.ts index 9267625d1..49345d2d0 100644 --- a/targets/frontend/src/modules/documents/api/documents.service.ts +++ b/targets/frontend/src/modules/documents/api/documents.service.ts @@ -59,6 +59,7 @@ export class DocumentsService { ? { size: block.file?.size, imgUrl: block.img?.url, + altText: block.img?.altText, fileUrl: block.file?.url, } : {}), diff --git a/targets/frontend/src/modules/informations/api/informations.query.ts b/targets/frontend/src/modules/informations/api/informations.query.ts index d5ecb59df..5d40aa509 100644 --- a/targets/frontend/src/modules/informations/api/informations.query.ts +++ b/targets/frontend/src/modules/informations/api/informations.query.ts @@ -25,6 +25,10 @@ export const informationsQuery = gql` content order type + img { + url + altText + } file { id url From 8eca6caf7044fb2087a320d6b230ffd7ab0fecf3 Mon Sep 17 00:00:00 2001 From: Victor Zeinstra Date: Tue, 17 Oct 2023 21:03:03 +0200 Subject: [PATCH 5/6] fix: migration order --- .../up.sql | 5 +- .../1694012383773_migrate_info_page/up.sql | 121 +++++++++--------- .../1696864194045_migration_info_doc/down.sql | 2 - .../1696864194045_migration_info_doc/up.sql | 6 - 4 files changed, 58 insertions(+), 76 deletions(-) delete mode 100644 targets/hasura/migrations/default/1696864194045_migration_info_doc/down.sql delete mode 100644 targets/hasura/migrations/default/1696864194045_migration_info_doc/up.sql diff --git a/targets/hasura/migrations/default/1693836035778_create_table_information_informations/up.sql b/targets/hasura/migrations/default/1693836035778_create_table_information_informations/up.sql index c98bf7fbb..4b3850ff7 100644 --- a/targets/hasura/migrations/default/1693836035778_create_table_information_informations/up.sql +++ b/targets/hasura/migrations/default/1693836035778_create_table_information_informations/up.sql @@ -5,14 +5,11 @@ CREATE TABLE "information"."informations" ( "meta_title" text NOT NULL, "meta_description" text NOT NULL, "description" text NOT NULL, - "cdtn_id" text, "section_display_mode" text NOT NULL default 'accordion', "reference_label" text, "dismissal_process" boolean not null default false, "id" uuid NOT NULL DEFAULT gen_random_uuid(), PRIMARY KEY ("id"), - FOREIGN KEY ("cdtn_id") REFERENCES "public"."documents"("cdtn_id") ON UPDATE restrict ON DELETE restrict, - UNIQUE ("id"), - UNIQUE ("cdtn_id") + UNIQUE ("id") ); CREATE EXTENSION IF NOT EXISTS pgcrypto; diff --git a/targets/hasura/migrations/default/1694012383773_migrate_info_page/up.sql b/targets/hasura/migrations/default/1694012383773_migrate_info_page/up.sql index 05f81c709..1d9030237 100644 --- a/targets/hasura/migrations/default/1694012383773_migrate_info_page/up.sql +++ b/targets/hasura/migrations/default/1694012383773_migrate_info_page/up.sql @@ -16,6 +16,7 @@ with _informations as ( "document"->'references'->0->>'label' as "reference_label" from documents where source = 'information' + and is_published is true ), _informations_inserted as ( insert into "information".informations( @@ -27,8 +28,7 @@ _informations_inserted as ( description, section_display_mode, dismissal_process, - reference_label, - cdtn_id + reference_label ) select updated_at, intro, @@ -41,30 +41,26 @@ _informations_inserted as ( 'accordion' ), dismissal_process, - reference_label, - cdtn_id + reference_label from _informations returning id, - cdtn_id + title ), _informations_references as ( select i.id as informations_id, - l.links->'id' as id, - l.links->>'url' as url, - l.links->>'type' as "type", - l.links->>'title' as title, - row_number() over(partition by i.id) as "order" + l.value->'id' as id, + l.value->>'url' as url, + l.value->>'type' as "type", + l.value->>'title' as title, + l."ordinality" as "order" from ( - select r.cdtn_id, - jsonb_array_elements(r.refs->'links') as "links" - from ( - select cdtn_id, - jsonb_array_elements("references") as refs - from _informations - where jsonb_typeof("references") = 'array' - ) r - ) l - inner join _informations_inserted i on i.cdtn_id = l.cdtn_id + select title, + jsonb_array_elements("references") as refs + from _informations + where jsonb_typeof("references") = 'array' + ) r + cross join jsonb_array_elements(r.refs->'links') WITH ordinality as l + inner join _informations_inserted i on i.title = r.title ), _informations_references_inserted as ( insert into information.informations_references(informations_id, url, "type", title, "order") @@ -78,18 +74,15 @@ _informations_references_inserted as ( ), _informations_contents as ( select i.id as informations_id, - c."content"->>'name' as "name", - c."content"->>'title' as title, - c."content"->'blocks' as blocks, - c."content"->'references' as "references", - c."content"->'references'->0->>'label' as "reference_label", - row_number() over(partition by i.id) as "order" - from ( - select cdtn_id, - jsonb_array_elements(contents) as "content" - from _informations - ) c - inner join _informations_inserted i on i.cdtn_id = c.cdtn_id + c."value"->>'name' as "name", + c."value"->>'title' as title, + c."value"->'blocks' as blocks, + c."value"->'references' as "references", + c."value"->'references'->0->>'label' as "reference_label", + c."ordinality" as "order" + from _informations as d + cross join jsonb_array_elements(d.contents) WITH ordinality as c + inner join _informations_inserted i on i.title = d.title ), _informations_contents_inserted as ( insert into information.informations_contents( @@ -107,7 +100,8 @@ _informations_contents_inserted as ( from _informations_contents returning id, informations_id, - title + title, + "order" ), _informations_contents_references as ( select i.id as informations_contents_id, @@ -115,11 +109,12 @@ _informations_contents_references as ( l.links->>'url' as url, l.links->>'type' as "type", l.links->>'title' as title, - row_number() over(partition by i.id) as "order" + l."order" from ( select title, informations_id, - jsonb_array_elements(r.refs->'links') as "links" + l.value as "links", + l."ordinality" as "order" from ( select title, informations_id, @@ -127,6 +122,7 @@ _informations_contents_references as ( from _informations_contents where jsonb_typeof("references") = 'array' ) r + cross join jsonb_array_elements(r.refs->'links') WITH ordinality as l ) l inner join _informations_contents_inserted i on i.informations_id = l.informations_id and i.title = l.title @@ -149,24 +145,20 @@ _informations_contents_references_inserted as ( ), _informations_contents_blocks as ( select i.id as informations_contents_id, - coalesce(b.block->>'markdown', b.block->>'title') as "content", - b.block->>'type' as "type", - b.block->>'size' as "size", - b.block->>'imgUrl' as "img_url", - b.block->>'fileUrl' as "file_url", - b.block->>'altText' as "alt_text", - b.block->>'blockDisplayMode' as "content_display_mode", - b.block->'contents' as contents, - row_number() over(partition by b.informations_id, b.title) as "order" - from ( - select informations_id, - title, - jsonb_array_elements(blocks) as block - from _informations_contents - where jsonb_typeof(blocks) = 'array' - ) b - inner join _informations_contents_inserted i on i.informations_id = b.informations_id - and i.title = b.title + coalesce(b.value->>'markdown', b.value->>'title') as "content", + b.value->>'type' as "type", + b.value->>'size' as "size", + b.value->>'imgUrl' as "img_url", + b.value->>'fileUrl' as "file_url", + b.value->>'altText' as "alt_text", + b.value->>'blockDisplayMode' as "content_display_mode", + b.value->'contents' as contents, + b."ordinality" as "order" + from _informations_contents ic + cross join jsonb_array_elements(ic.blocks) WITH ordinality as b + inner join _informations_contents_inserted i on i.informations_id = ic.informations_id + and i.title = ic.title + where jsonb_typeof(ic.blocks) = 'array' ), _files as ( select fa.url, @@ -227,18 +219,14 @@ _informations_contents_blocks_inserted as ( "order" ), _informations_contents_blocks_contents as ( - select c."content"->>'cdtnId' as "cdtn_id", + select c."value"->>'cdtnId' as "cdtn_id", i.id as informations_contents_blocks_id, - row_number() over(partition by i.id) as "order" - from ( - select informations_contents_id, - "order", - jsonb_array_elements(contents) as "content" - from _informations_contents_blocks - where jsonb_typeof(contents) = 'array' - ) c - inner join _informations_contents_blocks_inserted i on i.informations_contents_id = c.informations_contents_id - and i."order" = c."order" + c."ordinality" as "order" + from _informations_contents_blocks icb + cross join jsonb_array_elements(icb.contents) WITH ordinality as c + inner join _informations_contents_blocks_inserted i on i.informations_contents_id = icb.informations_contents_id + and i."order" = icb."order" + where jsonb_typeof(icb.contents) = 'array' ) insert into information.informations_contents_blocks_contents( cdtn_id, @@ -249,3 +237,8 @@ select cdtn_id, informations_contents_blocks_id, "order" from _informations_contents_blocks_contents; +update documents +set initial_id = i.id +from information.informations i +where documents."source" = 'information' + and documents.title = i.title; diff --git a/targets/hasura/migrations/default/1696864194045_migration_info_doc/down.sql b/targets/hasura/migrations/default/1696864194045_migration_info_doc/down.sql deleted file mode 100644 index 297c685a4..000000000 --- a/targets/hasura/migrations/default/1696864194045_migration_info_doc/down.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table information.informations -add column "cdtn_id" text; diff --git a/targets/hasura/migrations/default/1696864194045_migration_info_doc/up.sql b/targets/hasura/migrations/default/1696864194045_migration_info_doc/up.sql deleted file mode 100644 index 697ad1610..000000000 --- a/targets/hasura/migrations/default/1696864194045_migration_info_doc/up.sql +++ /dev/null @@ -1,6 +0,0 @@ -update documents -set initial_id = i.id -from information.informations i -where documents."source" = 'information' - and documents.title = i.title; -alter table information.informations drop column cdtn_id; From 3406a872e2a109c0e6dcca105078ed5e35075c7e Mon Sep 17 00:00:00 2001 From: Victor Zeinstra Date: Thu, 19 Oct 2023 11:05:30 +0200 Subject: [PATCH 6/6] chore: clean --- targets/frontend/src/modules/documents/api/documents.query.ts | 2 -- targets/frontend/src/modules/documents/api/documents.service.ts | 2 -- 2 files changed, 4 deletions(-) diff --git a/targets/frontend/src/modules/documents/api/documents.query.ts b/targets/frontend/src/modules/documents/api/documents.query.ts index db770568e..10cca57a9 100644 --- a/targets/frontend/src/modules/documents/api/documents.query.ts +++ b/targets/frontend/src/modules/documents/api/documents.query.ts @@ -34,7 +34,6 @@ export const queryDocument = async ( client: ApiClient, variables: DocumentsQueryProps ): Promise => { - console.log("queryDocument", query, variables); const { data: result, error } = await client.query( query, variables @@ -43,7 +42,6 @@ export const queryDocument = async ( console.log(error); throw error; } - console.log("result", result); const data = result?.documents[0]; return data; diff --git a/targets/frontend/src/modules/documents/api/documents.service.ts b/targets/frontend/src/modules/documents/api/documents.service.ts index 49345d2d0..bf8cc6731 100644 --- a/targets/frontend/src/modules/documents/api/documents.service.ts +++ b/targets/frontend/src/modules/documents/api/documents.service.ts @@ -95,12 +95,10 @@ export class DocumentsService { } public async publish(id: string, source: string) { - console.log("id", id); let document = await this.documentsRepository.fetch({ source, initialId: id, }); - console.log("currentDoc", document); switch (source) { case "information": default: