diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 6f03d21b9..ed415da08 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -12,7 +12,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0078-move_resubmission_date', + DB_VERSION: '0079-fill_linked_user_id_of_contributions', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index bd985d2d2..c07a691a3 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -451,6 +451,7 @@ export class ContributionResolver { transaction.userId = contribution.userId transaction.userGradidoID = user.gradidoID transaction.userName = fullName(user.firstName, user.lastName) + transaction.linkedUserId = contribution.moderatorId transaction.previous = lastTransaction ? lastTransaction.id : null transaction.amount = contribution.amount transaction.creationDate = contribution.contributionDate diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 8d35708a6..d379efef3 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -254,6 +254,9 @@ export class TransactionResolver { // userTransactions.forEach((transaction: dbTransaction) => { // use normal for loop because of timing problems with await in forEach-loop for (const transaction of userTransactions) { + if (transaction.typeId === TransactionTypeId.CREATION) { + continue + } if (transaction.linkedUserId && !involvedUserIds.includes(transaction.linkedUserId)) { involvedUserIds.push(transaction.linkedUserId) } diff --git a/database/migrations/0079-fill_linked_user_id_of_contributions.ts b/database/migrations/0079-fill_linked_user_id_of_contributions.ts new file mode 100644 index 000000000..5fe62af30 --- /dev/null +++ b/database/migrations/0079-fill_linked_user_id_of_contributions.ts @@ -0,0 +1,13 @@ +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + `UPDATE \`transactions\` AS t + JOIN \`contributions\` AS c ON t.id = c.transaction_id + SET t.linked_user_id = c.confirmed_by + WHERE t.type_id = ?`, + [1], + ) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn(`UPDATE \`transactions\` SET \`linked_user_id\` = NULL where \`type_id\` = ?;`, [1]) +} diff --git a/dht-node/src/config/index.ts b/dht-node/src/config/index.ts index 2548166f4..b0661126f 100644 --- a/dht-node/src/config/index.ts +++ b/dht-node/src/config/index.ts @@ -4,7 +4,7 @@ import dotenv from 'dotenv' dotenv.config() const constants = { - DB_VERSION: '0078-move_resubmission_date', + DB_VERSION: '0079-fill_linked_user_id_of_contributions', LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info LOG_LEVEL: process.env.LOG_LEVEL || 'info', diff --git a/federation/src/config/index.ts b/federation/src/config/index.ts index 036ce67ee..9ce6f18e3 100644 --- a/federation/src/config/index.ts +++ b/federation/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0078-move_resubmission_date', + DB_VERSION: '0079-fill_linked_user_id_of_contributions', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info