Skip to content

Commit

Permalink
Add migration to re-render live forms
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperka committed Nov 2, 2023
1 parent 74e1982 commit 55ce526
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 9 additions & 0 deletions db/migrate/20231102211012_render_live_forms_for_meta_tags.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class RenderLiveFormsForMetaTags < ActiveRecord::Migration[6.1]
def up
puts "Rendering #{Form.published.count} forms..."
Form.published.find_each do |f|
puts "Rendering #{f.name}..."
ODK::FormRenderJob.perform_now(f)
end
end
end
10 changes: 6 additions & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_03_14_140916) do
ActiveRecord::Schema.define(version: 2023_11_02_211012) do

# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -678,9 +679,10 @@
add_foreign_key "user_groups", "missions", name: "user_groups_mission_id_fkey", on_update: :restrict, on_delete: :restrict
add_foreign_key "users", "missions", column: "last_mission_id", name: "users_last_mission_id_fkey", on_update: :restrict, on_delete: :nullify
add_foreign_key "whitelistings", "users", name: "whitelistings_user_id_fkey", on_update: :restrict, on_delete: :restrict
create_trigger("answers_before_insert_update_row_tr", generated: true, compatibility: 1)
.on("answers")
.before(:insert, :update) do
create_trigger("answers_before_insert_update_row_tr", :generated => true, :compatibility => 1).
on("answers").
before(:insert, :update) do
"new.tsv := TO_TSVECTOR('simple', COALESCE( new.value, to_char(new.date_value, 'YYYY-MM-DD'), to_char(new.time_value, 'HH24hMImSSs'), to_char(new.datetime_value, 'YYYY-MM-DD HH24hMImSSs'), (SELECT STRING_AGG(opt_name_translation.value, ' ') FROM options, option_nodes, JSONB_EACH_TEXT(options.name_translations) opt_name_translation WHERE options.id = option_nodes.option_id AND (option_nodes.id = new.option_node_id OR option_nodes.id IN (SELECT option_node_id FROM choices WHERE answer_id = new.id))), '' ));"
end

end

0 comments on commit 55ce526

Please sign in to comment.