Skip to content

Commit

Permalink
Adds release tags report.
Browse files Browse the repository at this point in the history
closes #4825
  • Loading branch information
justinlittman committed Apr 11, 2024
1 parent 2fcb971 commit cfa4bc0
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 cfa4bc0

Please sign in to comment.