Skip to content

Commit 01aec7f

Browse files
authored
Merge pull request #364 from DKAndreasen/feature/ai-stuff-fix-sql-queries
Add status true condition
2 parents 450cced + 525bb14 commit 01aec7f

7 files changed

+381
-334
lines changed
Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Select
1+
Select
22
n_fd.nid,
33
n_fd.type,
44
n_fd.title,
@@ -10,24 +10,25 @@ Select
1010
docscol_content.os2loop_documents_dc_content_value as content, -- all format are rich text (html and div encoded)
1111
docs_ib.os2loop_documents_info_box_value as info_box,
1212
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`,
13+
`subject`.`name` as `subject`, -- subjects are from curated list
14+
tags.tags, -- authors can add any tags they like
15+
-- `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
1616
rev_date.os2loop_shared_rev_date_value as review_date,
1717
`version`.os2loop_shared_version_value as `version`
1818
from (
19-
SELECT nid,vid,type,uid,title,created,changed
19+
SELECT nid,vid,type,uid,title,created,changed
2020
FROM node_field_data
2121
where type = 'os2loop_documents_collection'
2222
-- 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
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
2525
-- /instruks-korrekt-haandtering-af-medicin-i-sundhed-og-omsorg-mso nid 4188
2626
-- of 805 documents 164 documents are not assigned to a document_collection
27+
and status = 1
2728
) as n_fd
2829
left join path_alias as pa on CONCAT('/node/',n_fd.nid) = pa.path
2930
left join (
30-
SELECT
31+
SELECT
3132
doc_col_itm.collection_id,
3233
json_arrayagg(doc_col_itm.document_id) as document_node_ids,
3334
json_arrayagg(pa.`alias`) as document_relative_urls
@@ -38,26 +39,26 @@ left join (
3839
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)
3940
left join (
4041
SELECT
41-
entity_id,
42-
os2loop_documents_info_box_value
43-
FROM node__os2loop_documents_info_box
42+
entity_id,
43+
os2loop_documents_info_box_value
44+
FROM node__os2loop_documents_info_box
4445
WHERE bundle = 'os2loop_documents_collection') as docs_ib on n_fd.nid = docs_ib.entity_id -- only from bundle document_collection
4546
left join node__os2loop_shared_approval_date as approval_date on n_fd.nid = approval_date.entity_id
4647
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
48+
SELECT
49+
n_ss.entity_id,
50+
subject_tt_fd.name
51+
FROM node__os2loop_shared_subject as n_ss
52+
left join taxonomy_term_field_data as subject_tt_fd on n_ss.os2loop_shared_subject_target_id = subject_tt_fd.tid
53+
where n_ss.bundle = 'os2loop_documents_collection') as `subject` on n_fd.nid = `subject`.entity_id
54+
-- left join node__os2loop_shared_owner as `owner` on n_fd.nid = `owner`.entity_id -- see comment in select
5455
left join node__os2loop_shared_rev_date as rev_date on n_fd.nid = rev_date.entity_id
5556
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
57+
SELECT
58+
n_st.entity_id,
59+
json_arrayagg(tt_fd.name) as tags
60+
FROM node__os2loop_shared_tags as n_st
61+
left join taxonomy_term_field_data as tt_fd on n_st.os2loop_shared_tags_target_id = tt_fd.tid
62+
where n_st.bundle = 'os2loop_documents_collection'
63+
group by n_st.entity_id) tags on n_fd.nid = tags.entity_id
64+
left join node__os2loop_shared_version as `version` on n_fd.nid = `version`.entity_id

0 commit comments

Comments
 (0)