Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4085914
commit f85cf0e
Showing
6 changed files
with
122 additions
and
79 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
118 changes: 67 additions & 51 deletions
118
app/sources/curation_concerns/resource_statistics_source.rb
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 |
---|---|---|
@@ -1,67 +1,83 @@ | ||
module CurationConcerns | ||
class ResourceStatisticsSource | ||
class << self | ||
def open_concerns_count | ||
# TODO: verify that this is not pulling all records and then counting | ||
relation.where(Hydra.config.permissions.read.group => 'public').count | ||
end | ||
|
||
def authenticated_concerns_count | ||
relation.where(Hydra.config.permissions.read.group => 'registered').count | ||
end | ||
attr_accessor :search_builder, :repository | ||
def initialize(search_builder: nil, repository: nil) | ||
@search_builder = search_builder || ::CatalogController.new.search_builder | ||
@repository = repository || ::CatalogController.new.repository | ||
# Remove gated discovery. | ||
@search_builder = self.search_builder.except(:add_access_controls_to_solr_params) | ||
solr_arguments[:fq] ||= [] | ||
solr_arguments[:rows] = 0 | ||
end | ||
|
||
def restricted_concerns_count | ||
# TODO: Replace this with a query that that returns all documents that | ||
# either lack the `read_access_group_ssim` key, or have the key | ||
# without the values of `public` or `registered` | ||
relation.count - (authenticated_concerns_count + open_concerns_count) | ||
end | ||
def open_concerns_count | ||
search_with_query("#{Hydra.config.permissions.read.group}:public") | ||
end | ||
|
||
def expired_embargo_now_authenticated_concerns_count | ||
relation.where(Hydra.config.permissions.read.group => 'registered').where("embargo_history_ssim:*").count | ||
end | ||
def authenticated_concerns_count | ||
search_with_query("#{Hydra.config.permissions.read.group}:registered") | ||
end | ||
|
||
def expired_embargo_now_open_concerns_count | ||
relation.where(Hydra.config.permissions.read.group => 'public').where("embargo_history_ssim:*").count | ||
end | ||
def restricted_concerns_count | ||
# TODO: Replace this with a query that that returns all documents that | ||
# either lack the `read_access_group_ssim` key, or have the key | ||
# without the values of `public` or `registered` | ||
repository.search(solr_arguments)["response"]["numFound"] - (authenticated_concerns_count + open_concerns_count) | ||
end | ||
|
||
def active_embargo_now_authenticated_concerns_count | ||
relation.where(Hydra.config.permissions.read.group => 'registered').where("embargo_release_date_dtsi:[NOW TO *]").count | ||
end | ||
def expired_embargo_now_authenticated_concerns_count | ||
search_with_query(["#{Hydra.config.permissions.read.group}:registered", "embargo_history_ssim:*"]) | ||
end | ||
|
||
def active_embargo_now_restricted_concerns_count | ||
# TODO: Replace the subtraction with another `#where` query that returns | ||
# all actively embargoed documents that either lack the | ||
# `read_access_group_ssim` key, or have the key without the values | ||
# of `public` or `registered` | ||
relation.where("embargo_release_date_dtsi:[NOW TO *]").count - active_embargo_now_authenticated_concerns_count | ||
end | ||
def expired_embargo_now_open_concerns_count | ||
search_with_query(["#{Hydra.config.permissions.read.group}:public", "embargo_history_ssim:*"]) | ||
end | ||
|
||
def expired_lease_now_authenticated_concerns_count | ||
relation.where(Hydra.config.permissions.read.group => 'registered').where("lease_history_ssim:*").count | ||
end | ||
def active_embargo_now_authenticated_concerns_count | ||
search_with_query(["#{Hydra.config.permissions.read.group}:registered", "embargo_release_date_dtsi:[NOW TO *]"]) | ||
end | ||
|
||
def expired_lease_now_restricted_concerns_count | ||
# TODO: Replace the subtraction with another `#where` query that returns | ||
# all expired lease documents that either lack the | ||
# `read_access_group_ssim` key, or have the key without the values | ||
# of `public` or `registered` | ||
relation.where("lease_history_ssim:*").count - expired_lease_now_authenticated_concerns_count | ||
end | ||
def active_embargo_now_restricted_concerns_count | ||
# TODO: Replace the subtraction with another `#where` query that returns | ||
# all actively embargoed documents that either lack the | ||
# `read_access_group_ssim` key, or have the key without the values | ||
# of `public` or `registered` | ||
all_expired_embargos = search_with_query("embargo_release_date_dtsi:[NOW TO *]") | ||
all_expired_embargos - active_embargo_now_authenticated_concerns_count | ||
end | ||
|
||
def active_lease_now_authenticated_concerns_count | ||
relation.where(Hydra.config.permissions.read.group => 'registered').where("lease_expiration_date_dtsi:[NOW TO *]").count | ||
end | ||
def expired_lease_now_authenticated_concerns_count | ||
search_with_query(["#{Hydra.config.permissions.read.group}:registered", "lease_history_ssim:*"]) | ||
end | ||
|
||
def active_lease_now_open_concerns_count | ||
relation.where(Hydra.config.permissions.read.group => 'public').where("lease_expiration_date_dtsi:[NOW TO *]").count | ||
end | ||
def expired_lease_now_restricted_concerns_count | ||
# TODO: Replace the subtraction with another `#where` query that returns | ||
# all expired lease documents that either lack the | ||
# `read_access_group_ssim` key, or have the key without the values | ||
# of `public` or `registered` | ||
all_leased_documents = search_with_query("lease_history_ssim:*") | ||
all_leased_documents - expired_lease_now_authenticated_concerns_count | ||
end | ||
|
||
private | ||
def active_lease_now_authenticated_concerns_count | ||
search_with_query(["#{Hydra.config.permissions.read.group}:registered", "lease_expiration_date_dtsi:[NOW TO *]"]) | ||
end | ||
|
||
def relation | ||
CurationConcerns::WorkRelation.new | ||
end | ||
def active_lease_now_open_concerns_count | ||
search_with_query(["#{Hydra.config.permissions.read.group}:public", "lease_expiration_date_dtsi:[NOW TO *]"]) | ||
end | ||
|
||
private | ||
|
||
def solr_arguments | ||
@solr_arguments ||= search_builder.to_h | ||
end | ||
|
||
def search_with_query(query) | ||
q = { fq: Array.wrap(query) } | ||
repository.search(solr_arguments.merge(q) do |_key, v1, v2| | ||
v1 + v2 | ||
end)["response"]["numFound"] | ||
end | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
app/views/curation_concerns/admin/_document_aggregate.html.erb
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,5 @@ | ||
Aggregate Information: | ||
|
||
<% resource_stats = @configuration[:data_sources][:resource_stats] %> | ||
<% resource_stats = resource_stats.new(search_builder: @search_builder) %> | ||
<%= render "resource_stats", resource_stats: resource_stats %> |
14 changes: 14 additions & 0 deletions
14
app/views/curation_concerns/admin/_resource_stats.html.erb
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,14 @@ | ||
<h4>Totals by Visibility</h4> | ||
<ul> | ||
<li><%= t("curation_concerns.visibility.open.text") %> <span class="count">(<%= resource_stats.open_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.authenticated.text") %> <span class="count">(<%= resource_stats.authenticated_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.restricted.text") %> <span class="count">(<%= resource_stats.restricted_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.embargo.expired.authenticated.text") %> <span class="count">(<%= resource_stats.expired_embargo_now_authenticated_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.embargo.expired.open.text") %> <span class="count">(<%= resource_stats.expired_embargo_now_open_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.embargo.active.authenticated.text") %> <span class="count">(<%= resource_stats.active_embargo_now_authenticated_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.embargo.active.restricted.text") %> <span class="count">(<%= resource_stats.active_embargo_now_restricted_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.lease.expired.restricted.text") %> <span class="count">(<%= resource_stats.expired_lease_now_restricted_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.lease.expired.authenticated.text") %> <span class="count">(<%= resource_stats.expired_lease_now_authenticated_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.lease.active.authenticated.text") %> <span class="count">(<%= resource_stats.active_lease_now_authenticated_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.lease.active.open.text") %> <span class="count">(<%= resource_stats.active_lease_now_open_concerns_count %>)</span></li> | ||
</ul> |
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 |
---|---|---|
@@ -1,15 +1,2 @@ | ||
<% resource_stats = @configuration[:data_sources][:resource_stats] %> | ||
<h4>Totals by Visibility</h4> | ||
<ul> | ||
<li><%= t("curation_concerns.visibility.open.text") %> <span class="count">(<%= resource_stats.open_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.authenticated.text") %> <span class="count">(<%= resource_stats.authenticated_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.restricted.text") %> <span class="count">(<%= resource_stats.restricted_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.embargo.expired.authenticated.text") %> <span class="count">(<%= resource_stats.expired_embargo_now_authenticated_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.embargo.expired.open.text") %> <span class="count">(<%= resource_stats.expired_embargo_now_open_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.embargo.active.authenticated.text") %> <span class="count">(<%= resource_stats.active_embargo_now_authenticated_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.embargo.active.restricted.text") %> <span class="count">(<%= resource_stats.active_embargo_now_restricted_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.lease.expired.restricted.text") %> <span class="count">(<%= resource_stats.expired_lease_now_restricted_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.lease.expired.authenticated.text") %> <span class="count">(<%= resource_stats.expired_lease_now_authenticated_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.lease.active.authenticated.text") %> <span class="count">(<%= resource_stats.active_lease_now_authenticated_concerns_count %>)</span></li> | ||
<li><%= t("curation_concerns.visibility.lease.active.open.text") %> <span class="count">(<%= resource_stats.active_lease_now_open_concerns_count %>)</span></li> | ||
</ul> | ||
<% resource_stats = @configuration[:data_sources][:resource_stats].new %> | ||
<%= render "resource_stats", resource_stats: resource_stats %> |
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