pimbongaerts / mesophotic

Ruby on Rails application to host scientific information on mesophotic coral ecosystems
http://www.mesophotic.org
MIT License
1 stars 1 forks source link

Batch validations #147

Closed veronicar239 closed 5 months ago

veronicar239 commented 8 months ago

@ryanbooker Our goal is to re-validate publications where the validation has expired (old publications where I fixed a specific thing but the validators are no longer active members). Using the publication ID number ("Pub ID" column) in the google sheet tab # 8 below, revalidate all publications listed in the column "ID".

Sheet # 8 "Re-validate" https://docs.google.com/spreadsheets/d/1_Ppq8Lg_-zo5jq2sYwsf3tsEP2HIvV24ueCihvpOlHM/edit#gid=425816306

pimbongaerts commented 5 months ago

Just for some more info if that is helpful.

For all the Publication IDs in column A of that sheet (currently 115 in total) - we want to "touch" the existing validations so that they are "validated" again.

As a reminder, "validated" publications are defined as having 2 validations of which the updated_at date is equal or later than the updated_at of the publication:

  scope :validated, -> {
    select("publications.*, COUNT(validations.id) AS validations_count")
    .joins("LEFT JOIN validations
      ON validations.validatable_id = publications.id
      AND validations.updated_at >= publications.updated_at")
    .group("publications.id")
    .having("validations_count >= 2")
  }

In the controller revalidating is done for each individual validation like this (but we want "validations.all" instead):

  def touch_validation
      @publication.validations.find_by_user_id(params[:format]).touch
      redirect_back fallback_location: root_path,
                    notice: 'Publication was successfully revalidated.'
  end
ryanbooker commented 5 months ago

Ok. Admins can now search for "all expired" publications, and when they do they will now see a "Revalidate All" button.

Pressing "Revalidate All" will revalidate everything matching the search criteria.

I noticed that there are only 93 publications currently listed as expired, where the spreadsheet suggests there are 116.