fix completed_at index
This commit is contained in:
@@ -104,7 +104,7 @@ module Api
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def maybe_filder_by_completed_at(submitters, params)
|
def maybe_filter_by_completed_at(submitters, params)
|
||||||
if params[:completed_after].present?
|
if params[:completed_after].present?
|
||||||
submitters = submitters.where(completed_at: Time.zone.parse(params[:completed_after])..)
|
submitters = submitters.where(completed_at: Time.zone.parse(params[:completed_after])..)
|
||||||
end
|
end
|
||||||
@@ -177,7 +177,7 @@ module Api
|
|||||||
submitters = submitters.joins(:submission).where(submissions: { template_id: params[:template_id] })
|
submitters = submitters.joins(:submission).where(submissions: { template_id: params[:template_id] })
|
||||||
end
|
end
|
||||||
|
|
||||||
maybe_filder_by_completed_at(submitters, params)
|
maybe_filter_by_completed_at(submitters, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def assign_external_id(submitter, attrs)
|
def assign_external_id(submitter, attrs)
|
||||||
|
|||||||
@@ -28,8 +28,8 @@
|
|||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
# index_submitters_on_account_id_and_completed_at (account_id,completed_at) WHERE (completed_at IS NOT NULL)
|
||||||
# index_submitters_on_account_id_and_id (account_id,id)
|
# index_submitters_on_account_id_and_id (account_id,id)
|
||||||
# index_submitters_on_completed_at_and_account_id (completed_at,account_id)
|
|
||||||
# index_submitters_on_email (email)
|
# index_submitters_on_email (email)
|
||||||
# index_submitters_on_external_id (external_id)
|
# index_submitters_on_external_id (external_id)
|
||||||
# index_submitters_on_slug (slug) UNIQUE
|
# index_submitters_on_slug (slug) UNIQUE
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class RemoveSubmittersCompletedAtIndex < ActiveRecord::Migration[8.1]
|
||||||
|
def up
|
||||||
|
remove_index :submitters, %i[completed_at account_id], if_exists: true
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
add_index :submitters, %i[completed_at account_id], if_not_exists: true
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AddSubmittersCompletedAtPartialIndex < ActiveRecord::Migration[8.1]
|
||||||
|
def up
|
||||||
|
add_index :submitters, %i[account_id completed_at], where: 'completed_at IS NOT NULL', if_not_exists: true
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_index :submitters, %i[account_id completed_at], if_exists: true
|
||||||
|
end
|
||||||
|
end
|
||||||
+2
-2
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.1].define(version: 2026_05_06_121640) do
|
ActiveRecord::Schema[8.1].define(version: 2026_06_27_083558) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "btree_gin"
|
enable_extension "btree_gin"
|
||||||
enable_extension "pg_catalog.plpgsql"
|
enable_extension "pg_catalog.plpgsql"
|
||||||
@@ -405,8 +405,8 @@ ActiveRecord::Schema[8.1].define(version: 2026_05_06_121640) do
|
|||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "uuid", null: false
|
t.string "uuid", null: false
|
||||||
t.text "values", null: false
|
t.text "values", null: false
|
||||||
|
t.index ["account_id", "completed_at"], name: "index_submitters_on_account_id_and_completed_at", where: "(completed_at IS NOT NULL)"
|
||||||
t.index ["account_id", "id"], name: "index_submitters_on_account_id_and_id"
|
t.index ["account_id", "id"], name: "index_submitters_on_account_id_and_id"
|
||||||
t.index ["completed_at", "account_id"], name: "index_submitters_on_completed_at_and_account_id"
|
|
||||||
t.index ["email"], name: "index_submitters_on_email"
|
t.index ["email"], name: "index_submitters_on_email"
|
||||||
t.index ["external_id"], name: "index_submitters_on_external_id"
|
t.index ["external_id"], name: "index_submitters_on_external_id"
|
||||||
t.index ["slug"], name: "index_submitters_on_slug", unique: true
|
t.index ["slug"], name: "index_submitters_on_slug", unique: true
|
||||||
|
|||||||
Reference in New Issue
Block a user