Skip to content

Commit

Permalink
Merge pull request #4847 from sul-dlss/t4825-release_tag_report
Browse files Browse the repository at this point in the history
Adds release tags report.
  • Loading branch information
jcoyne authored Apr 11, 2024
2 parents 2fcb971 + cfa4bc0 commit 4ab87f3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/reports/latest_release_tags.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

# Reports most recent release tags.

# Invoke via:
# bin/rails r -e production "LatestReleaseTags.report"
class LatestReleaseTags
SQL = <<~SQL.squish.freeze
select tags.*, case when dros.id is not null then 'dro' else 'collection' end as object_type from
(
select distinct on (druid, released_to, what)
druid, released_to, what, release
from release_tags
order by druid, released_to, what, created_at desc
) as tags
left outer join dros on tags.druid=dros.external_identifier;
SQL

def self.report
puts "druid,released_to,what,release,object_type\n"

sql_result_rows = ActiveRecord::Base.connection.execute(SQL)
sql_result_rows.each do |row|
puts "#{row['druid']},#{row['released_to']},#{row['what']},#{row['release']},#{row['object_type']}"
end
end
end

0 comments on commit 4ab87f3

Please sign in to comment.