From 83ba678b4842d8438abc709ed3f357bd55e1c2e4 Mon Sep 17 00:00:00 2001 From: Benjamin Piouffle Date: Thu, 19 Dec 2024 08:50:20 +0100 Subject: [PATCH] perf: misc enhancements (#10550) --- ...20241218093842-confirm-email-token-index.js | 18 ++++++++++++++++++ server/graphql/loaders/index.js | 1 + server/lib/queries.js | 2 ++ 3 files changed, 21 insertions(+) create mode 100644 migrations/20241218093842-confirm-email-token-index.js diff --git a/migrations/20241218093842-confirm-email-token-index.js b/migrations/20241218093842-confirm-email-token-index.js new file mode 100644 index 00000000000..5fec80ea342 --- /dev/null +++ b/migrations/20241218093842-confirm-email-token-index.js @@ -0,0 +1,18 @@ +'use strict'; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.addIndex('Users', ['emailConfirmationToken'], { + unique: true, + where: { + deletedAt: { [Sequelize.Op.eq]: null }, + emailConfirmationToken: { [Sequelize.Op.ne]: null }, + }, + }); + }, + + async down(queryInterface, Sequelize) { + await queryInterface.removeIndex('Users', ['emailConfirmationToken']); + }, +}; diff --git a/server/graphql/loaders/index.js b/server/graphql/loaders/index.js index 15bd6b1b5f8..3490333e29e 100644 --- a/server/graphql/loaders/index.js +++ b/server/graphql/loaders/index.js @@ -616,6 +616,7 @@ export const loaders = req => { AND "Transaction"."RefundTransactionId" IS NULL AND "Transaction"."type" = 'CREDIT' AND "Transaction"."kind" IN ('CONTRIBUTION', 'ADDED_FUNDS') + AND "Transaction"."deletedAt" IS NULL GROUP BY "Order"."TierId"; `, { diff --git a/server/lib/queries.js b/server/lib/queries.js index 82796e2f679..8dad3e065ac 100644 --- a/server/lib/queries.js +++ b/server/lib/queries.js @@ -378,6 +378,8 @@ const getGiftCardBatchesForCollective = async collectiveId => { FROM "PaymentMethods" pm INNER JOIN "PaymentMethods" spm ON pm."SourcePaymentMethodId" = spm.id WHERE spm."CollectiveId" = :collectiveId + AND pm."deletedAt" IS NULL + AND spm."deletedAt" IS NULL GROUP BY pm.batch ORDER BY pm.batch ASC `,