Skip to content

Commit

Permalink
chore: ensure rfh categories seeded
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantk committed Oct 10, 2023
1 parent 81bd014 commit 959a67d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
7 changes: 7 additions & 0 deletions db/migrate/20231010122627_re_seed_rfh_categories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ReSeedRfhCategories < ActiveRecord::Migration[7.0]
def up
Rake::Task['request_for_help:seed_categories'].invoke
end

def down; end
end
42 changes: 23 additions & 19 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2023_09_19_144709) do
ActiveRecord::Schema[7.0].define(version: 2023_10_10_122627) do
create_sequence "evaluation_refs"
create_sequence "framework_refs"

Expand Down Expand Up @@ -340,8 +340,8 @@
t.string "title"
t.text "body"
t.string "slug"
t.datetime "created_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
t.datetime "updated_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
t.datetime "created_at", precision: nil, default: -> { "CURRENT_TIMESTAMP" }, null: false
t.datetime "updated_at", precision: nil, default: -> { "CURRENT_TIMESTAMP" }, null: false
t.string "contentful_id"
t.text "sidebar"
t.string "breadcrumbs", default: [], array: true
Expand Down Expand Up @@ -643,6 +643,8 @@
t.jsonb "cc_recipients"
t.jsonb "bcc_recipients"
t.uuid "template_id"
t.string "ticket_type"
t.uuid "ticket_id"
t.index ["in_reply_to_id"], name: "index_support_emails_on_in_reply_to_id"
t.index ["template_id"], name: "index_support_emails_on_template_id"
end
Expand Down Expand Up @@ -761,7 +763,7 @@
t.string "ukprn"
t.string "telephone_number"
t.jsonb "local_authority"
t.datetime "opened_date"
t.datetime "opened_date", precision: nil
t.string "number"
t.string "rsc_region"
t.string "trust_name"
Expand Down Expand Up @@ -1089,21 +1091,6 @@
FROM support_interactions si_1
WHERE (si_1.event_type = 8)) sir ON ((si.case_id = sir.case_id)));
SQL
create_view "support_message_threads", sql_definition: <<-SQL
SELECT DISTINCT ON (se.outlook_conversation_id, se.case_id) se.outlook_conversation_id AS conversation_id,
se.case_id,
( SELECT jsonb_agg(DISTINCT elems.value) AS jsonb_agg
FROM support_emails se2,
LATERAL jsonb_array_elements(se2.recipients) elems(value)
WHERE ((se2.outlook_conversation_id)::text = (se.outlook_conversation_id)::text)) AS recipients,
se.subject,
( SELECT se2.sent_at
FROM support_emails se2
WHERE ((se2.outlook_conversation_id)::text = (se.outlook_conversation_id)::text)
ORDER BY se2.sent_at DESC
LIMIT 1) AS last_updated
FROM support_emails se;
SQL
create_view "support_tower_cases", sql_definition: <<-SQL
SELECT sc.id,
sc.state,
Expand All @@ -1122,4 +1109,21 @@
LEFT JOIN support_towers tow ON ((cat.support_tower_id = tow.id)))
WHERE (sc.state = ANY (ARRAY[0, 1, 3]));
SQL
create_view "support_message_threads", sql_definition: <<-SQL
SELECT DISTINCT ON (se.outlook_conversation_id, se.ticket_id) se.outlook_conversation_id AS conversation_id,
se.case_id,
se.ticket_id,
se.ticket_type,
( SELECT jsonb_agg(DISTINCT elems.value) AS jsonb_agg
FROM support_emails se2,
LATERAL jsonb_array_elements(se2.recipients) elems(value)
WHERE ((se2.outlook_conversation_id)::text = (se.outlook_conversation_id)::text)) AS recipients,
se.subject,
( SELECT se2.sent_at
FROM support_emails se2
WHERE ((se2.outlook_conversation_id)::text = (se.outlook_conversation_id)::text)
ORDER BY se2.sent_at DESC
LIMIT 1) AS last_updated
FROM support_emails se;
SQL
end

0 comments on commit 959a67d

Please sign in to comment.