From efa74e6e19e86d3408a290723640f7e851ba037a Mon Sep 17 00:00:00 2001 From: crugas Date: Fri, 20 Dec 2024 12:13:01 -0500 Subject: [PATCH 1/2] Added script for #14. This should close the issue. --- sql_scripts/report_cfchlinkedagents.sql | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 sql_scripts/report_cfchlinkedagents.sql diff --git a/sql_scripts/report_cfchlinkedagents.sql b/sql_scripts/report_cfchlinkedagents.sql new file mode 100644 index 0000000..303043e --- /dev/null +++ b/sql_scripts/report_cfchlinkedagents.sql @@ -0,0 +1,23 @@ +-- Retrieves all agent_persons that are linked to in the CFCH repository. Updating this script to another repository is possible by changing the ao.repo_id code to the desired repository. + +SELECT + name_person.sort_name AS agent_name, name_person.agent_person_id AS agent_id, evname.value AS name_source, evrole.value AS role +FROM + linked_agents_rlshp AS rel + JOIN + archival_object AS ao ON ao.id = rel.archival_object_id + LEFT JOIN + resource ON resource.id = rel.resource_id + LEFT JOIN + name_person ON name_person.agent_person_id = rel.agent_person_id + LEFT JOIN + enumeration_value AS evname ON evname.id = name_person.source_id + JOIN + enumeration_value AS evrole ON evrole.id = rel.role_id + JOIN + agent_record_identifier AS recordid ON recordid.id = rel. +WHERE + ao.repo_id = 21 +GROUP BY name_person.id + +-- To get the above to work properly, you'll need to run this query before running the above: SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', '')); \ No newline at end of file From 60d5d2088c180bf967dde8253d685afa601cf5d5 Mon Sep 17 00:00:00 2001 From: crugas Date: Mon, 23 Dec 2024 09:50:02 -0500 Subject: [PATCH 2/2] Complete incomplete rel. --- sql_scripts/report_cfchlinkedagents.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql_scripts/report_cfchlinkedagents.sql b/sql_scripts/report_cfchlinkedagents.sql index 303043e..2f698f0 100644 --- a/sql_scripts/report_cfchlinkedagents.sql +++ b/sql_scripts/report_cfchlinkedagents.sql @@ -15,7 +15,7 @@ FROM JOIN enumeration_value AS evrole ON evrole.id = rel.role_id JOIN - agent_record_identifier AS recordid ON recordid.id = rel. + agent_record_identifier AS recordid ON recordid.id = rel.role_id WHERE ao.repo_id = 21 GROUP BY name_person.id