|
| 1 | +Select |
| 2 | + n_fd.nid, |
| 3 | + n_fd.type, |
| 4 | + n_fd.title, |
| 5 | + pa.`alias` as relative_url, |
| 6 | + DATE_FORMAT(FROM_UNIXTIME(n_fd.created), '%Y-%m-%dT%H:%i:%s') as created, |
| 7 | + DATE_FORMAT(FROM_UNIXTIME(n_fd.changed), '%Y-%m-%dT%H:%i:%s') as `changed`, |
| 8 | + dci.document_node_ids, |
| 9 | + dci.document_relative_urls, |
| 10 | + docscol_content.os2loop_documents_dc_content_value as content, -- all format are rich text (html and div encoded) |
| 11 | + docs_ib.os2loop_documents_info_box_value as info_box, |
| 12 | + approval_date.os2loop_shared_approval_date_value as approval_date, |
| 13 | + `subject`.`name` as `subject`, |
| 14 | + tags.tags, |
| 15 | + `owner`.os2loop_shared_owner_value as `owner`, |
| 16 | + rev_date.os2loop_shared_rev_date_value as review_date, |
| 17 | + `version`.os2loop_shared_version_value as `version` |
| 18 | +from ( |
| 19 | + SELECT nid,vid,type,uid,title,created,changed |
| 20 | + FROM node_field_data |
| 21 | + where type = 'os2loop_documents_collection' |
| 22 | + -- the table os2loop_documents_collection_item associate document collections (their nid on collection_id) |
| 23 | + -- to documents (document_id = nid) except for 20 document collections. Fx case /rammedelegation nid=3807 it is a collection of |
| 24 | + -- links to sharepoint docs and /medicinhaandtering nid=3827 is a link to the collection |
| 25 | + -- /instruks-korrekt-haandtering-af-medicin-i-sundhed-og-omsorg-mso nid 4188 |
| 26 | + -- of 805 documents 164 documents are not assigned to a document_collection |
| 27 | + ) as n_fd |
| 28 | +left join path_alias as pa on CONCAT('/node/',n_fd.nid) = pa.path |
| 29 | +left join ( |
| 30 | + SELECT |
| 31 | + doc_col_itm.collection_id, |
| 32 | + json_arrayagg(doc_col_itm.document_id) as document_node_ids, |
| 33 | + json_arrayagg(pa.`alias`) as document_relative_urls |
| 34 | + from os2loop_documents_collection_item as doc_col_itm |
| 35 | + left join path_alias as pa on CONCAT('/node/',doc_col_itm.document_id) = pa.path |
| 36 | + group by doc_col_itm.collection_id |
| 37 | + ) as dci on n_fd.nid = dci.collection_id |
| 38 | +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) |
| 39 | +left join ( |
| 40 | + SELECT |
| 41 | + entity_id, |
| 42 | + os2loop_documents_info_box_value |
| 43 | + FROM node__os2loop_documents_info_box |
| 44 | + WHERE bundle = 'os2loop_documents_collection') as docs_ib on n_fd.nid = docs_ib.entity_id -- only from bundle document_collection |
| 45 | +left join node__os2loop_shared_approval_date as approval_date on n_fd.nid = approval_date.entity_id |
| 46 | +left join ( |
| 47 | + SELECT |
| 48 | + n_ss.entity_id, |
| 49 | + subject_tt_fd.name |
| 50 | + FROM node__os2loop_shared_subject as n_ss |
| 51 | + left join taxonomy_term_field_data as subject_tt_fd on n_ss.os2loop_shared_subject_target_id = subject_tt_fd.tid |
| 52 | + where n_ss.bundle = 'os2loop_documents_collection') as `subject` on n_fd.nid = `subject`.entity_id |
| 53 | +left join node__os2loop_shared_owner as `owner` on n_fd.nid = `owner`.entity_id |
| 54 | +left join node__os2loop_shared_rev_date as rev_date on n_fd.nid = rev_date.entity_id |
| 55 | +left join ( |
| 56 | + SELECT |
| 57 | + n_st.entity_id, |
| 58 | + json_arrayagg(tt_fd.name) as tags |
| 59 | + FROM node__os2loop_shared_tags as n_st |
| 60 | + left join taxonomy_term_field_data as tt_fd on n_st.os2loop_shared_tags_target_id = tt_fd.tid |
| 61 | + where n_st.bundle = 'os2loop_documents_collection' |
| 62 | + group by n_st.entity_id) tags on n_fd.nid = tags.entity_id |
| 63 | +left join node__os2loop_shared_version as `version` on n_fd.nid = `version`.entity_id |
0 commit comments