-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a report for files with no size
Ref #4990
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
# Invoke via: | ||
# bin/rails r -e production "FilesWithNoSize.report" | ||
class FilesWithNoSize | ||
JSON_PATH = '$.contains[*].structural.contains[*]' | ||
SQL = <<~SQL.squish.freeze | ||
SELECT ro.external_identifier | ||
FROM repository_objects AS ro, repository_object_versions AS rov WHERE | ||
ro.head_version_id = rov.id | ||
AND ro.object_type = 'dro' | ||
AND jsonb_array_length(jsonb_path_query_array(rov.structural, '#{JSON_PATH}')) != | ||
jsonb_array_length(jsonb_path_query_array(rov.structural, '#{JSON_PATH}.size')) | ||
SQL | ||
|
||
def self.report | ||
puts "item_druid\n" | ||
result = ActiveRecord::Base.connection.execute(SQL) | ||
|
||
result.each do |row| | ||
puts row | ||
end | ||
end | ||
end |