From d7f8ac3d15b67639f61c10a78b12c0c91d7eb5ee Mon Sep 17 00:00:00 2001 From: John Coote Date: Mon, 16 Sep 2024 09:08:33 +1000 Subject: [PATCH] Fix all the evidence ingest and surface irt on view pages --- app/services/file_ingestor.rb | 5 +++-- app/views/components/groups/person.rb | 18 ++++++++++++++++-- app/views/components/people/group.rb | 16 +++++++++++++++- csv_data/affiliations.csv | 2 +- csv_data/other_people_groups_positions.csv | 2 +- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/app/services/file_ingestor.rb b/app/services/file_ingestor.rb index 241b56b..0345a4c 100644 --- a/app/services/file_ingestor.rb +++ b/app/services/file_ingestor.rb @@ -237,6 +237,7 @@ def general_upload(file) end_date = parse_date(row['end_date']) if row['end_date'].present? # the membership may not exist, if so, we need to create it + # There is no start date or end date added to the membership at this point membership = Membership.find_or_create_by( member_type: "Person", member_id: person.id, @@ -247,8 +248,8 @@ def general_upload(file) position = Position.find_or_create_by(membership:, title:, start_date:, end_date:) end - membership.update(evidence:) if evidence - position.update(evidence:) if evidence && position + membership.update!(evidence:) if evidence + position.update!(evidence:) if evidence && position rescue => e p "General Upload | Error: #{e} | row#{row.inspect}" diff --git a/app/views/components/groups/person.rb b/app/views/components/groups/person.rb index 2033b31..9ab4000 100644 --- a/app/views/components/groups/person.rb +++ b/app/views/components/groups/person.rb @@ -10,9 +10,19 @@ def initialize(person:, exclude_group: nil) def template tr do td do - a(href: "/people/#{person.id}") { person.name } + span { a(href: "/people/#{person.id}") { person.name } } + if membership.evidence.present? + span { ' ' } + span { a(href: membership.evidence, target: '_blank') { '...' } } + end + end + td do + span {last_position_and_title} + if last_position&.evidence.present? + span { ' ' } + span { a(href: last_position.evidence, target: '_blank') { '...' } } + end end - td { last_position_and_title } td do if person.memberships.length == 1 # it me '' @@ -38,6 +48,10 @@ def template private + def last_position + membership&.last_position + end + def last_position_and_title position = membership&.last_position diff --git a/app/views/components/people/group.rb b/app/views/components/people/group.rb index 1a14c5a..3580edf 100644 --- a/app/views/components/people/group.rb +++ b/app/views/components/people/group.rb @@ -11,8 +11,19 @@ def template tr do td do a(href: "/groups/#{group.id}") { group.name } + if membership.evidence.present? + span { ' ' } + span { a(href: membership.evidence, target: '_blank') { '...' } } + end + end + td do + span {last_position_and_title} + + if last_position&.evidence.present? + span { ' ' } + span { a(href: last_position.evidence, target: '_blank') { '...' } } + end end - td { last_position_and_title } td do if group.memberships.count == 1 '' @@ -34,6 +45,9 @@ def template end private + def last_position + membership&.last_position + end def last_position_and_title position = membership&.last_position diff --git a/csv_data/affiliations.csv b/csv_data/affiliations.csv index 850a98e..6b44d07 100644 --- a/csv_data/affiliations.csv +++ b/csv_data/affiliations.csv @@ -1,4 +1,4 @@ -group,member_group,start_date,end_date, evidence +group,member_group,start_date,end_date,evidence Greens Federal, Greens NSW Greens Federal, Greens VIC Greens Federal, Greens QLD diff --git a/csv_data/other_people_groups_positions.csv b/csv_data/other_people_groups_positions.csv index dd2efcb..3d05b22 100644 --- a/csv_data/other_people_groups_positions.csv +++ b/csv_data/other_people_groups_positions.csv @@ -1,4 +1,4 @@ -group,person,title,start_date,end_date, evidence +group,person,title,start_date,end_date,evidence Financial Services Council Limited,Martin Codina,Director Of Policy,1/10/2009,1/12/2013,https://www.linkedin.com/in/martin-codina-32a1b641/ Westpac BT Financial Group,Martin Codina,Head of Government and Industry Affairs,1/1/0204,1/1/2015,https://www.linkedin.com/in/martin-codina-32a1b641/ Office of Josh Frydenberg,Martin Codina,Chief Of Staff,1/1/2015,1/8/2017,https://www.linkedin.com/in/martin-codina-32a1b641/