Skip to content

Instantly share code, notes, and snippets.

@scytacki
Last active August 5, 2022 14:20
Show Gist options
  • Save scytacki/c82ac7bf1a38abe459c6cfaab397237f to your computer and use it in GitHub Desktop.
Save scytacki/c82ac7bf1a38abe459c6cfaab397237f to your computer and use it in GitHub Desktop.
Embeddable::ImageQuestion.joins(:converted_interactive).where("drawing_prompt like '%<img%' or prompt like '%<img%'").count
=> 60
Embeddable::OpenResponse.joins(:converted_interactive).where("prompt like '%<img%'").count
=> 1525
Embeddable::MultipleChoice.joins(:converted_interactive).where("prompt like '%<img%'").count
=> 622
ManagedInteractive.where("legacy_ref_id is not null").where("authored_state like '%\\u003Cimg%'").count
=> 2218
For some reason I don't understand the `<` character gets turned into `\\u003C` when searching `\u003C` and `<` match.
But `\\u003C` do not.
acts = ManagedInteractive.where("legacy_ref_id is not null").where("authored_state like '%\\u003Cimg%'")
.includes(interactive_page: [:lightweight_activity]).all
.group_by{|i| i.interactive_page.lightweight_activity};nil
irb(main):035:0> acts.count
=> 1519
irb(main):038:0> projs.keys.size
=> 17
irb(main):041:0> projs.map { |proj, acts| [proj&.title, acts.size]}
=> [["Molecular Workbench", 7], ["High Adventure Science", 29], [nil, 181], ["Interactions", 67],
["RITES", 2], ["InquirySpace", 13], ["NGSS Assessments", 18], ["ITSI", 1116], ["Building Models", 12],
["InquirySpace 2", 13], ["GEODE", 19], ["Precipitating Change", 6], ["ConnectedBio", 16],
["Geniventure", 1], ["Default Project", 2], ["GeoHazard", 13], ["GeoCode Tephra", 4]]
mis = ManagedInteractive.where("legacy_ref_id is not null").where("authored_state like '%\\u003Cimg%'").includes(interactive_page: [:lightweight_activity]); nil
mi_info = mis.all.map{|mi| {url: "https://authoring-migrate.concord.org/activities/#{mi.interactive_page.lightweight_activity.id}/pages/#{mi.interactive_page.id}/edit", mi_id: mi.id, authored_state: mi.authored_state} }; nil
require 'csv'
output = CSV.generate do |csv|
mi_info.each { |mi| csv << [mi[:mi_id], mi[:url], mi[:authored_state]] }
end; nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment