benwbrum / fromthepage

FromThePage is a wiki-like application for crowdsourcing transcription of handwritten documents.
http://fromthepage.com
GNU Affero General Public License v3.0
169 stars 50 forks source link

Needs review pages turn to Incomplete upon review #4209

Closed benwbrum closed 2 weeks ago

benwbrum commented 2 weeks ago

Currently, for projects marked as Review Optional, a page in the review state (i.e. the page Needs Review) is marked as Incomplete whenever a user approves the page by unchecking the "Mark as needing review" box and hitting Save.

We need to fix this behavior and remediate the data.

To remediate the data, we need a migration script that finds all pages in status Incomplete that have a previous page version in Needs Review state, and update the page status to Transcribed or (if the page has article links) Indexed.

benwbrum commented 2 weeks ago

Remediation algorithm:

pages_to_remediate = Page.where(status: 'incomplete').select{|page| page.page_versions.second&.status == 'review'}
pages_to_remediate.each do |page|
  if page.page_article_links.present?
    page.update_columns(status: Page::STATUS_INDEXED)
  else
    page.update_columns(status: Page::STATUS_TRANSCRIBED)
  end
end