From 525bb143481cebdeb50aa41c7a0f24cad37b3416 Mon Sep 17 00:00:00 2001 From: Daniel Andreasen Date: Thu, 28 Nov 2024 07:58:32 +0100 Subject: [PATCH] Add status true condition Also adds some comments, since the queries are copied from itk-ai/loop_vectorstore develop branch --- .../export_document_collections_with_meta.sql | 53 ++-- data-export/export_documents_with_meta.sql | 290 ++++++++++-------- data-export/export_external_with_meta.sql | 33 +- .../export_folding_parts_of_documents.sql | 72 ++--- data-export/export_news_posts_with_meta.sql | 31 +- data-export/export_q_and_a_with_meta.sql | 147 ++++----- data-export/export_static_pages_with_meta.sql | 89 +++--- 7 files changed, 381 insertions(+), 334 deletions(-) diff --git a/data-export/export_document_collections_with_meta.sql b/data-export/export_document_collections_with_meta.sql index 37fa64579..7cec356c5 100644 --- a/data-export/export_document_collections_with_meta.sql +++ b/data-export/export_document_collections_with_meta.sql @@ -1,4 +1,4 @@ -Select +Select n_fd.nid, n_fd.type, n_fd.title, @@ -10,24 +10,25 @@ Select docscol_content.os2loop_documents_dc_content_value as content, -- all format are rich text (html and div encoded) docs_ib.os2loop_documents_info_box_value as info_box, approval_date.os2loop_shared_approval_date_value as approval_date, - `subject`.`name` as `subject`, - tags.tags, - `owner`.os2loop_shared_owner_value as `owner`, + `subject`.`name` as `subject`, -- subjects are from curated list + tags.tags, -- authors can add any tags they like + -- `owner`.os2loop_shared_owner_value as `owner`, -- should not be exported, can be found by url reference if end user have a need and has access rights rev_date.os2loop_shared_rev_date_value as review_date, `version`.os2loop_shared_version_value as `version` from ( - SELECT nid,vid,type,uid,title,created,changed + SELECT nid,vid,type,uid,title,created,changed FROM node_field_data where type = 'os2loop_documents_collection' -- the table os2loop_documents_collection_item associate document collections (their nid on collection_id) - -- to documents (document_id = nid) except for 20 document collections. Fx case /rammedelegation nid=3807 it is a collection of - -- links to sharepoint docs and /medicinhaandtering nid=3827 is a link to the collection + -- to documents (document_id = nid) except for 20 document collections. Fx case /rammedelegation nid=3807 it is a collection of + -- links to sharepoint docs and /medicinhaandtering nid=3827 is a link to the collection -- /instruks-korrekt-haandtering-af-medicin-i-sundhed-og-omsorg-mso nid 4188 -- of 805 documents 164 documents are not assigned to a document_collection + and status = 1 ) as n_fd left join path_alias as pa on CONCAT('/node/',n_fd.nid) = pa.path left join ( - SELECT + SELECT doc_col_itm.collection_id, json_arrayagg(doc_col_itm.document_id) as document_node_ids, json_arrayagg(pa.`alias`) as document_relative_urls @@ -38,26 +39,26 @@ left join ( left join node__os2loop_documents_dc_content as docscol_content on n_fd.nid = docscol_content.entity_id -- contains only records from bundle documents_collection (all delta 0, so top placement) left join ( SELECT - entity_id, - os2loop_documents_info_box_value - FROM node__os2loop_documents_info_box + entity_id, + os2loop_documents_info_box_value + FROM node__os2loop_documents_info_box WHERE bundle = 'os2loop_documents_collection') as docs_ib on n_fd.nid = docs_ib.entity_id -- only from bundle document_collection left join node__os2loop_shared_approval_date as approval_date on n_fd.nid = approval_date.entity_id left join ( - SELECT - n_ss.entity_id, - subject_tt_fd.name - FROM node__os2loop_shared_subject as n_ss - left join taxonomy_term_field_data as subject_tt_fd on n_ss.os2loop_shared_subject_target_id = subject_tt_fd.tid - where n_ss.bundle = 'os2loop_documents_collection') as `subject` on n_fd.nid = `subject`.entity_id -left join node__os2loop_shared_owner as `owner` on n_fd.nid = `owner`.entity_id + SELECT + n_ss.entity_id, + subject_tt_fd.name + FROM node__os2loop_shared_subject as n_ss + left join taxonomy_term_field_data as subject_tt_fd on n_ss.os2loop_shared_subject_target_id = subject_tt_fd.tid + where n_ss.bundle = 'os2loop_documents_collection') as `subject` on n_fd.nid = `subject`.entity_id +-- left join node__os2loop_shared_owner as `owner` on n_fd.nid = `owner`.entity_id -- see comment in select left join node__os2loop_shared_rev_date as rev_date on n_fd.nid = rev_date.entity_id left join ( - SELECT - n_st.entity_id, - json_arrayagg(tt_fd.name) as tags - FROM node__os2loop_shared_tags as n_st - left join taxonomy_term_field_data as tt_fd on n_st.os2loop_shared_tags_target_id = tt_fd.tid - where n_st.bundle = 'os2loop_documents_collection' - group by n_st.entity_id) tags on n_fd.nid = tags.entity_id -left join node__os2loop_shared_version as `version` on n_fd.nid = `version`.entity_id + SELECT + n_st.entity_id, + json_arrayagg(tt_fd.name) as tags + FROM node__os2loop_shared_tags as n_st + left join taxonomy_term_field_data as tt_fd on n_st.os2loop_shared_tags_target_id = tt_fd.tid + where n_st.bundle = 'os2loop_documents_collection' + group by n_st.entity_id) tags on n_fd.nid = tags.entity_id +left join node__os2loop_shared_version as `version` on n_fd.nid = `version`.entity_id \ No newline at end of file diff --git a/data-export/export_documents_with_meta.sql b/data-export/export_documents_with_meta.sql index 16811ee65..fa79958ea 100644 --- a/data-export/export_documents_with_meta.sql +++ b/data-export/export_documents_with_meta.sql @@ -1,11 +1,52 @@ -Select +Select n_fd.nid, -- n_fd.type, n_fd.title, pa.`alias` as relative_url, DATE_FORMAT(FROM_UNIXTIME(n_fd.created), '%Y-%m-%dT%H:%i:%s') as created, DATE_FORMAT(FROM_UNIXTIME(n_fd.changed), '%Y-%m-%dT%H:%i:%s') as `changed`, - doc_author.os2loop_documents_document_autho_value as document_author, -- is this okay to share, here we name person, not just orgs + -- doc_author.os2loop_documents_document_autho_value as document_author, -- after meeting with Lasse Skjalms it is decided not to export, as end user can access this info fra url, if they + -- have appropriate rights, but it names persons, which makes it harder to share the exported data + -- general authors are: + -- Cura Book + -- Digitalisering + -- Digitalisering og Kvalitet, MSO + -- "Personnavn", Digitalisering + -- "Personnavn"; Digitalisering + -- "Personnavn" - SUE Område Marselisborg, "Personnavn" - SUE Område Marselisborg, "Personnavn" - SOL, "Personnavn" - SOL, "Personnavn" - SOL, "Personnavn" og "Personnavn" - Digitalisering + -- "Personnavn" - SUE Område Marselisborg, "Personnavn" - SOL, "Personnavn" - SOL, Digitalisering + -- "Personnavn", Digitalisering + -- "Personnavn", Digitalisering + -- Digitalisering og Kvalitet + -- "Personnavn", Digitaliseringen + -- Digtalisering + -- Digitalisering - "Personnavn" + -- Akuttilbud og Rehabilitering + -- Kvalitet og Borgersikkerhed + -- Digitaliseringen + -- Digitalisering og Kvalitet, Sygeplejeklyngen + -- "Personnavn", Digitalisering + -- "Personnavn" - Digitalisering + -- Digitalisering. + -- Område Christiansbjerg og Kvalitet og Borgersikkerhed + -- Digitalisering & kvalitet + -- Medarbejdere i SOL + -- Velfærdsteknologi + -- Medarbejder i SOL + -- Følgegruppen for medicin + -- Borgervelfærd + -- Velfærdssteknologi + -- Digitalisering Kvalitet + -- Digitalisering og Kvalitet. + -- Demensklyngen + -- Demensklyngen ("Personnavn") + -- Demensklyngen ("Personnavn") + -- Nissen + -- Digitalisering og Kvalitet, Grøndalsvej 2 + -- Klyngen for sygepleje + -- "Personnavn" - enhed for måltider og ernæring + -- Sygeplejeklyngen + -- "Personnavn" doc_body.os2loop_documents_document_body_value as document_body, -- all delta is zero doc_content.content, -- when 'content_type' is os2loop_documents_step_by_step the JSON object should be replaced by the corresponding folding_part entity depending on the content_target_id, otherwise the field can be removed `subject`.`name` as `subject`, @@ -14,142 +55,143 @@ Select rev_date.os2loop_shared_rev_date_value as review_date, `version`.os2loop_shared_version_value as `version` from ( - SELECT nid,vid,type,uid,title,created,changed + SELECT nid,vid,type,uid,title,created,changed FROM node_field_data where `type` = 'os2loop_documents_document' + and status = 1 ) as n_fd left join path_alias as pa on CONCAT('/node/',n_fd.nid) = pa.path -left join node__os2loop_documents_document_autho as doc_author on n_fd.nid = doc_author.entity_id +-- left join node__os2loop_documents_document_autho as doc_author on n_fd.nid = doc_author.entity_id -- see comment in select left join node__os2loop_documents_document_body as doc_body on n_fd.nid = doc_body.entity_id -- group by n_fd.nid -- returns 701 records left join ( - SELECT - n_ddc.entity_id, - -- ANY_VALUE(para_ifd.parent_field_name) as parent_field_name, - json_arrayagg(json_object( - 'delta', n_ddc.delta, + SELECT + n_ddc.entity_id, + -- ANY_VALUE(para_ifd.parent_field_name) as parent_field_name, + json_arrayagg(json_object( + 'delta', n_ddc.delta, 'paragraph_title', doc_title.os2loop_documents_title_value, -- all delta is zero - 'paragraph_description', IFNull(doc_desc.os2loop_documents_description_value, IFNULL(tbl.os2loop_documents_tbl_desc_value, video.os2loop_video_description_value)), - 'paragraph', IFNull(doc_hc.os2loop_documents_hc_content_value, IFNull(text_and_image.os2loop_documents_tai_text_value, tbl.os2loop_documents_tbl_cont_value)), - 'content', json_object('content_target_id', n_ddc.os2loop_documents_document_conte_target_id, - 'content_type', para_ifd.`type` + 'paragraph_description', IFNull(doc_desc.os2loop_documents_description_value, IFNULL(tbl.os2loop_documents_tbl_desc_value, video.os2loop_video_description_value)), + 'paragraph', IFNull(doc_hc.os2loop_documents_hc_content_value, IFNull(text_and_image.os2loop_documents_tai_text_value, tbl.os2loop_documents_tbl_cont_value)), + 'content', json_object('content_target_id', n_ddc.os2loop_documents_document_conte_target_id, + 'content_type', para_ifd.`type` ), -- when 'content_type' is os2loop_documents_step_by_step the JSON object should be replaced by the corresponding folding_part entity depending on the content_target_id, otherwise the field can be removed - 'text_and_image_position', text_and_image.os2loop_documents_tai_position_value, + 'text_and_image_position', text_and_image.os2loop_documents_tai_position_value, 'media', json_object('uri', IFNull(text_and_image.uri, video.os2loop_video_url_uri), - 'filemime', text_and_image.filemime, - 'filesize', text_and_image.filesize, - 'created', DATE_FORMAT(FROM_UNIXTIME(text_and_image.created), '%Y-%m-%dT%H:%i:%s'), - 'changed', DATE_FORMAT(FROM_UNIXTIME(text_and_image.`changed`), '%Y-%m-%dT%H:%i:%s'), - 'video_title', video.os2loop_video_title_value, - 'video_iframe', video.os2loop_video_iframe_value - ) - )) as content + 'filemime', text_and_image.filemime, + 'filesize', text_and_image.filesize, + 'created', DATE_FORMAT(FROM_UNIXTIME(text_and_image.created), '%Y-%m-%dT%H:%i:%s'), + 'changed', DATE_FORMAT(FROM_UNIXTIME(text_and_image.`changed`), '%Y-%m-%dT%H:%i:%s'), + 'video_title', video.os2loop_video_title_value, + 'video_iframe', video.os2loop_video_iframe_value + ) + )) as content FROM node__os2loop_documents_document_conte as n_ddc left join paragraphs_item_field_data as para_ifd on n_ddc.os2loop_documents_document_conte_target_id = para_ifd.id - left join paragraph__os2loop_documents_hc_content as doc_hc on n_ddc.os2loop_documents_document_conte_target_id = doc_hc.entity_id - left join ( - WITH media_attachments AS (SELECT - media_collected.mid, - fm.uri, -- where public:// -> https://loop.sundhedogomsorg.dk/sites/loop.sundhedogomsorg.dk/files/ - fm.filemime, - fm.filesize, - fm.created, - fm.changed - FROM (SELECT - m_fd.mid, - IFNULL (m_mf.field_media_file_target_id, m_mi.field_media_image_target_id) as target_id - from media_field_data as m_fd - left join media__field_media_file as m_mf on m_fd.mid = m_mf.entity_id -- remember dep on m_fd.bundle whether it should be media__field_media_file, media__field_media_image or media__field_media_library we need to join on - left join media__field_media_image as m_mi on m_fd.mid = m_mi.entity_id - -- left join media__field_media_library as m_ml on m_fd.mid = m_ml.entity_id -- turns out the media_library is not the correct reference for the file_managed table - ) as media_collected - left join file_managed as fm on media_collected.target_id = fm.fid) - SELECT - tai_pos.bundle, - tai_pos.deleted, - tai_pos.entity_id, - tai_pos.revision_id, - tai_pos.langcode, - tai_pos.delta, - tai_pos.os2loop_documents_tai_position_value, - tai_text.os2loop_documents_tai_text_value, - tai_text.os2loop_documents_tai_text_format, - tai_image.os2loop_documents_tai_image_target_id, - media_attachments.uri, - media_attachments.filemime, - media_attachments.filesize, - media_attachments.created, - media_attachments.`changed` - FROM paragraph__os2loop_documents_tai_position as tai_pos - left join paragraph__os2loop_documents_tai_text as tai_text on tai_pos.entity_id = tai_text.entity_id - -- where tai_pos.bundle != tai_text.bundle -- none - -- where tai_pos.entity_id != tai_text.entity_id -- none - -- where tai_pos.delta != tai_text.delta -- none - left join paragraph__os2loop_documents_tai_image as tai_image on tai_pos.entity_id = tai_image.entity_id - -- where tai_pos.bundle != tai_image.bundle -- none - -- where tai_pos.entity_id != tai_image.entity_id -- none - -- where tai_pos.delta != tai_image.delta -- none - -- where !isnull(tai_text.os2loop_documents_tai_text_format) -- 113 records - like numbner of records in tai_text - -- where !isnull(tai_image.os2loop_documents_tai_image_target_id) -- 60 records - like numbner of records in tai_image - left join media_attachments on tai_image.os2loop_documents_tai_image_target_id = media_attachments.mid - ) as text_and_image on n_ddc.os2loop_documents_document_conte_target_id = text_and_image.entity_id - left join ( - SELECT - video_src.bundle, - video_src.entity_id, - video_src.delta, - video_title.os2loop_video_title_value, - video_desc.os2loop_video_description_value, - video_ifrm.os2loop_video_iframe_value, - video_url.os2loop_video_url_uri, - -- video_url.os2loop_video_url_title -- all empty so far - -- Convert(video_url.os2loop_video_url_options, CHAR(255)), -- nothing interesting so far (all contains "a:0:{}") - video_width.os2loop_video_width_value - FROM paragraph__os2loop_video_source_type as video_src -- so far all sources are url - left join paragraph__os2loop_video_description as video_desc on video_src.entity_id = video_desc.entity_id - left join paragraph__os2loop_video_iframe as video_ifrm on video_src.entity_id = video_ifrm.entity_id - left join paragraph__os2loop_video_title as video_title on video_src.entity_id = video_title.entity_id - left join paragraph__os2loop_video_url as video_url on video_src.entity_id = video_url.entity_id - left join paragraph__os2loop_video_width as video_width on video_src.entity_id = video_width.entity_id - ) as video on n_ddc.os2loop_documents_document_conte_target_id = video.entity_id - -- where para_ifd.type = 'os2loop_video' -- returns 10 of 14 video records - left join ( - SELECT - tbl_content.bundle, - tbl_content.entity_id, - tbl_content.delta, - tbl_content.os2loop_documents_tbl_cont_value, - tbl_content.os2loop_documents_tbl_cont_format, - tbl_desc.os2loop_documents_tbl_desc_value - FROM paragraph__os2loop_documents_tbl_cont as tbl_content - left join paragraph__os2loop_documents_tbl_desc as tbl_desc on tbl_content.entity_id = tbl_desc.entity_id - ) as tbl on n_ddc.os2loop_documents_document_conte_target_id = tbl.entity_id - -- where para_ifd.`type` = 'os2loop_documents_table' -- returns 3 of 16 records - left join `paragraph__os2loop_documents_title` as doc_title on n_ddc.os2loop_documents_document_conte_target_id = doc_title.entity_id - left join paragraph__os2loop_documents_description as doc_desc on n_ddc.os2loop_documents_document_conte_target_id = doc_desc.entity_id -- all para doc desc relates to bundle step_by_step - -- we miss content on step by step paragraphs, (we only have description so far) this must be added post querying using the dedicated query export_folding_parts_of_documents after it have been post-processed by the preprocess_loop_document_folding_parts.py - -- we ignore table of contents as this does not add any additional information conveying text - where para_ifd.`type` not in ( - 'table_of_contents' -- this leaves out 3 records - ) - group by n_ddc.entity_id - ) as doc_content on n_fd.nid = doc_content.entity_id + left join paragraph__os2loop_documents_hc_content as doc_hc on n_ddc.os2loop_documents_document_conte_target_id = doc_hc.entity_id + left join ( + WITH media_attachments AS (SELECT + media_collected.mid, + fm.uri, -- where public:// -> https://loop.sundhedogomsorg.dk/sites/loop.sundhedogomsorg.dk/files/ + fm.filemime, + fm.filesize, + fm.created, + fm.changed + FROM (SELECT + m_fd.mid, + IFNULL (m_mf.field_media_file_target_id, m_mi.field_media_image_target_id) as target_id + from media_field_data as m_fd + left join media__field_media_file as m_mf on m_fd.mid = m_mf.entity_id -- remember dep on m_fd.bundle whether it should be media__field_media_file, media__field_media_image or media__field_media_library we need to join on + left join media__field_media_image as m_mi on m_fd.mid = m_mi.entity_id + -- left join media__field_media_library as m_ml on m_fd.mid = m_ml.entity_id -- turns out the media_library is not the correct reference for the file_managed table + ) as media_collected + left join file_managed as fm on media_collected.target_id = fm.fid) + SELECT + tai_pos.bundle, + tai_pos.deleted, + tai_pos.entity_id, + tai_pos.revision_id, + tai_pos.langcode, + tai_pos.delta, + tai_pos.os2loop_documents_tai_position_value, + tai_text.os2loop_documents_tai_text_value, + tai_text.os2loop_documents_tai_text_format, + tai_image.os2loop_documents_tai_image_target_id, + media_attachments.uri, + media_attachments.filemime, + media_attachments.filesize, + media_attachments.created, + media_attachments.`changed` + FROM paragraph__os2loop_documents_tai_position as tai_pos + left join paragraph__os2loop_documents_tai_text as tai_text on tai_pos.entity_id = tai_text.entity_id + -- where tai_pos.bundle != tai_text.bundle -- none + -- where tai_pos.entity_id != tai_text.entity_id -- none + -- where tai_pos.delta != tai_text.delta -- none + left join paragraph__os2loop_documents_tai_image as tai_image on tai_pos.entity_id = tai_image.entity_id + -- where tai_pos.bundle != tai_image.bundle -- none + -- where tai_pos.entity_id != tai_image.entity_id -- none + -- where tai_pos.delta != tai_image.delta -- none + -- where !isnull(tai_text.os2loop_documents_tai_text_format) -- 113 records - like numbner of records in tai_text + -- where !isnull(tai_image.os2loop_documents_tai_image_target_id) -- 60 records - like numbner of records in tai_image + left join media_attachments on tai_image.os2loop_documents_tai_image_target_id = media_attachments.mid + ) as text_and_image on n_ddc.os2loop_documents_document_conte_target_id = text_and_image.entity_id + left join ( + SELECT + video_src.bundle, + video_src.entity_id, + video_src.delta, + video_title.os2loop_video_title_value, + video_desc.os2loop_video_description_value, + video_ifrm.os2loop_video_iframe_value, + video_url.os2loop_video_url_uri, + -- video_url.os2loop_video_url_title -- all empty so far + -- Convert(video_url.os2loop_video_url_options, CHAR(255)), -- nothing interesting so far (all contains "a:0:{}") + video_width.os2loop_video_width_value + FROM paragraph__os2loop_video_source_type as video_src -- so far all sources are url + left join paragraph__os2loop_video_description as video_desc on video_src.entity_id = video_desc.entity_id + left join paragraph__os2loop_video_iframe as video_ifrm on video_src.entity_id = video_ifrm.entity_id + left join paragraph__os2loop_video_title as video_title on video_src.entity_id = video_title.entity_id + left join paragraph__os2loop_video_url as video_url on video_src.entity_id = video_url.entity_id + left join paragraph__os2loop_video_width as video_width on video_src.entity_id = video_width.entity_id + ) as video on n_ddc.os2loop_documents_document_conte_target_id = video.entity_id + -- where para_ifd.type = 'os2loop_video' -- returns 10 of 14 video records + left join ( + SELECT + tbl_content.bundle, + tbl_content.entity_id, + tbl_content.delta, + tbl_content.os2loop_documents_tbl_cont_value, + tbl_content.os2loop_documents_tbl_cont_format, + tbl_desc.os2loop_documents_tbl_desc_value + FROM paragraph__os2loop_documents_tbl_cont as tbl_content + left join paragraph__os2loop_documents_tbl_desc as tbl_desc on tbl_content.entity_id = tbl_desc.entity_id + ) as tbl on n_ddc.os2loop_documents_document_conte_target_id = tbl.entity_id + -- where para_ifd.`type` = 'os2loop_documents_table' -- returns 3 of 16 records + left join `local_loop`.`paragraph__os2loop_documents_title` as doc_title on n_ddc.os2loop_documents_document_conte_target_id = doc_title.entity_id + left join paragraph__os2loop_documents_description as doc_desc on n_ddc.os2loop_documents_document_conte_target_id = doc_desc.entity_id -- all para doc desc relates to bundle step_by_step + -- we miss content on step by step paragraphs, (we only have description so far) this must be added post querying using the dedicated query export_folding_parts_of_documents after it have been post-processed by the preprocess_loop_document_folding_parts.py + -- we ignore table of contents as this does not add any additional information conveying text + where para_ifd.`type` not in ( + 'table_of_contents' -- this leaves out 3 records + ) + group by n_ddc.entity_id + ) as doc_content on n_fd.nid = doc_content.entity_id -- where ((not ISNULL(doc_body.os2loop_documents_document_body_value)) and not ISNULL(n_ddc.os2loop_documents_document_conte_target_id)) -- returns 13 records, where 3 (maybe 4) records seems to have both relevant body and content left join node__os2loop_shared_approval_date as approval_date on n_fd.nid = approval_date.entity_id left join ( - SELECT - n_ss.entity_id, - subject_tt_fd.name - FROM node__os2loop_shared_subject as n_ss - left join taxonomy_term_field_data as subject_tt_fd on n_ss.os2loop_shared_subject_target_id = subject_tt_fd.tid - where n_ss.bundle = 'os2loop_documents_document') as `subject` on n_fd.nid = `subject`.entity_id + SELECT + n_ss.entity_id, + subject_tt_fd.name + FROM node__os2loop_shared_subject as n_ss + left join taxonomy_term_field_data as subject_tt_fd on n_ss.os2loop_shared_subject_target_id = subject_tt_fd.tid + where n_ss.bundle = 'os2loop_documents_document') as `subject` on n_fd.nid = `subject`.entity_id left join ( - SELECT - n_st.entity_id, - json_arrayagg(tt_fd.name) as tags - FROM node__os2loop_shared_tags as n_st - left join taxonomy_term_field_data as tt_fd on n_st.os2loop_shared_tags_target_id = tt_fd.tid - where n_st.bundle = 'os2loop_documents_document' - group by n_st.entity_id) tags on n_fd.nid = tags.entity_id + SELECT + n_st.entity_id, + json_arrayagg(tt_fd.name) as tags + FROM node__os2loop_shared_tags as n_st + left join taxonomy_term_field_data as tt_fd on n_st.os2loop_shared_tags_target_id = tt_fd.tid + where n_st.bundle = 'os2loop_documents_document' + group by n_st.entity_id) tags on n_fd.nid = tags.entity_id left join node__os2loop_shared_rev_date as rev_date on n_fd.nid = rev_date.entity_id -left join node__os2loop_shared_version as `version` on n_fd.nid = `version`.entity_id +left join node__os2loop_shared_version as `version` on n_fd.nid = `version`.entity_id \ No newline at end of file diff --git a/data-export/export_external_with_meta.sql b/data-export/export_external_with_meta.sql index fdfff75af..f40105e43 100644 --- a/data-export/export_external_with_meta.sql +++ b/data-export/export_external_with_meta.sql @@ -1,4 +1,4 @@ -Select +Select n_fd.nid, n_fd.type, n_fd.title, @@ -15,27 +15,28 @@ Select tags.tags, rev_date.os2loop_shared_rev_date_value as review_date from ( - SELECT nid,vid,type,uid,title,created,changed + SELECT nid,vid,type,uid,title,created,changed FROM node_field_data where type = 'os2loop_external' -- nodes with links/external references (it seems) + and status = 1 ) as n_fd left join path_alias as pa on CONCAT('/node/',n_fd.nid) = pa.path left join user__os2loop_user_job_title as u_jt on n_fd.uid = u_jt.entity_id left join node__os2loop_external_descripti as ext_desc on n_fd.nid = ext_desc.entity_id left join node__os2loop_external_url as ext_url on n_fd.nid = ext_url.entity_id left join ( - SELECT - n_ss.entity_id, - subject_tt_fd.name - FROM node__os2loop_shared_subject as n_ss - left join taxonomy_term_field_data as subject_tt_fd on n_ss.os2loop_shared_subject_target_id = subject_tt_fd.tid - where n_ss.bundle = 'os2loop_external') as `subject` on n_fd.nid = `subject`.entity_id + SELECT + n_ss.entity_id, + subject_tt_fd.name + FROM node__os2loop_shared_subject as n_ss + left join taxonomy_term_field_data as subject_tt_fd on n_ss.os2loop_shared_subject_target_id = subject_tt_fd.tid + where n_ss.bundle = 'os2loop_external') as `subject` on n_fd.nid = `subject`.entity_id left join ( - SELECT - n_st.entity_id, - json_arrayagg(tt_fd.name) as tags - FROM node__os2loop_shared_tags as n_st - left join taxonomy_term_field_data as tt_fd on n_st.os2loop_shared_tags_target_id = tt_fd.tid - where n_st.bundle = 'os2loop_external' - group by n_st.entity_id) tags on n_fd.nid = tags.entity_id -left join node__os2loop_shared_rev_date as rev_date on n_fd.nid = rev_date.entity_id + SELECT + n_st.entity_id, + json_arrayagg(tt_fd.name) as tags + FROM node__os2loop_shared_tags as n_st + left join taxonomy_term_field_data as tt_fd on n_st.os2loop_shared_tags_target_id = tt_fd.tid + where n_st.bundle = 'os2loop_external' + group by n_st.entity_id) tags on n_fd.nid = tags.entity_id +left join node__os2loop_shared_rev_date as rev_date on n_fd.nid = rev_date.entity_id \ No newline at end of file diff --git a/data-export/export_folding_parts_of_documents.sql b/data-export/export_folding_parts_of_documents.sql index d83ddd2a6..657e44a8b 100644 --- a/data-export/export_folding_parts_of_documents.sql +++ b/data-export/export_folding_parts_of_documents.sql @@ -1,5 +1,5 @@ -SELECT - steps.bundle as step_bundle, +SELECT + steps.bundle as step_bundle, steps.entity_id, steps.delta, steps.os2loop_documents_steps_target_id as step_target_id, @@ -8,47 +8,47 @@ SELECT step_text.delta as text_delta, step_text.os2loop_documents_step_text_value, -- step_text.os2loop_documents_step_text_format, - -- step_image.bundle as image_bundle, - step_image.delta as image_delta, - step_image.uri, - step_image.filemime, - step_image.filesize, + -- step_image.bundle as image_bundle, + step_image.delta as image_delta, + step_image.uri, + step_image.filemime, + step_image.filesize, DATE_FORMAT(FROM_UNIXTIME(step_image.created), '%Y-%m-%dT%H:%i:%s') as created, DATE_FORMAT(FROM_UNIXTIME(step_image.`changed`), '%Y-%m-%dT%H:%i:%s') as `changed` from paragraph__os2loop_documents_steps as steps left join paragraph__os2loop_documents_step_title as step_title on steps.os2loop_documents_steps_target_id = step_title.entity_id -- contains 682 records, but only 617 records are join, so there might be some problem left join paragraph__os2loop_documents_step_text as step_text on steps.os2loop_documents_steps_target_id = step_text.entity_id -- bundle are only os2loop_documents_step, contains 620 reconds, but only 558 are joined left join ( - WITH media_attachments AS (SELECT - media_collected.mid, - fm.uri, -- where public:// -> https://loop.sundhedogomsorg.dk/sites/loop.sundhedogomsorg.dk/files/ - fm.filemime, - fm.filesize, - fm.created, - fm.changed - FROM (SELECT - m_fd.mid, - -- IFNULL (m_mf.field_media_file_target_id, IFNULL(m_mi.field_media_image_target_id, m_ml.field_media_library_target_id)) as target_id + WITH media_attachments AS (SELECT + media_collected.mid, + fm.uri, -- where public:// -> https://loop.sundhedogomsorg.dk/sites/loop.sundhedogomsorg.dk/files/ + fm.filemime, + fm.filesize, + fm.created, + fm.changed + FROM (SELECT + m_fd.mid, + -- IFNULL (m_mf.field_media_file_target_id, IFNULL(m_mi.field_media_image_target_id, m_ml.field_media_library_target_id)) as target_id IFNULL (m_mf.field_media_file_target_id, m_mi.field_media_image_target_id) as target_id - from media_field_data as m_fd - left join media__field_media_file as m_mf on m_fd.mid = m_mf.entity_id -- remember dep on m_fd.bundle whether it should be media__field_media_file, media__field_media_image or media__field_media_library we need to join on - left join media__field_media_image as m_mi on m_fd.mid = m_mi.entity_id - -- left join media__field_media_library as m_ml on m_fd.mid = m_ml.entity_id + from media_field_data as m_fd + left join media__field_media_file as m_mf on m_fd.mid = m_mf.entity_id -- remember dep on m_fd.bundle whether it should be media__field_media_file, media__field_media_image or media__field_media_library we need to join on + left join media__field_media_image as m_mi on m_fd.mid = m_mi.entity_id + -- left join media__field_media_library as m_ml on m_fd.mid = m_ml.entity_id ) as media_collected - left join file_managed as fm on media_collected.target_id = fm.fid) - SELECT - step_image.bundle, - -- step_image.deleted, - step_image.entity_id, - -- step_image.revision_id, - -- step_image.langcode, - step_image.delta, + left join file_managed as fm on media_collected.target_id = fm.fid) + SELECT + step_image.bundle, + -- step_image.deleted, + step_image.entity_id, + -- step_image.revision_id, + -- step_image.langcode, + step_image.delta, -- step_image.os2loop_documents_step_image_target_id, - media_attachments.uri, - media_attachments.filemime, - media_attachments.filesize, - media_attachments.created, - media_attachments.`changed` - FROM paragraph__os2loop_documents_step_image as step_image - left join media_attachments on step_image.os2loop_documents_step_image_target_id = media_attachments.mid + media_attachments.uri, + media_attachments.filemime, + media_attachments.filesize, + media_attachments.created, + media_attachments.`changed` + FROM paragraph__os2loop_documents_step_image as step_image + left join media_attachments on step_image.os2loop_documents_step_image_target_id = media_attachments.mid ) as step_image on steps.os2loop_documents_steps_target_id = step_image.entity_id diff --git a/data-export/export_news_posts_with_meta.sql b/data-export/export_news_posts_with_meta.sql index 8b84c43b1..f719f1ab5 100644 --- a/data-export/export_news_posts_with_meta.sql +++ b/data-export/export_news_posts_with_meta.sql @@ -1,4 +1,4 @@ -Select +Select n_fd.nid, n_fd.type, n_fd.title, @@ -11,26 +11,27 @@ Select `subject`.`name` as `subject`, tags.tags from ( - SELECT nid,vid,type,uid,title,created,changed + SELECT nid,vid,type,uid,title,created,changed FROM node_field_data where type = 'os2loop_post' -- nyheder/indlæg + and status = 1 ) as n_fd left join path_alias as pa on CONCAT('/node/',n_fd.nid) = pa.path -- left join node__os2loop_documents_document_autho as doc_author on n_fd.nid = doc_author.entity_id -- left join node__os2loop_documents_document_body as doc_body on n_fd.nid = doc_body.entity_id left join node__os2loop_post_content as post_cont on n_fd.nid = post_cont.entity_id left join ( - SELECT - n_ss.entity_id, - subject_tt_fd.name - FROM node__os2loop_shared_subject as n_ss - left join taxonomy_term_field_data as subject_tt_fd on n_ss.os2loop_shared_subject_target_id = subject_tt_fd.tid - where n_ss.bundle = 'os2loop_post') as `subject` on n_fd.nid = `subject`.entity_id + SELECT + n_ss.entity_id, + subject_tt_fd.name + FROM node__os2loop_shared_subject as n_ss + left join taxonomy_term_field_data as subject_tt_fd on n_ss.os2loop_shared_subject_target_id = subject_tt_fd.tid + where n_ss.bundle = 'os2loop_post') as `subject` on n_fd.nid = `subject`.entity_id left join ( - SELECT - n_st.entity_id, - json_arrayagg(tt_fd.name) as tags - FROM node__os2loop_shared_tags as n_st - left join taxonomy_term_field_data as tt_fd on n_st.os2loop_shared_tags_target_id = tt_fd.tid - where n_st.bundle = 'os2loop_post' - group by n_st.entity_id) tags on n_fd.nid = tags.entity_id; + SELECT + n_st.entity_id, + json_arrayagg(tt_fd.name) as tags + FROM node__os2loop_shared_tags as n_st + left join taxonomy_term_field_data as tt_fd on n_st.os2loop_shared_tags_target_id = tt_fd.tid + where n_st.bundle = 'os2loop_post' + group by n_st.entity_id) tags on n_fd.nid = tags.entity_id; \ No newline at end of file diff --git a/data-export/export_q_and_a_with_meta.sql b/data-export/export_q_and_a_with_meta.sql index 1a4168b31..f7e321a1a 100644 --- a/data-export/export_q_and_a_with_meta.sql +++ b/data-export/export_q_and_a_with_meta.sql @@ -1,68 +1,68 @@ WITH media_attachments AS (SELECT - media_collected.mid, - fm.uri, -- where public:// -> https://loop.sundhedogomsorg.dk/sites/loop.sundhedogomsorg.dk/files/ - fm.filemime, - fm.filesize, - fm.created, - fm.changed - FROM (SELECT - m_fd.mid, - -- m_fd.vid, - -- -- m_fd.bundle, - -- -- m_fd.langcode, - -- m_fd.status, - -- m_fd.uid, - -- m_fd.name, - -- m_fd.thumbnail__target_id, - -- m_fd.thumbnail__alt, - -- m_fd.thumbnail__title, - -- m_fd.thumbnail__width, - -- m_fd.thumbnail__height, - -- m_fd.created, - -- m_fd.changed, - -- m_fd.default_langcode, - -- m_fd.revision_translation_affected, - -- IFNULL (m_mf.bundle, IFNULL(m_mi.bundle, m_ml.bundle)) as bundle, -- where m_fd.bundle != IFNULL (m_mf.bundle, IFNULL(m_mi.bundle, m_ml.bundle)) returns zero mathes - -- IFNULL (m_mf.deleted, IFNULL(m_mi.deleted, m_ml.deleted)) as deleted, - -- IFNULL (m_mf.entity_id, IFNULL(m_mi.entity_id, m_ml.entity_id)) as entity_id, - -- IFNULL (m_mf.revision_id, IFNULL(m_mi.revision_id, m_ml.revision_id)) as revision_id, - -- IFNULL (m_mf.langcode, IFNULL(m_mi.langcode, m_ml.langcode)) as langcode, -- where m_fd.langcode != IFNULL (m_mf.langcode, IFNULL(m_mi.langcode, m_ml.langcode)) returns zero mathes - -- IFNULL (m_mf.delta, IFNULL(m_mi.delta, m_ml.delta)) as delta, - IFNULL (m_mf.field_media_file_target_id, IFNULL(m_mi.field_media_image_target_id, m_ml.field_media_library_target_id)) as target_id - -- m_mf.field_media_file_display, - -- m_mf.field_media_file_description, - -- m_mi.field_media_image_alt, - -- m_mi.field_media_image_title, - -- m_mi.field_media_image_width, - -- m_mi.field_media_image_height - from media_field_data as m_fd + media_collected.mid, + fm.uri, -- where public:// -> https://loop.sundhedogomsorg.dk/sites/loop.sundhedogomsorg.dk/files/ + fm.filemime, + fm.filesize, + fm.created, + fm.changed + FROM (SELECT + m_fd.mid, + -- m_fd.vid, + -- -- m_fd.bundle, + -- -- m_fd.langcode, + -- m_fd.status, + -- m_fd.uid, + -- m_fd.name, + -- m_fd.thumbnail__target_id, + -- m_fd.thumbnail__alt, + -- m_fd.thumbnail__title, + -- m_fd.thumbnail__width, + -- m_fd.thumbnail__height, + -- m_fd.created, + -- m_fd.changed, + -- m_fd.default_langcode, + -- m_fd.revision_translation_affected, + -- IFNULL (m_mf.bundle, IFNULL(m_mi.bundle, m_ml.bundle)) as bundle, -- where m_fd.bundle != IFNULL (m_mf.bundle, IFNULL(m_mi.bundle, m_ml.bundle)) returns zero mathes + -- IFNULL (m_mf.deleted, IFNULL(m_mi.deleted, m_ml.deleted)) as deleted, + -- IFNULL (m_mf.entity_id, IFNULL(m_mi.entity_id, m_ml.entity_id)) as entity_id, + -- IFNULL (m_mf.revision_id, IFNULL(m_mi.revision_id, m_ml.revision_id)) as revision_id, + -- IFNULL (m_mf.langcode, IFNULL(m_mi.langcode, m_ml.langcode)) as langcode, -- where m_fd.langcode != IFNULL (m_mf.langcode, IFNULL(m_mi.langcode, m_ml.langcode)) returns zero mathes + -- IFNULL (m_mf.delta, IFNULL(m_mi.delta, m_ml.delta)) as delta, + IFNULL (m_mf.field_media_file_target_id, IFNULL(m_mi.field_media_image_target_id, m_ml.field_media_library_target_id)) as target_id + -- m_mf.field_media_file_display, + -- m_mf.field_media_file_description, + -- m_mi.field_media_image_alt, + -- m_mi.field_media_image_title, + -- m_mi.field_media_image_width, + -- m_mi.field_media_image_height + from media_field_data as m_fd left join media__field_media_file as m_mf on m_fd.mid = m_mf.entity_id -- remember dep on m_fd.bundle whether it should be media__field_media_file, media__field_media_image or media__field_media_library we need to join on left join media__field_media_image as m_mi on m_fd.mid = m_mi.entity_id left join media__field_media_library as m_ml on m_fd.mid = m_ml.entity_id) as media_collected left join file_managed as fm on media_collected.target_id = fm.fid), question_attachments AS (SELECT - n_qf.entity_id, - media_attachments.uri, -- where public:// -> https://loop.sundhedogomsorg.dk/sites/loop.sundhedogomsorg.dk/files/ - media_attachments.filemime, - media_attachments.filesize, - media_attachments.created, - media_attachments.changed + n_qf.entity_id, + media_attachments.uri, -- where public:// -> https://loop.sundhedogomsorg.dk/sites/loop.sundhedogomsorg.dk/files/ + media_attachments.filemime, + media_attachments.filesize, + media_attachments.created, + media_attachments.changed FROM node__os2loop_question_file as n_qf left join media_attachments on n_qf.os2loop_question_file_target_id = media_attachments.mid), answer_attachment AS (SELECT - c_am.entity_id, - media_attachments.uri, -- where public:// -> https://loop.sundhedogomsorg.dk/sites/loop.sundhedogomsorg.dk/files/ - media_attachments.filemime, - media_attachments.filesize, - media_attachments.created, - media_attachments.changed + c_am.entity_id, + media_attachments.uri, -- where public:// -> https://loop.sundhedogomsorg.dk/sites/loop.sundhedogomsorg.dk/files/ + media_attachments.filemime, + media_attachments.filesize, + media_attachments.created, + media_attachments.changed FROM comment__os2loop_question_answer_media as c_am left join media_attachments on c_am.os2loop_question_answer_media_target_id = media_attachments.mid) -- the only entry here is null, maybe it has been deleted??, but in future there might be something Select -- *, - n_fd.title as title, + n_fd.title as title, pa.alias as relative_public_url, - n_qc.os2loop_question_content_value as question, + n_qc.os2loop_question_content_value as question, DATE_FORMAT(FROM_UNIXTIME(n_fd.created), '%Y-%m-%dT%H:%i:%s') as question_created, DATE_FORMAT(FROM_UNIXTIME(n_fd.changed), '%Y-%m-%dT%H:%i:%s') as question_changed_in_some_way, c_qa.os2loop_question_answer_value as response, @@ -72,32 +72,33 @@ Select -- *, IF(c_qa.os2loop_question_answer_value LIKE '%http%' or c_qa.os2loop_question_answer_value LIKE '%href%' or c_qa.os2loop_question_answer_value LIKE '%www.%', 1, 0) as any_reference, u_jt.os2loop_user_job_title_value as questioner_job_title, subject_tt_fd.name as `subject`, - agg_professions.target_professions as target_professions, + agg_professions.target_professions as target_professions, agg_tags.tags as question_tags, u_jt_c.os2loop_user_job_title_value as respondent_job_title, - IFNULL(flags.redaktionens_anbefaling,0) as editor_choice, -- add if null -> 0 + IFNULL(flags.redaktionens_anbefaling,0) as editor_choice, -- add if null -> 0 IFNULL(flags.likes,0) as likes, -- if null ->0 -- (, editor_edited) - -- # images/media: + -- # images/media: -- table comment__os2loop_question_answer_media only contains one line and the media here I cannot dereference -- it seem that it should be referenced in the bundle os2loop_media_file (according to table media) corresponding to table media__field_media_file, but here the reference is not among the entity_ids - -- The reference could also not be found in any of the others media__field's nor file_manage + -- The reference could also not be found in any of the others media__field's nor file_manage question_attachments.uri as question_attachment_uri, -- where public:// -> https://loop.sundhedogomsorg.dk/sites/loop.sundhedogomsorg.dk/files/ - question_attachments.filemime as question_attachment_filemime, - question_attachments.filesize as question_attachment_filesize, - DATE_FORMAT(FROM_UNIXTIME(question_attachments.created), '%Y-%m-%dT%H:%i:%s') as question_attachment_created, + question_attachments.filemime as question_attachment_filemime, + question_attachments.filesize as question_attachment_filesize, + DATE_FORMAT(FROM_UNIXTIME(question_attachments.created), '%Y-%m-%dT%H:%i:%s') as question_attachment_created, DATE_FORMAT(FROM_UNIXTIME(question_attachments.changed), '%Y-%m-%dT%H:%i:%s') as question_attachment_changed /* Not included as of export 2/11 - 2023 there are no attachments in answers answer_attachment.uri as answer_attachment_uri, -- where public:// -> https://loop.sundhedogomsorg.dk/sites/loop.sundhedogomsorg.dk/files/ - answer_attachment.filemime as answer_attachment_filemime, - answer_attachment.filesize as answer_attachment_filesize, - answer_attachment.created as answer_attachment_created, + answer_attachment.filemime as answer_attachment_filemime, + answer_attachment.filesize as answer_attachment_filesize, + answer_attachment.created as answer_attachment_created, answer_attachment.changed as answer_attachment_changed */ from ( - SELECT nid,vid,type,uid,title,created,changed + SELECT nid,vid,type,uid,title,created,changed FROM node_field_data where type='os2loop_question' + and status = 1 ) as n_fd left join path_alias as pa on CONCAT('/node/',n_fd.nid) = pa.path left join node__os2loop_question_content as n_qc on n_fd.nid = n_qc.entity_id @@ -105,16 +106,16 @@ left join user__os2loop_user_job_title as u_jt on n_fd.uid = u_jt.entity_id left join node__os2loop_shared_subject as n_ss on n_fd.nid = n_ss.entity_id left join taxonomy_term_field_data as subject_tt_fd on n_ss.os2loop_shared_subject_target_id = subject_tt_fd.tid left join (SELECT - n_sp.entity_id, - CONVERT(JSON_ARRAYAGG(target_prof_tt_fd.name) USING latin1) as target_professions + n_sp.entity_id, + JSON_ARRAYAGG(target_prof_tt_fd.name) as target_professions FROM node__os2loop_shared_profession as n_sp LEFT JOIN taxonomy_term_field_data as target_prof_tt_fd on n_sp.os2loop_shared_profession_target_id = target_prof_tt_fd.tid WHERE n_sp.bundle = 'os2loop_question' group by n_sp.entity_id) AS agg_professions on n_fd.nid = agg_professions.entity_id -left join (SELECT - n_st.entity_id, - CONVERT(JSON_ARRAYAGG(tag_tt_fd.name) USING latin1) as tags - FROM node__os2loop_shared_tags as n_st +left join (SELECT + n_st.entity_id, + JSON_ARRAYAGG(tag_tt_fd.name) as tags + FROM node__os2loop_shared_tags as n_st left join taxonomy_term_field_data as tag_tt_fd on n_st.os2loop_shared_tags_target_id = tag_tt_fd.tid where n_st.bundle = 'os2loop_question' group by n_st.entity_id) as agg_tags on n_fd.nid = agg_tags.entity_id @@ -122,18 +123,18 @@ left join question_attachments on n_fd.nid = question_attachments.entity_id left join comment_field_data as c_fd on n_fd.nid = c_fd.entity_id left join comment__os2loop_question_answer as c_qa on c_fd.cid = c_qa.entity_id left join user__os2loop_user_job_title as u_jt_c on c_fd.uid = u_jt_c.entity_id -left join (SELECT - entity_id, +left join (SELECT + entity_id, MAX( IF (flag_id = 'os2loop_upvote_correct_answer', True, False)) as redaktionens_anbefaling, MAX( IF (flag_id = 'os2loop_upvote_upvote_button', count, 0)) as likes FROM flag_counts - where entity_type = 'comment' + where entity_type = 'comment' group by entity_id -- maybe and flag_id = 'os2loop_upvote_correct_answer' ) as flags on flags.entity_id = c_fd.cid left join answer_attachment on c_fd.cid = answer_attachment.entity_id --- where +-- where -- and (c_qa.os2loop_question_answer_value LIKE '%http%' or c_qa.os2loop_question_answer_value LIKE '%href%') -- where c_qa.os2loop_question_answer_value LIKE '%loop.sundhedogomsorg%' -- c_fd.cid = '5183' - -- and n_fd.title Like 'Ved kommunikation %'; + -- and n_fd.title Like 'Ved kommunikation %'; \ No newline at end of file diff --git a/data-export/export_static_pages_with_meta.sql b/data-export/export_static_pages_with_meta.sql index 46b88235c..11894dc5e 100644 --- a/data-export/export_static_pages_with_meta.sql +++ b/data-export/export_static_pages_with_meta.sql @@ -1,4 +1,4 @@ -Select +Select n_fd.nid, n_fd.type, n_fd.title, @@ -9,59 +9,60 @@ Select -- doc_body.os2loop_documents_document_body_value, -- all delta is zero -- page_cont.os2loop_page_content_summary, -- no info at the moment page_cont.os2loop_page_content_value as page_content, - sec_page_para.os2loop_section_page_free_html_value, - sec_page_para.os2loop_section_page_info_text_value, + sec_page_para.os2loop_section_page_free_html_value, + sec_page_para.os2loop_section_page_info_text_value, sec_page_para.os2loop_section_page_view_header_value, sec_page_para.os2loop_section_page_view_text_value from ( - SELECT nid,vid,type,uid,title,created,changed + SELECT nid,vid,type,uid,title,created,changed FROM node_field_data where type in ( 'os2loop_page', -- static pages 'os2loop_section_page' -- only 3 nodes, but /velkommen-til-loop (landing page) and /arbejdsgange-og-vejledninger and /sundhedsfaglige-instrukser - collection pages - ) + ) + and status = 1 ) as n_fd left join path_alias as pa on CONCAT('/node/',n_fd.nid) = pa.path -- left join node__os2loop_documents_document_autho as doc_author on n_fd.nid = doc_author.entity_id -- left join node__os2loop_documents_document_body as doc_body on n_fd.nid = doc_body.entity_id left join node__os2loop_page_content as page_cont on n_fd.nid = page_cont.entity_id left join (SELECT - -- sec_page_para.bundle as sec_page_para_bundle, - -- IFNULL(sec_page_free.bundle, IFNULL(sec_page_info.bundle, sec_page_view.bundle)) as sec_page_bundle, - -- sec_page_para.deleted, - sec_page_para.entity_id, - -- sec_page_para.revision_id, sec_page_para.langcode, sec_page_para.delta, sec_page_para.os2loop_section_page_paragraph_target_id, sec_page_para.os2loop_section_page_paragraph_target_revision_id, - -- IFNull(sec_page_free.entity_id,IFNULL(sec_page_info.entity_id, sec_page_view.entity_id)) as para_entity_id, - -- IFNull(sec_page_free.revision_id, IFNULL(sec_page_info.revision_id, sec_page_view.revision_id)) as para_revision_id, - -- IFNULL(sec_page_free.deleted, IFNULL(sec_page_info.deleted, sec_page_view.deleted)) as deleted, - -- IFNull(sec_page_free.langcode, IFNULL(sec_page_info.langcode, sec_page_view.langcode)) as langcode, - -- IFNull(sec_page_free.delta, IFNULL(sec_page_info.delta, sec_page_view.delta)) as delta, - sec_page_free.os2loop_section_page_free_html_value, - sec_page_info.os2loop_section_page_info_text_value, - sec_page_view.os2loop_section_page_view_header_value, - sec_page_view.os2loop_section_page_view_text_value - -- sec_page_free.os2loop_section_page_free_html_format, - -- sec_page_info.os2loop_section_page_info_text_format, - -- sec_page_view.os2loop_section_page_view_text_format - -- par_ifd.id as para_id, par_ifd.revision_id, par_ifd.type as para_type, par_ifd.parent_id as para_parent_id, par_ifd.parent_type, par_ifd.parent_field_name, par_ifd.langcode, par_ifd.status, par_ifd.created, par_ifd.behavior_settings, par_ifd.default_langcode, par_ifd.revision_translation_affected, - FROM node__os2loop_section_page_paragraph as sec_page_para - -- ::: the info in paragraphs_item_field_data are not needed here ::: - -- left join (SELECT * - -- FROM paragraphs_item_field_data - -- where parent_field_name = 'os2loop_section_page_paragraph') as par_ifd on sec_page_para.os2loop_section_page_paragraph_target_id = par_ifd.id - left join paragraph__os2loop_section_page_free_html as sec_page_free on sec_page_para.os2loop_section_page_paragraph_target_id = sec_page_free.entity_id - left join paragraph__os2loop_section_page_info_text as sec_page_info on sec_page_para.os2loop_section_page_paragraph_target_id = sec_page_info.entity_id - -- left join paragraph__os2loop_section_page_title -- empty table, so no paragraph section page titles - left join (SELECT - -- sec_page_header.bundle, - sec_page_header.entity_id, - -- sec_page_header.revision_id, - -- sec_page_header.deleted, - -- sec_page_header.langcode, - -- sec_page_header.delta, - sec_page_header.os2loop_section_page_view_header_value, - sec_page_text.os2loop_section_page_view_text_value, - sec_page_text.os2loop_section_page_view_text_format - FROM paragraph__os2loop_section_page_view_header as sec_page_header - left join paragraph__os2loop_section_page_view_text as sec_page_text on sec_page_header.entity_id = sec_page_text.entity_id) as sec_page_view on sec_page_para.os2loop_section_page_paragraph_target_id = sec_page_view.entity_id - ) as sec_page_para on n_fd.nid = sec_page_para.entity_id + -- sec_page_para.bundle as sec_page_para_bundle, + -- IFNULL(sec_page_free.bundle, IFNULL(sec_page_info.bundle, sec_page_view.bundle)) as sec_page_bundle, + -- sec_page_para.deleted, + sec_page_para.entity_id, + -- sec_page_para.revision_id, sec_page_para.langcode, sec_page_para.delta, sec_page_para.os2loop_section_page_paragraph_target_id, sec_page_para.os2loop_section_page_paragraph_target_revision_id, + -- IFNull(sec_page_free.entity_id,IFNULL(sec_page_info.entity_id, sec_page_view.entity_id)) as para_entity_id, + -- IFNull(sec_page_free.revision_id, IFNULL(sec_page_info.revision_id, sec_page_view.revision_id)) as para_revision_id, + -- IFNULL(sec_page_free.deleted, IFNULL(sec_page_info.deleted, sec_page_view.deleted)) as deleted, + -- IFNull(sec_page_free.langcode, IFNULL(sec_page_info.langcode, sec_page_view.langcode)) as langcode, + -- IFNull(sec_page_free.delta, IFNULL(sec_page_info.delta, sec_page_view.delta)) as delta, + sec_page_free.os2loop_section_page_free_html_value, + sec_page_info.os2loop_section_page_info_text_value, + sec_page_view.os2loop_section_page_view_header_value, + sec_page_view.os2loop_section_page_view_text_value + -- sec_page_free.os2loop_section_page_free_html_format, + -- sec_page_info.os2loop_section_page_info_text_format, + -- sec_page_view.os2loop_section_page_view_text_format + -- par_ifd.id as para_id, par_ifd.revision_id, par_ifd.type as para_type, par_ifd.parent_id as para_parent_id, par_ifd.parent_type, par_ifd.parent_field_name, par_ifd.langcode, par_ifd.status, par_ifd.created, par_ifd.behavior_settings, par_ifd.default_langcode, par_ifd.revision_translation_affected, + FROM node__os2loop_section_page_paragraph as sec_page_para + -- ::: the info in paragraphs_item_field_data are not needed here ::: + -- left join (SELECT * + -- FROM paragraphs_item_field_data + -- where parent_field_name = 'os2loop_section_page_paragraph') as par_ifd on sec_page_para.os2loop_section_page_paragraph_target_id = par_ifd.id + left join paragraph__os2loop_section_page_free_html as sec_page_free on sec_page_para.os2loop_section_page_paragraph_target_id = sec_page_free.entity_id + left join paragraph__os2loop_section_page_info_text as sec_page_info on sec_page_para.os2loop_section_page_paragraph_target_id = sec_page_info.entity_id + -- left join paragraph__os2loop_section_page_title -- empty table, so no paragraph section page titles + left join (SELECT + -- sec_page_header.bundle, + sec_page_header.entity_id, + -- sec_page_header.revision_id, + -- sec_page_header.deleted, + -- sec_page_header.langcode, + -- sec_page_header.delta, + sec_page_header.os2loop_section_page_view_header_value, + sec_page_text.os2loop_section_page_view_text_value, + sec_page_text.os2loop_section_page_view_text_format + FROM paragraph__os2loop_section_page_view_header as sec_page_header + left join paragraph__os2loop_section_page_view_text as sec_page_text on sec_page_header.entity_id = sec_page_text.entity_id) as sec_page_view on sec_page_para.os2loop_section_page_paragraph_target_id = sec_page_view.entity_id + ) as sec_page_para on n_fd.nid = sec_page_para.entity_id \ No newline at end of file