Skip to content

Commit

Permalink
Use TimeService when determining expired embargoes/leases (#6972)
Browse files Browse the repository at this point in the history
* Use TimeService when determining expired embargoes/leases

This allows timely local testing without waiting a day for the expiration.

* Cast to UTC Time obj for proper format
  • Loading branch information
dlpierce authored Nov 11, 2024
1 parent 5c07d4f commit d60db08
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion app/search_builders/hyrax/expired_embargo_search_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ class ExpiredEmbargoSearchBuilder < EmbargoSearchBuilder

def only_expired_embargoes(solr_params)
solr_params[:fq] ||= []
solr_params[:fq] = 'embargo_release_date_dtsi:[* TO NOW]'
solr_params[:fq] = "embargo_release_date_dtsi:[* TO #{now}]"
end

private

def now
Hyrax::TimeService.time_in_utc.utc.xmlschema
end
end
end
8 changes: 7 additions & 1 deletion app/search_builders/hyrax/expired_lease_search_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ class ExpiredLeaseSearchBuilder < LeaseSearchBuilder

def only_expired_leases(solr_params)
solr_params[:fq] ||= []
solr_params[:fq] = 'lease_expiration_date_dtsi:[* TO NOW]'
solr_params[:fq] = "lease_expiration_date_dtsi:[* TO #{now}]"
end

private

def now
Hyrax::TimeService.time_in_utc.utc.xmlschema
end
end
end

0 comments on commit d60db08

Please sign in to comment.