Skip to content

Commit

Permalink
Merge pull request #21 from johnofsydney/fix-evidence-and-add-to-view
Browse files Browse the repository at this point in the history
Fix all the evidence ingest and surface it on view pages
  • Loading branch information
johnofsydney authored Sep 15, 2024
2 parents 6116ace + d7f8ac3 commit e1935b2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
5 changes: 3 additions & 2 deletions app/services/file_ingestor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}"
Expand Down
18 changes: 16 additions & 2 deletions app/views/components/groups/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
''
Expand All @@ -38,6 +48,10 @@ def template

private

def last_position
membership&.last_position
end

def last_position_and_title
position = membership&.last_position

Expand Down
16 changes: 15 additions & 1 deletion app/views/components/people/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
''
Expand All @@ -34,6 +45,9 @@ def template
end

private
def last_position
membership&.last_position
end

def last_position_and_title
position = membership&.last_position
Expand Down
2 changes: 1 addition & 1 deletion csv_data/affiliations.csv
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion csv_data/other_people_groups_positions.csv
Original file line number Diff line number Diff line change
@@ -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/
Expand Down

0 comments on commit e1935b2

Please sign in to comment.