From bf086e7866d5d4cc3d26a6375c6497f9314de6b8 Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Tue, 28 Jun 2022 16:41:43 +0200 Subject: [PATCH 001/103] add migration script begin --- ...0041-update_transactions_for_blockchain.ts | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 database/migrations/0041-update_transactions_for_blockchain.ts diff --git a/database/migrations/0041-update_transactions_for_blockchain.ts b/database/migrations/0041-update_transactions_for_blockchain.ts new file mode 100644 index 000000000..9662d84cf --- /dev/null +++ b/database/migrations/0041-update_transactions_for_blockchain.ts @@ -0,0 +1,81 @@ +/* MIGRATION for updating transactions from the past to follow the blockchain rules*/ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // split creation transaction with 3000 GDD created in one transaction what isn't allowed + const transactionDivData = [ + {date: new Date('2019-12-01T01:00:00'), memo: 'Aktives Grundeinkommen für GL. Dez'}, + {date: new Date('2019-01-01T01:00:00'), memo: 'Aktives Grundeinkommen für GL. Jan'}, + {date: new Date('2019-02-01T01:00:00'), memo: 'Aktives Grundeinkommen für GL. Feb'} + ] + /* + | id | int(10) unsigned | NO | PRI | NULL | auto_increment | + | user_id | int(10) | YES | | NULL | | + | previous | int(10) unsigned | YES | UNI | NULL | | + | type_id | int(10) | YES | | NULL | | + | amount | decimal(40,20) | YES | | NULL | | + | balance | decimal(40,20) | YES | | NULL | | + | balance_date | datetime | NO | | current_timestamp() | | + | decay | decimal(40,20) | YES | | NULL | | + | decay_start | datetime | YES | | NULL | | + | memo | varchar(255) | NO | | NULL | | + | creation_date | datetime | YES | | NULL | | + | linked_user_id | int(10) unsigned | YES | | NULL | | + | linked_transaction_id | int(10) | YES | | NULL | | + | transaction_link_id | int(10) unsigned | YES | | NULL | | + + */ + + transactionDivData.forEach(({date:Date, memo:string}, index)=> { + if(!index) { + queryFn(` + INSERT INTO transactions( + user_id, type_id, amount, balance, + balance_date, decay, decay_start, + memo, creation_date, linked_user_id + ) VALUES( + 275, 1, 1000, ?, + ? + )`, [1000 * (index + 1), date]) + + } else { + //queryFn('INSERT INTO transactions(user_id, previous, type_id, amount, balance, balance_date, decay, decay_start, memo, creation_date, linked_user_id)') + } + + }) + /* + Profiler splitTransactionTime; + Poco::Data::Statement insertTransactions(dbSession); + std::string memo; + Poco::DateTime received(2020, 3, 30, 8, 59, 55); + insertTransactions << "INSERT INTO " << mTempTransactionsTableName + << "(transaction_type_id, memo, received) VALUES(1, ?, ?)", + use(memo), use(received); + + Poco::Data::Statement insertCreationTransactions(dbSession); + int amount = 10000000; + Poco::DateTime targetDate(2019, 12, 1, 1, 0, 0); + insertCreationTransactions << "INSERT INTO " << mTempCreationTableName + << "(transaction_id, state_user_id, amount, target_date) VALUES(LAST_INSERT_ID(), 275, ?, ?)", + use(amount), use(targetDate); + + for (auto it = transactionDivData.begin(); it != transactionDivData.end(); it++) { + targetDate = it->first; + memo = it->second; + insertTransactions.execute(); + insertCreationTransactions.execute(); + } + Poco::Data::Statement removeInvalidTransaction(dbSession); + removeInvalidTransaction << "delete from " << mTempCreationTableName << " where id = 150", now; + removeInvalidTransaction.reset(dbSession); + removeInvalidTransaction << "delete from " << mTempTransactionsTableName << " where id = 224", now; + speedLog.information("time for split transaction: %s", splitTransactionTime.string()); + */ + //await queryFn('DROP TABLE `user_setting`;') + } + + export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + + } + \ No newline at end of file From dbe2ec4845390e116dd210cb1f04ae4356a1c4df Mon Sep 17 00:00:00 2001 From: Dario bb Date: Tue, 28 Jun 2022 18:29:00 +0200 Subject: [PATCH 002/103] implement code translated in js from c++ from gradido blockchain connector --- ...0041-update_transactions_for_blockchain.ts | 170 ++++++++++++------ 1 file changed, 112 insertions(+), 58 deletions(-) diff --git a/database/migrations/0041-update_transactions_for_blockchain.ts b/database/migrations/0041-update_transactions_for_blockchain.ts index 9662d84cf..3f4e47abb 100644 --- a/database/migrations/0041-update_transactions_for_blockchain.ts +++ b/database/migrations/0041-update_transactions_for_blockchain.ts @@ -1,15 +1,19 @@ -/* MIGRATION for updating transactions from the past to follow the blockchain rules*/ +/* MIGRATION for updating transactions from the past to follow the blockchain rules */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/no-explicit-any */ export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { - // split creation transaction with 3000 GDD created in one transaction what isn't allowed - const transactionDivData = [ - {date: new Date('2019-12-01T01:00:00'), memo: 'Aktives Grundeinkommen für GL. Dez'}, - {date: new Date('2019-01-01T01:00:00'), memo: 'Aktives Grundeinkommen für GL. Jan'}, - {date: new Date('2019-02-01T01:00:00'), memo: 'Aktives Grundeinkommen für GL. Feb'} - ] - /* + interface TransactionDivData { + date: Date + memo: string + } + // split creation transaction with 3000 GDD created in one transaction what isn't allowed + const transactionDivData: TransactionDivData[] = [ + { date: new Date('2019-12-01T01:00:00'), memo: 'Aktives Grundeinkommen für GL. Dez' }, + { date: new Date('2019-01-01T01:00:00'), memo: 'Aktives Grundeinkommen für GL. Jan' }, + { date: new Date('2019-02-01T01:00:00'), memo: 'Aktives Grundeinkommen für GL. Feb' }, + ] + /* | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | user_id | int(10) | YES | | NULL | | | previous | int(10) unsigned | YES | UNI | NULL | | @@ -26,56 +30,106 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis | transaction_link_id | int(10) unsigned | YES | | NULL | | */ - - transactionDivData.forEach(({date:Date, memo:string}, index)=> { - if(!index) { - queryFn(` - INSERT INTO transactions( - user_id, type_id, amount, balance, - balance_date, decay, decay_start, - memo, creation_date, linked_user_id - ) VALUES( - 275, 1, 1000, ?, - ? - )`, [1000 * (index + 1), date]) - - } else { - //queryFn('INSERT INTO transactions(user_id, previous, type_id, amount, balance, balance_date, decay, decay_start, memo, creation_date, linked_user_id)') - } - - }) - /* - Profiler splitTransactionTime; - Poco::Data::Statement insertTransactions(dbSession); - std::string memo; - Poco::DateTime received(2020, 3, 30, 8, 59, 55); - insertTransactions << "INSERT INTO " << mTempTransactionsTableName - << "(transaction_type_id, memo, received) VALUES(1, ?, ?)", - use(memo), use(received); - Poco::Data::Statement insertCreationTransactions(dbSession); - int amount = 10000000; - Poco::DateTime targetDate(2019, 12, 1, 1, 0, 0); - insertCreationTransactions << "INSERT INTO " << mTempCreationTableName - << "(transaction_id, state_user_id, amount, target_date) VALUES(LAST_INSERT_ID(), 275, ?, ?)", - use(amount), use(targetDate); - - for (auto it = transactionDivData.begin(); it != transactionDivData.end(); it++) { - targetDate = it->first; - memo = it->second; - insertTransactions.execute(); - insertCreationTransactions.execute(); + transactionDivData.forEach((transactionDivData, index) => { + let sqlQuery = "INSERT INTO 'transactions'(user_id," + let sqlValues = 'VALUES(275,' + if (index) { + sqlQuery += 'previous,' + sqlValues += 'LAST_INSERT_ID()' } - Poco::Data::Statement removeInvalidTransaction(dbSession); - removeInvalidTransaction << "delete from " << mTempCreationTableName << " where id = 150", now; - removeInvalidTransaction.reset(dbSession); - removeInvalidTransaction << "delete from " << mTempTransactionsTableName << " where id = 224", now; - speedLog.information("time for split transaction: %s", splitTransactionTime.string()); - */ - //await queryFn('DROP TABLE `user_setting`;') + sqlQuery += `type_id, amount, balance, + balance_date, + memo, creation_date` + sqlValues += '1, 1000, ?, ?, ?, ?' + + sqlQuery += ')' + sqlValues += ')' + queryFn(sqlQuery + sqlValues, [ + 1000 * (index + 1), + transactionDivData.date, + transactionDivData.memo, + transactionDivData.date, + ]) + }) + // remove original transaction + queryFn("DELETE FROM 'transactions' where id = 150") + + // update previous field of first transaction after splitted transaction + queryFn("UPDATE 'transactions' SET 'previous' = LAST_INSERT_ID() WHERE 'previous' = 150") + + // ---------------------------------------------------------------------------------------------- + // update creation_date for transactions with creation_date == balance_date + // !cannot made be undone easily! + + // update entries from which memo contain month name (most cases) + interface ReplaceSet { + monthName: string + monthValue: number + yearValue: number } - - export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { - - } - \ No newline at end of file + const replaceSets: ReplaceSet[] = [ + { monthName: 'Dez', monthValue: 12, yearValue: 2019 }, + { monthName: 'Jan', monthValue: 1, yearValue: 2020 }, + { monthName: 'Feb', monthValue: 2, yearValue: 2020 }, + { monthName: 'M_rz', monthValue: 3, yearValue: 2020 }, + { monthName: 'April', monthValue: 4, yearValue: 2020 }, + ] + replaceSets.forEach((replaceSet) => { + let sqlQuery = `update 'transactions' + SET 'creation_date' = DATE_FORMAT('creation_date', CONCAT(?, '-', ?, '-', ` + if (replaceSet.monthName === 'Feb') { + sqlQuery += "IF(DATE_FORMAT(creation_date, '%d') <= 28, '%d', 28)" + } else { + sqlQuery += "'%d'" + } + sqlQuery += `, ' %H:%i:%s')) + WHERE balance_date = creation_date + AND type_id = 1 + AND memo LIKE '%?%'` + + queryFn(sqlQuery, [replaceSet.yearValue, replaceSet.monthValue, replaceSet.monthName]) + }) + + // update entries without month name in memo, simply move creation_date 1 month before balance_date + queryFn(`UPDATE 'transactions' + set creation_date = CAST(DATE_FORMAT(creation_date, CONCAT( + IF(DATE_FORMAT(creation_date, '%m') = 1, DATE_FORMAT(creation_date, '%Y') - 1, '%Y'), + '-', + IF(DATE_FORMAT(creation_date, '%m') = 1, 12, DATE_FORMAT(creation_date, '%m') - 1), + '-', + IF(DATE_FORMAT(creation_date, '%m') = 3, IF(DATE_FORMAT(creation_date, '%d') <= 28, '%d', 28), '%d'), + ' %H:%i:%s')) AS DATETIME) + WHERE balance_date = creation_date + `) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // remove in upgrade added transactions + const creationDates: Date[] = [ + new Date('2019-12-01T01:00:00'), + new Date('2019-01-01T01:00:00'), + new Date('2019-02-01T01:00:00'), + ] + queryFn( + "DELETE FROM 'transactions' WHERE 'user_id' = 275 AND 'creation_date' IN(?,?,?)", + creationDates, + ) + // put back removed transaction + queryFn( + `INSERT INTO 'transactions'( + id, user_id, + type_id, amount, + balance, balance_date, + memo, creation_date + ) VALUES( + 150, 275, + 1, 3000, + 3000, '2020-03-30 06:59:55', + 'Aktives Grundeinkommen für GL. Dez, Jan, Feb', '2020-03-30 06:59:55' + )`, + ) + + // restore previous field of first transaction after splitted transaction + queryFn("UPDATE 'transactions' SET 'previous' = 150 WHERE 'id' = 278") +} From ac18a11256dce888091de1307d9a19dc799d0d50 Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Wed, 29 Jun 2022 12:38:20 +0200 Subject: [PATCH 003/103] simplify code --- ...0041-update_transactions_for_blockchain.ts | 100 +++++------------- 1 file changed, 26 insertions(+), 74 deletions(-) diff --git a/database/migrations/0041-update_transactions_for_blockchain.ts b/database/migrations/0041-update_transactions_for_blockchain.ts index 3f4e47abb..98f794693 100644 --- a/database/migrations/0041-update_transactions_for_blockchain.ts +++ b/database/migrations/0041-update_transactions_for_blockchain.ts @@ -3,60 +3,31 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { - interface TransactionDivData { - date: Date - memo: string - } // split creation transaction with 3000 GDD created in one transaction what isn't allowed - const transactionDivData: TransactionDivData[] = [ - { date: new Date('2019-12-01T01:00:00'), memo: 'Aktives Grundeinkommen für GL. Dez' }, - { date: new Date('2019-01-01T01:00:00'), memo: 'Aktives Grundeinkommen für GL. Jan' }, - { date: new Date('2019-02-01T01:00:00'), memo: 'Aktives Grundeinkommen für GL. Feb' }, + const transactionMemos: string[] = [ + 'Aktives Grundeinkommen für GL. Dez', + 'Aktives Grundeinkommen für GL. Jan', + 'Aktives Grundeinkommen für GL. Feb', ] - /* - | id | int(10) unsigned | NO | PRI | NULL | auto_increment | - | user_id | int(10) | YES | | NULL | | - | previous | int(10) unsigned | YES | UNI | NULL | | - | type_id | int(10) | YES | | NULL | | - | amount | decimal(40,20) | YES | | NULL | | - | balance | decimal(40,20) | YES | | NULL | | - | balance_date | datetime | NO | | current_timestamp() | | - | decay | decimal(40,20) | YES | | NULL | | - | decay_start | datetime | YES | | NULL | | - | memo | varchar(255) | NO | | NULL | | - | creation_date | datetime | YES | | NULL | | - | linked_user_id | int(10) unsigned | YES | | NULL | | - | linked_transaction_id | int(10) | YES | | NULL | | - | transaction_link_id | int(10) unsigned | YES | | NULL | | + const creationDate = new Date('2020-03-30 06:59:55') - */ - - transactionDivData.forEach((transactionDivData, index) => { - let sqlQuery = "INSERT INTO 'transactions'(user_id," - let sqlValues = 'VALUES(275,' - if (index) { - sqlQuery += 'previous,' - sqlValues += 'LAST_INSERT_ID()' - } - sqlQuery += `type_id, amount, balance, - balance_date, - memo, creation_date` - sqlValues += '1, 1000, ?, ?, ?, ?' - - sqlQuery += ')' - sqlValues += ')' - queryFn(sqlQuery + sqlValues, [ - 1000 * (index + 1), - transactionDivData.date, - transactionDivData.memo, - transactionDivData.date, - ]) - }) - // remove original transaction - queryFn("DELETE FROM 'transactions' where id = 150") - - // update previous field of first transaction after splitted transaction - queryFn("UPDATE 'transactions' SET 'previous' = LAST_INSERT_ID() WHERE 'previous' = 150") + queryFn(`UPDATE 'transactions' set amount = 1000, memo = ? WHERE id = 150`, [transactionMemos[0]]) + queryFn( + `INSERT INTO 'transactions'( + user_id, previous, type_id, amount, balance, balance_date, memo, creation_date + ) VALUES( + 275, 150, 1, 1000, 2000, ?, ?, ? + )`, + [creationDate, transactionMemos[1], creationDate], + ) + queryFn( + `INSERT INTO 'transactions'( + user_id, previous, type_id, amount, balance, balance_date, memo, creation_date + ) VALUES( + 275, LAST_INSERT_ID(), 1, 1000, 3000, ?, ?, ? + )`, + [creationDate, transactionMemos[2], creationDate], + ) // ---------------------------------------------------------------------------------------------- // update creation_date for transactions with creation_date == balance_date @@ -105,31 +76,12 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis } export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { - // remove in upgrade added transactions - const creationDates: Date[] = [ - new Date('2019-12-01T01:00:00'), - new Date('2019-01-01T01:00:00'), - new Date('2019-02-01T01:00:00'), - ] + // remove added transaction queryFn( - "DELETE FROM 'transactions' WHERE 'user_id' = 275 AND 'creation_date' IN(?,?,?)", - creationDates, + "DELETE FROM 'transactions' WHERE 'user_id' = 275 AND 'balance' IN(2000, 3000) AND 'amount' = 1000", ) - // put back removed transaction + // rewind transaction to split queryFn( - `INSERT INTO 'transactions'( - id, user_id, - type_id, amount, - balance, balance_date, - memo, creation_date - ) VALUES( - 150, 275, - 1, 3000, - 3000, '2020-03-30 06:59:55', - 'Aktives Grundeinkommen für GL. Dez, Jan, Feb', '2020-03-30 06:59:55' - )`, + `UPDATE 'transactions' set amount = 3000, memo = 'Aktives Grundeinkommen für GL. Dez, Jan, Feb' WHERE id = 150`, ) - - // restore previous field of first transaction after splitted transaction - queryFn("UPDATE 'transactions' SET 'previous' = 150 WHERE 'id' = 278") } From 88e789c53edfd1c711a37e30e6b846d0e0d4362d Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Wed, 29 Jun 2022 16:09:31 +0200 Subject: [PATCH 004/103] tested and fixed --- ...0041-update_transactions_for_blockchain.ts | 87 ++++++++++++------- 1 file changed, 56 insertions(+), 31 deletions(-) diff --git a/database/migrations/0041-update_transactions_for_blockchain.ts b/database/migrations/0041-update_transactions_for_blockchain.ts index 98f794693..6ecdfffa9 100644 --- a/database/migrations/0041-update_transactions_for_blockchain.ts +++ b/database/migrations/0041-update_transactions_for_blockchain.ts @@ -11,28 +11,46 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis ] const creationDate = new Date('2020-03-30 06:59:55') - queryFn(`UPDATE 'transactions' set amount = 1000, memo = ? WHERE id = 150`, [transactionMemos[0]]) - queryFn( - `INSERT INTO 'transactions'( - user_id, previous, type_id, amount, balance, balance_date, memo, creation_date + await queryFn(`UPDATE \`transactions\` set \`amount\` = 1000, \`balance\` = 1000, \`memo\` = ? WHERE \`id\` = 150`, [ + transactionMemos[0], + ]) + + // [ RowDataPacket { 'MAX(`id`)': 6828 } ] + const lastTransactionId = (await queryFn(`SELECT MAX(\`id\`) as max_id from \`transactions\``))[0].max_id + // dummy id to insert two transactions before this (previous has an index on it) + await queryFn(`UPDATE \`transactions\` set \`previous\` = ? WHERE \`id\` = 278`, [lastTransactionId + 30]) + + await queryFn( + `INSERT INTO \`transactions\`( + \`user_id\`, \`previous\`, \`type_id\`, \`amount\`, \`balance\`, + \`balance_date\`, \`decay\`, \`memo\`, \`creation_date\` ) VALUES( - 275, 150, 1, 1000, 2000, ?, ?, ? + 275, 150, 1, 1000, 2000, + ?, 0, ?, ? )`, [creationDate, transactionMemos[1], creationDate], ) - queryFn( - `INSERT INTO 'transactions'( - user_id, previous, type_id, amount, balance, balance_date, memo, creation_date + await queryFn( + `INSERT INTO \`transactions\`( + \`user_id\`, \`previous\`, \`type_id\`, \`amount\`, \`balance\`, + \`balance_date\`, \`decay\`, \`memo\`, \`creation_date\` ) VALUES( - 275, LAST_INSERT_ID(), 1, 1000, 3000, ?, ?, ? + 275, LAST_INSERT_ID(), 1, 1000, 3000, + ?, 0, ?, ? )`, - [creationDate, transactionMemos[2], creationDate], + [creationDate, transactionMemos[2], creationDate], ) + await queryFn(`UPDATE \`transactions\` set \`previous\` = LAST_INSERT_ID() WHERE \`id\` = 278`) // ---------------------------------------------------------------------------------------------- // update creation_date for transactions with creation_date == balance_date // !cannot made be undone easily! + // make copy of transaction_creations table for easy debugging workflow + await queryFn(`DROP TABLE IF EXISTS \`transactions_temp\``) + await queryFn(`CREATE TABLE \`transactions_temp\` LIKE transactions`) + await queryFn(`INSERT INTO \`transactions_temp\` SELECT * FROM \`transactions\``) + // update entries from which memo contain month name (most cases) interface ReplaceSet { monthName: string @@ -40,30 +58,30 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis yearValue: number } const replaceSets: ReplaceSet[] = [ - { monthName: 'Dez', monthValue: 12, yearValue: 2019 }, - { monthName: 'Jan', monthValue: 1, yearValue: 2020 }, - { monthName: 'Feb', monthValue: 2, yearValue: 2020 }, - { monthName: 'M_rz', monthValue: 3, yearValue: 2020 }, - { monthName: 'April', monthValue: 4, yearValue: 2020 }, + { monthName: '%Dez%', monthValue: 12, yearValue: 2019 }, + { monthName: '%Jan%', monthValue: 1, yearValue: 2020 }, + { monthName: '%Feb%', monthValue: 2, yearValue: 2020 }, + { monthName: '%M_rz%', monthValue: 3, yearValue: 2020 }, + { monthName: '%April%', monthValue: 4, yearValue: 2020 }, ] - replaceSets.forEach((replaceSet) => { - let sqlQuery = `update 'transactions' - SET 'creation_date' = DATE_FORMAT('creation_date', CONCAT(?, '-', ?, '-', ` - if (replaceSet.monthName === 'Feb') { - sqlQuery += "IF(DATE_FORMAT(creation_date, '%d') <= 28, '%d', 28)" + for(const replaceSet of replaceSets) { + let sqlQuery = `update \`transactions_temp\` + SET \`creation_date\` = DATE_FORMAT(\`creation_date\`, CONCAT(?, '-', ?, '-', ` + if (replaceSet.monthName === '%Feb%') { + sqlQuery += "IF(DATE_FORMAT(`creation_date`, '%d') <= 28, '%d', 28)" } else { sqlQuery += "'%d'" } sqlQuery += `, ' %H:%i:%s')) - WHERE balance_date = creation_date - AND type_id = 1 - AND memo LIKE '%?%'` + WHERE \`balance_date\` = \`creation_date\` + AND \`type_id\` = 1 + AND \`memo\` LIKE ?` - queryFn(sqlQuery, [replaceSet.yearValue, replaceSet.monthValue, replaceSet.monthName]) - }) + await queryFn(sqlQuery, [replaceSet.yearValue, replaceSet.monthValue, replaceSet.monthName]) + } // update entries without month name in memo, simply move creation_date 1 month before balance_date - queryFn(`UPDATE 'transactions' + await queryFn(`UPDATE \`transactions_temp\` set creation_date = CAST(DATE_FORMAT(creation_date, CONCAT( IF(DATE_FORMAT(creation_date, '%m') = 1, DATE_FORMAT(creation_date, '%Y') - 1, '%Y'), '-', @@ -71,17 +89,24 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis '-', IF(DATE_FORMAT(creation_date, '%m') = 3, IF(DATE_FORMAT(creation_date, '%d') <= 28, '%d', 28), '%d'), ' %H:%i:%s')) AS DATETIME) - WHERE balance_date = creation_date + WHERE balance_date = creation_date `) } + export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // remove added transaction - queryFn( - "DELETE FROM 'transactions' WHERE 'user_id' = 275 AND 'balance' IN(2000, 3000) AND 'amount' = 1000", + await queryFn( + `DELETE FROM \`transactions\` + WHERE \`user_id\` = 275 AND \`balance\` IN (2000, 3000) AND \`amount\` = 1000`, ) + // rewind transaction to split - queryFn( - `UPDATE 'transactions' set amount = 3000, memo = 'Aktives Grundeinkommen für GL. Dez, Jan, Feb' WHERE id = 150`, + await queryFn( + `UPDATE \`transactions\` set \`amount\` = 3000, \`memo\` = 'Aktives Grundeinkommen für GL. Dez, Jan, Feb' + WHERE \`id\` = 150`, ) + + await queryFn(`UPDATE \`transactions\` set \`previous\` = 150 WHERE \`id\` = 278`) } From f8b0d52afd9b68be757e609bd215fa2c35e3c912 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 30 Jun 2022 13:57:30 +0200 Subject: [PATCH 005/103] Add ROLES and RIGHTS for users to query listContributions. --- backend/src/auth/RIGHTS.ts | 1 + backend/src/auth/ROLES.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/backend/src/auth/RIGHTS.ts b/backend/src/auth/RIGHTS.ts index c10fc96de..6a6f8b7c0 100644 --- a/backend/src/auth/RIGHTS.ts +++ b/backend/src/auth/RIGHTS.ts @@ -26,6 +26,7 @@ export enum RIGHTS { LIST_TRANSACTION_LINKS = 'LIST_TRANSACTION_LINKS', GDT_BALANCE = 'GDT_BALANCE', CREATE_CONTRIBUTION = 'CREATE_CONTRIBUTION', + LIST_CONTRIBUTIONS = 'LIST_CONTRIBUTIONS', // Admin SEARCH_USERS = 'SEARCH_USERS', SET_USER_ROLE = 'SET_USER_ROLE', diff --git a/backend/src/auth/ROLES.ts b/backend/src/auth/ROLES.ts index 2d9ac2deb..f56106664 100644 --- a/backend/src/auth/ROLES.ts +++ b/backend/src/auth/ROLES.ts @@ -24,6 +24,7 @@ export const ROLE_USER = new Role('user', [ RIGHTS.LIST_TRANSACTION_LINKS, RIGHTS.GDT_BALANCE, RIGHTS.CREATE_CONTRIBUTION, + RIGHTS.LIST_CONTRIBUTIONS, ]) export const ROLE_ADMIN = new Role('admin', Object.values(RIGHTS)) // all rights From f19a6f1d15a14331711305e83e7a0df848c98923 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 30 Jun 2022 13:58:21 +0200 Subject: [PATCH 006/103] Create model for Contribution and create function to query listContributions. --- backend/src/graphql/model/Contribution.ts | 44 ++++++++++++++++ .../graphql/resolver/ContributionResolver.ts | 51 +++++++++++++++++-- 2 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 backend/src/graphql/model/Contribution.ts diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts new file mode 100644 index 000000000..cd8c94d74 --- /dev/null +++ b/backend/src/graphql/model/Contribution.ts @@ -0,0 +1,44 @@ +import { ObjectType, Field, Int } from 'type-graphql' +import Decimal from 'decimal.js-light' +import { Contribution as dbContribution } from '@entity/Contribution' +import { User } from './User' +import CONFIG from '@/config' + +@ObjectType() +export class Contribution { + constructor(contribution: dbContribution, user: User) { + this.id = contribution.id + this.user = user + this.amount = contribution.amount + this.memo = contribution.memo + this.createdAt = contribution.createdAt + this.deletedAt = contribution.deletedAt + } + + @Field(() => Number) + id: number + + @Field(() => User) + user: User + + @Field(() => Decimal) + amount: Decimal + + @Field(() => String) + memo: string + + @Field(() => Date) + createdAt: Date + + @Field(() => Date, { nullable: true }) + deletedAt: Date | null +} + +@ObjectType() +export class ContributionListResult { + @Field(() => Int) + linkCount: number + + @Field(() => [Contribution]) + linkList: Contribution[] +} diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 924108f87..c3b4c2127 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -1,10 +1,15 @@ import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' -import { Contribution } from '@entity/Contribution' -import { Args, Authorized, Ctx, Mutation, Resolver } from 'type-graphql' +import { Contribution as dbContribution } from '@entity/Contribution' +import { Arg, Args, Authorized, Ctx, Mutation, Query, Resolver } from 'type-graphql' +import { IsNull, Not } from '../../../../database/node_modules/typeorm' import ContributionArgs from '../arg/ContributionArgs' +import Paginated from '../arg/Paginated' +import { Order } from '../enum/Order' +import { Contribution } from '../model/Contribution' import { UnconfirmedContribution } from '../model/UnconfirmedContribution' +import { User } from '../model/User' import { isContributionValid, getUserCreation } from './util/isContributionValid' @Resolver() @@ -21,7 +26,7 @@ export class ContributionResolver { const creationDateObj = new Date(creationDate) isContributionValid(creations, amount, creationDateObj) - const contribution = Contribution.create() + const contribution = dbContribution.create() contribution.userId = user.id contribution.amount = amount contribution.createdAt = new Date() @@ -29,7 +34,45 @@ export class ContributionResolver { contribution.memo = memo logger.trace('contribution to save', contribution) - await Contribution.save(contribution) + await dbContribution.save(contribution) return new UnconfirmedContribution(contribution, user, creations) } + + @Authorized([RIGHTS.LIST_CONTRIBUTIONS]) + @Query(() => [Contribution]) + async listContributions( + @Args() + { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, + @Arg('filterConfirmed', () => Boolean) + filterConfirmed: boolean | null, + @Ctx() context: Context, + ): Promise { + const user = getUser(context) + let contribution + if (filterConfirmed) { + contribution = await dbContribution.find({ + where: { + userId: user.id, + confirmedBy: IsNull(), + }, + order: { + createdAt: order, + }, + skip: (currentPage - 1) * pageSize, + take: pageSize, + }) + } else { + contribution = await dbContribution.find({ + where: { + userId: user.id, + }, + order: { + createdAt: order, + }, + skip: (currentPage - 1) * pageSize, + take: pageSize, + }) + } + return contribution.map((contr) => new Contribution(contr, new User(user))) + } } From 3ce80fc081101df68d6ecb92287c6fd19e921517 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 30 Jun 2022 16:47:44 +0200 Subject: [PATCH 007/103] Remove unused imports. --- backend/src/graphql/model/Contribution.ts | 1 - backend/src/graphql/resolver/ContributionResolver.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts index cd8c94d74..dc1dd39e9 100644 --- a/backend/src/graphql/model/Contribution.ts +++ b/backend/src/graphql/model/Contribution.ts @@ -2,7 +2,6 @@ import { ObjectType, Field, Int } from 'type-graphql' import Decimal from 'decimal.js-light' import { Contribution as dbContribution } from '@entity/Contribution' import { User } from './User' -import CONFIG from '@/config' @ObjectType() export class Contribution { diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index c3b4c2127..6669ef20d 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -3,7 +3,7 @@ import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { Contribution as dbContribution } from '@entity/Contribution' import { Arg, Args, Authorized, Ctx, Mutation, Query, Resolver } from 'type-graphql' -import { IsNull, Not } from '../../../../database/node_modules/typeorm' +import { IsNull } from '../../../../database/node_modules/typeorm' import ContributionArgs from '../arg/ContributionArgs' import Paginated from '../arg/Paginated' import { Order } from '../enum/Order' From 7d23be6901ce1859aeebb81965ef2b38090f6fed Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 1 Jul 2022 12:54:04 +0200 Subject: [PATCH 008/103] Add query for listContributions. --- backend/src/seeds/graphql/queries.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index 531aebf0f..cf0fd09bd 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -172,6 +172,24 @@ export const queryTransactionLink = gql` } ` +export const listContributions = gql` + query ( + $currentPage: Int = 1 + $pageSize: Int = 5 + $order: Order + $filterConfirmed: Boolean = false + ) { + listContributions( + currentPage: $currentPage + pageSize: $pageSize + order: $order + filterConfirmed: $filterConfirmed + ) { + amount + memo + } + } +` // from admin interface export const listUnconfirmedContributions = gql` From 58a350155bfd8dc2183ac775cfac4b09ce87fcdb Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 1 Jul 2022 12:54:46 +0200 Subject: [PATCH 009/103] Add tests that confirmed contribution are found and no unconfirmed contributions are found. --- .../resolver/ContributionResolver.test.ts | 93 ++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 01e9b123e..2308cd4e7 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -3,10 +3,13 @@ import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { createContribution } from '@/seeds/graphql/mutations' -import { login } from '@/seeds/graphql/queries' +import { listContributions, login } from '@/seeds/graphql/queries' import { cleanDB, resetToken, testEnvironment } from '@test/helpers' import { GraphQLError } from 'graphql' import { userFactory } from '@/seeds/factory/user' +import { creationFactory } from '@/seeds/factory/creation' +import { creations } from '@/seeds/creation/index' +import { peterLustig } from '@/seeds/users/peter-lustig' let mutate: any, query: any, con: any let testEnv: any @@ -121,4 +124,92 @@ describe('ContributionResolver', () => { }) }) }) + + describe('listContributions', () => { + describe('unauthenticated', () => { + it('returns an error', async () => { + await expect( + query({ + query: listContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: false, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) + + describe('authenticated', () => { + beforeAll(async () => { + await userFactory(testEnv, peterLustig) + await userFactory(testEnv, bibiBloxberg) + // bibi needs GDDs + const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + await creationFactory(testEnv, bibisCreation!) + // await userFactory(testEnv, bibiBloxberg) + await query({ + query: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + }) + + afterAll(async () => { + await cleanDB() + resetToken() + }) + + it('returns an empty array for unconfirmed creation filter', async () => { + await expect( + query({ + query: listContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: true, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listContributions: [], + }, + }), + ) + }) + + it('returns confirmed creation', async () => { + await expect( + query({ + query: listContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: false, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listContributions: expect.arrayContaining([ + expect.objectContaining({ + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + ]), + }, + }), + ) + }) + }) + }) }) From 78195612c2c4abbf83151f7faed47ad4f4d1767f Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 4 Jul 2022 07:39:11 +0200 Subject: [PATCH 010/103] Add ROLES and RIGHTS to updateContribution. --- backend/src/auth/RIGHTS.ts | 1 + backend/src/auth/ROLES.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/backend/src/auth/RIGHTS.ts b/backend/src/auth/RIGHTS.ts index 6a6f8b7c0..1d0fd2856 100644 --- a/backend/src/auth/RIGHTS.ts +++ b/backend/src/auth/RIGHTS.ts @@ -27,6 +27,7 @@ export enum RIGHTS { GDT_BALANCE = 'GDT_BALANCE', CREATE_CONTRIBUTION = 'CREATE_CONTRIBUTION', LIST_CONTRIBUTIONS = 'LIST_CONTRIBUTIONS', + UPDATE_CONTRIBUTION = 'UPDATE_CONTRIBUTION', // Admin SEARCH_USERS = 'SEARCH_USERS', SET_USER_ROLE = 'SET_USER_ROLE', diff --git a/backend/src/auth/ROLES.ts b/backend/src/auth/ROLES.ts index f56106664..75e552e79 100644 --- a/backend/src/auth/ROLES.ts +++ b/backend/src/auth/ROLES.ts @@ -25,6 +25,7 @@ export const ROLE_USER = new Role('user', [ RIGHTS.GDT_BALANCE, RIGHTS.CREATE_CONTRIBUTION, RIGHTS.LIST_CONTRIBUTIONS, + RIGHTS.UPDATE_CONTRIBUTION, ]) export const ROLE_ADMIN = new Role('admin', Object.values(RIGHTS)) // all rights From b580f8755da0a0034f58eb6b8871bab68c366d3e Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 4 Jul 2022 07:40:10 +0200 Subject: [PATCH 011/103] Refactor updateCreations. --- backend/src/graphql/resolver/AdminResolver.ts | 11 +---------- .../src/graphql/resolver/util/isContributionValid.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 5476fd8a1..962c13e9b 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -52,6 +52,7 @@ import { getUserCreations, isContributionValid, isStartEndDateValid, + updateCreations, } from './util/isContributionValid' import { CONTRIBUTIONLINK_MEMO_MAX_CHARS, @@ -688,13 +689,3 @@ export class AdminResolver { return new ContributionLink(dbContributionLink) } } - -function updateCreations(creations: Decimal[], contribution: Contribution): Decimal[] { - const index = getCreationIndex(contribution.contributionDate.getMonth()) - - if (index < 0) { - throw new Error('You cannot create GDD for a month older than the last three months.') - } - creations[index] = creations[index].plus(contribution.amount.toString()) - return creations -} diff --git a/backend/src/graphql/resolver/util/isContributionValid.ts b/backend/src/graphql/resolver/util/isContributionValid.ts index 0a9b57170..552370f4c 100644 --- a/backend/src/graphql/resolver/util/isContributionValid.ts +++ b/backend/src/graphql/resolver/util/isContributionValid.ts @@ -1,6 +1,7 @@ import { TransactionTypeId } from '@/graphql/enum/TransactionTypeId' import { backendLogger as logger } from '@/server/logger' import { getConnection } from '@dbTools/typeorm' +import { Contribution } from '@entity/Contribution' import Decimal from 'decimal.js-light' import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '../const/const' @@ -117,3 +118,13 @@ export const isStartEndDateValid = ( throw new Error(`The value of validFrom must before or equals the validTo!`) } } + +export const updateCreations = (creations: Decimal[], contribution: Contribution): Decimal[] => { + const index = getCreationIndex(contribution.contributionDate.getMonth()) + + if (index < 0) { + throw new Error('You cannot create GDD for a month older than the last three months.') + } + creations[index] = creations[index].plus(contribution.amount.toString()) + return creations +} From 03db4ed125cd2bcd7d7288f081bc25fa08b071af Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 4 Jul 2022 07:41:21 +0200 Subject: [PATCH 012/103] Add mutation to updateContribution. --- .../resolver/ContributionResolver.test.ts | 24 ++++++++++++++++++- backend/src/seeds/graphql/mutations.ts | 14 +++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 2308cd4e7..c9302cf64 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -2,7 +2,7 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' -import { createContribution } from '@/seeds/graphql/mutations' +import { createContribution, updateContribution } from '@/seeds/graphql/mutations' import { listContributions, login } from '@/seeds/graphql/queries' import { cleanDB, resetToken, testEnvironment } from '@test/helpers' import { GraphQLError } from 'graphql' @@ -212,4 +212,26 @@ describe('ContributionResolver', () => { }) }) }) + + describe('updateContribution', () => { + describe('unauthenticated', () => { + it('returns an error', async () => { + await expect( + mutate({ + mutation: updateContribution, + variables: { + contributionId: 1, + amount: 100.0, + memo: 'Test Contribution', + creationDate: 'not-valid', + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) + }) }) diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 4926f706f..45adeacc8 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -239,3 +239,17 @@ export const createContribution = gql` } } ` + +export const updateContribution = gql` + mutation ($contributionId: Int!, $amount: Decimal!, $memo: String!, $creationDate: String!) { + updateContribution( + contributionId: $contributionId + amount: $amount + memo: $memo + creationDate: $creationDate + ) { + amount + memo + } + } +` From 7b38fe7f931ad45697d67d1d3ce4d06cb0e535ec Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 4 Jul 2022 07:41:41 +0200 Subject: [PATCH 013/103] Function for updateContribution. --- .../graphql/resolver/ContributionResolver.ts | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 6669ef20d..2399593c2 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -2,7 +2,7 @@ import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { Contribution as dbContribution } from '@entity/Contribution' -import { Arg, Args, Authorized, Ctx, Mutation, Query, Resolver } from 'type-graphql' +import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' import { IsNull } from '../../../../database/node_modules/typeorm' import ContributionArgs from '../arg/ContributionArgs' import Paginated from '../arg/Paginated' @@ -10,7 +10,7 @@ import { Order } from '../enum/Order' import { Contribution } from '../model/Contribution' import { UnconfirmedContribution } from '../model/UnconfirmedContribution' import { User } from '../model/User' -import { isContributionValid, getUserCreation } from './util/isContributionValid' +import { isContributionValid, getUserCreation, updateCreations } from './util/isContributionValid' @Resolver() export class ContributionResolver { @@ -75,4 +75,41 @@ export class ContributionResolver { } return contribution.map((contr) => new Contribution(contr, new User(user))) } + + @Authorized([RIGHTS.UPDATE_CONTRIBUTION]) + @Mutation(() => UnconfirmedContribution) + async updateContribution( + @Arg('contributionId', () => Int) + contributionId: number, + @Args() { amount, memo, creationDate }: ContributionArgs, + @Ctx() context: Context, + ): Promise { + const user = getUser(context) + + const contributionToUpdate = await dbContribution.findOne({ + where: { id: contributionId, confirmedAt: IsNull() }, + }) + if (!contributionToUpdate) { + throw new Error('No contribution found to given id.') + } + if (contributionToUpdate.userId !== user.id) { + throw new Error('user of the pending contribution and send user does not correspond') + } + + const creationDateObj = new Date(creationDate) + let creations = await getUserCreation(user.id) + if (contributionToUpdate.contributionDate.getMonth() === creationDateObj.getMonth()) { + creations = updateCreations(creations, contributionToUpdate) + } + + // all possible cases not to be true are thrown in this function + isContributionValid(creations, amount, creationDateObj) + contributionToUpdate.amount = amount + contributionToUpdate.memo = memo + contributionToUpdate.contributionDate = new Date(creationDate) + dbContribution.save(contributionToUpdate) + + const result = new UnconfirmedContribution(contributionToUpdate, user, creations) + return result + } } From 8c4664e39180557faa856734ccb1a3f08dc2a5a7 Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Mon, 4 Jul 2022 13:46:04 +0200 Subject: [PATCH 014/103] add line to downgrade --- database/migrations/0041-update_transactions_for_blockchain.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/database/migrations/0041-update_transactions_for_blockchain.ts b/database/migrations/0041-update_transactions_for_blockchain.ts index 6ecdfffa9..44f5bd87d 100644 --- a/database/migrations/0041-update_transactions_for_blockchain.ts +++ b/database/migrations/0041-update_transactions_for_blockchain.ts @@ -109,4 +109,6 @@ export async function downgrade(queryFn: (query: string, values?: any[]) => Prom ) await queryFn(`UPDATE \`transactions\` set \`previous\` = 150 WHERE \`id\` = 278`) + // drop temp table + await queryFn(`DROP TABLE IF EXISTS \`transactions_temp\``) } From 8e7476ecb07d0ede3ff6270f1077f18d93ec17a8 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 5 Jul 2022 09:07:29 +0200 Subject: [PATCH 015/103] Refactor return value so that their is only one return value. --- backend/src/graphql/resolver/ContributionResolver.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 2399593c2..f14aa4f36 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -109,7 +109,6 @@ export class ContributionResolver { contributionToUpdate.contributionDate = new Date(creationDate) dbContribution.save(contributionToUpdate) - const result = new UnconfirmedContribution(contributionToUpdate, user, creations) - return result + return new UnconfirmedContribution(contributionToUpdate, user, creations) } } From 61d4c138e1d196bd02f2c360555ec19866c80187 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 5 Jul 2022 09:17:48 +0200 Subject: [PATCH 016/103] Remove unused import. --- backend/src/graphql/resolver/AdminResolver.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 962c13e9b..291ee6ed8 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -47,7 +47,6 @@ import { sendAccountActivationEmail } from '@/mailer/sendAccountActivationEmail' import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' import CONFIG from '@/config' import { - getCreationIndex, getUserCreation, getUserCreations, isContributionValid, From 1d4f628cb9e0a908332c45fd126679914735c25c Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 06:38:55 +0200 Subject: [PATCH 017/103] add locales required for new link copy use case --- frontend/src/locales/de.json | 6 +++++- frontend/src/locales/en.json | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 6be44f30d..4db32e369 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -125,7 +125,9 @@ "gdd_per_link": { "choose-amount": "Wähle einen Betrag aus, welchen du per Link versenden möchtest. Du kannst auch noch eine Nachricht eintragen. Beim Klick „Jetzt generieren“ wird ein Link erstellt, den du versenden kannst.", "copy": "kopieren", + "copy-with-text": "Link und Text kopieren", "created": "Der Link wurde erstellt!", + "credit-your-gradido": "Um deine Gradido gutzuschreiben, klicke auf den Link!", "decay-14-day": "Vergänglichkeit für 14 Tage", "delete-the-link": "Den Link löschen?", "deleted": "Der Link wurde gelöscht!", @@ -134,6 +136,7 @@ "header": "Gradidos versenden per Link", "isFree": "Gradido ist weltweit kostenfrei.", "link-copied": "Link wurde in die Zwischenablage kopiert. Du kannst ihn jetzt in eine E-Mail oder Nachricht einfügen.", + "link-and-text-copied": "Der Link und deine Nachricht wurden in die Zwischenablage kopiert. Du kannst ihn jetzt in eine E-Mail oder Nachricht einfügen.", "link-deleted": "Der Link wurde am {date} gelöscht.", "link-expired": "Der Link ist nicht mehr gültig. Die Gültigkeit ist am {date} abgelaufen.", "link-overview": "Linkübersicht", @@ -149,7 +152,8 @@ "redeemed-title": "eingelöst", "to-login": "Log dich ein", "to-register": "Registriere ein neues Konto.", - "validUntil": "Gültig bis" + "validUntil": "Gültig bis", + "validUntilDate": "Sie sind bis zum {date} gültig." }, "gdt": { "calculation": "Berechnung der Gradido Transform", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 5a89bb7bb..db409ff54 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -125,7 +125,9 @@ "gdd_per_link": { "choose-amount": "Select an amount that you would like to send via link. You can also enter a message. Click 'Generate now' to create a link that you can share.", "copy": "copy", + "copy-with-text": "copy link and text", "created": "Link was created!", + "credit-your-gradido": "To credit your Gradido, click on the link!", "decay-14-day": "Decay for 14 days", "delete-the-link": "Delete the link?", "deleted": "The link was deleted!", @@ -134,6 +136,7 @@ "header": "Send Gradidos via link", "isFree": "Gradido is free of charge worldwide.", "link-copied": "Link has been copied to the clipboard. You can now paste it into an email or message.", + "link-and-text-copied": "The link and your message have been copied to the clipboard. You can now include it in an email or message.", "link-deleted": "The link was deleted on {date}.", "link-expired": "The link is no longer valid. The validity expired on {date}.", "link-overview": "Link overview", @@ -149,7 +152,8 @@ "redeemed-title": "redeemed", "to-login": "Log in", "to-register": "Register a new account.", - "validUntil": "Valid until" + "validUntil": "Valid until", + "validUntilDate": "They are valid until {date}." }, "gdt": { "calculation": "Calculation of Gradido Transform", From b7fb51887f6afc11f8fe3b935a110e8e3f2f6058 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 06:42:39 +0200 Subject: [PATCH 018/103] add dropdown item and method for new link copy use case --- .../TransactionLinks/TransactionLink.vue | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index c7b7682ec..be512abcb 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -22,6 +22,10 @@ {{ $t('gdd_per_link.copy') }} + + + {{ $t('gdd_per_link.copy-with-text') }} + { + this.$bvModal.show('modalPopoverCopyError' + this.id) + this.toastError(this.$t('gdd_per_link.not-copied')) + }) + }, deleteLink() { this.$bvModal.msgBoxConfirm(this.$t('gdd_per_link.delete-the-link')).then(async (value) => { if (value) From 92eb144faa3d04a52ed903248c969d8a07225628 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 07:27:46 +0200 Subject: [PATCH 019/103] fix linting --- .../TransactionLinks/TransactionLink.vue | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index be512abcb..75c57a160 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -107,13 +107,17 @@ export default { navigator.clipboard .writeText( `${this.link}\n` + - `${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${this.amount} Gradido.\n` + - `\"${this.memo}\"\n` + - `${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', {date: this.$d(new Date(this.validUntil), 'short')})}` - ) - .then( + `${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ + this.amount + } Gradido.\n` + + `"${this.memo}"\n` + + `${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( + 'gdd_per_link.validUntilDate', { + date: this.$d(new Date(this.validUntil), 'short')}) + }`) + .then(() => { this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) - ) + }) .catch(() => { this.$bvModal.show('modalPopoverCopyError' + this.id) this.toastError(this.$t('gdd_per_link.not-copied')) From 5019a7c48f0c6b9ce8c47fb29b9891c5633d4349 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 07:40:50 +0200 Subject: [PATCH 020/103] sort locales --- frontend/src/locales/de.json | 2 +- frontend/src/locales/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 4db32e369..2c97d71aa 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -135,8 +135,8 @@ "has-account": "Du besitzt bereits ein Gradido Konto?", "header": "Gradidos versenden per Link", "isFree": "Gradido ist weltweit kostenfrei.", - "link-copied": "Link wurde in die Zwischenablage kopiert. Du kannst ihn jetzt in eine E-Mail oder Nachricht einfügen.", "link-and-text-copied": "Der Link und deine Nachricht wurden in die Zwischenablage kopiert. Du kannst ihn jetzt in eine E-Mail oder Nachricht einfügen.", + "link-copied": "Link wurde in die Zwischenablage kopiert. Du kannst ihn jetzt in eine E-Mail oder Nachricht einfügen.", "link-deleted": "Der Link wurde am {date} gelöscht.", "link-expired": "Der Link ist nicht mehr gültig. Die Gültigkeit ist am {date} abgelaufen.", "link-overview": "Linkübersicht", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index db409ff54..163bbd091 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -135,8 +135,8 @@ "has-account": "You already have a Gradido account?", "header": "Send Gradidos via link", "isFree": "Gradido is free of charge worldwide.", - "link-copied": "Link has been copied to the clipboard. You can now paste it into an email or message.", "link-and-text-copied": "The link and your message have been copied to the clipboard. You can now include it in an email or message.", + "link-copied": "Link has been copied to the clipboard. You can now paste it into an email or message.", "link-deleted": "The link was deleted on {date}.", "link-expired": "The link is no longer valid. The validity expired on {date}.", "link-overview": "Link overview", From 20e2e0edea4993cfa633e4f29b6db0ff042b5a69 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 09:01:28 +0200 Subject: [PATCH 021/103] Update frontend/src/components/TransactionLinks/TransactionLink.vue Co-authored-by: Alexander Friedland --- .../TransactionLinks/TransactionLink.vue | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index 75c57a160..f0836aa2a 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -106,15 +106,15 @@ export default { copyLinkWithText() { navigator.clipboard .writeText( - `${this.link}\n` + - `${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ - this.amount - } Gradido.\n` + - `"${this.memo}"\n` + - `${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( - 'gdd_per_link.validUntilDate', { - date: this.$d(new Date(this.validUntil), 'short')}) - }`) + ``${this.link} + ${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ + this.amount + }. Gradido + "${this.memo}" + ${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( + 'gdd_per_link.validUntilDate', + { date: this.$d(new Date(this.validUntil), 'short') }, + )}`) .then(() => { this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) }) From fe4a95e32de278ec45cd9626175f3d03ff6117e4 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 09:05:24 +0200 Subject: [PATCH 022/103] Update frontend/src/locales/de.json Co-authored-by: Alexander Friedland --- frontend/src/locales/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 2c97d71aa..dbe029082 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -127,7 +127,7 @@ "copy": "kopieren", "copy-with-text": "Link und Text kopieren", "created": "Der Link wurde erstellt!", - "credit-your-gradido": "Um deine Gradido gutzuschreiben, klicke auf den Link!", + "credit-your-gradido": "Damit die Gradido gutgeschrieben werden können, klicke auf den Link!", "decay-14-day": "Vergänglichkeit für 14 Tage", "delete-the-link": "Den Link löschen?", "deleted": "Der Link wurde gelöscht!", From b8ba6af90615a3af65aed906e53ffa333d7a9bba Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 09:05:59 +0200 Subject: [PATCH 023/103] Update frontend/src/components/TransactionLinks/TransactionLink.vue Co-authored-by: Alexander Friedland --- frontend/src/components/TransactionLinks/TransactionLink.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index f0836aa2a..1cebf697d 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -22,7 +22,7 @@ {{ $t('gdd_per_link.copy') }} - + {{ $t('gdd_per_link.copy-with-text') }} From 74a6c22f6faffb879097ccf076363e8a20bae90e Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 09:06:32 +0200 Subject: [PATCH 024/103] Update frontend/src/locales/de.json Co-authored-by: Alexander Friedland --- frontend/src/locales/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index dbe029082..62160ec9d 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -153,7 +153,7 @@ "to-login": "Log dich ein", "to-register": "Registriere ein neues Konto.", "validUntil": "Gültig bis", - "validUntilDate": "Sie sind bis zum {date} gültig." + "validUntilDate": "Der Link ist bis zum {date} gültig." }, "gdt": { "calculation": "Berechnung der Gradido Transform", From 38d9e276acd6b58386de4d9f0e3613c81dc9dd37 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 09:06:52 +0200 Subject: [PATCH 025/103] Update frontend/src/locales/en.json Co-authored-by: Alexander Friedland --- frontend/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 163bbd091..36a695e86 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -153,7 +153,7 @@ "to-login": "Log in", "to-register": "Register a new account.", "validUntil": "Valid until", - "validUntilDate": "They are valid until {date}." + "validUntilDate": "The link is valid until {date}." }, "gdt": { "calculation": "Calculation of Gradido Transform", From 6c856c8a92898d5e34c7f4df93b9d250c8ea2fc4 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 09:12:37 +0200 Subject: [PATCH 026/103] Update frontend/src/locales/en.json Co-authored-by: Alexander Friedland --- frontend/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 36a695e86..735ae28bd 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -127,7 +127,7 @@ "copy": "copy", "copy-with-text": "copy link and text", "created": "Link was created!", - "credit-your-gradido": "To credit your Gradido, click on the link!", + "credit-your-gradido": "For the Gradido to be credited, click on the link!", "decay-14-day": "Decay for 14 days", "delete-the-link": "Delete the link?", "deleted": "The link was deleted!", From e8b70608e90e52eb619db4756595cbc1ff82d114 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 5 Jul 2022 09:34:32 +0200 Subject: [PATCH 027/103] double apostrophe removed, fix yarn lint --- .../TransactionLinks/TransactionLink.vue | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index 1cebf697d..1476c3be6 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -22,7 +22,11 @@ {{ $t('gdd_per_link.copy') }} - + {{ $t('gdd_per_link.copy-with-text') }} @@ -106,7 +110,7 @@ export default { copyLinkWithText() { navigator.clipboard .writeText( - ``${this.link} + `${this.link} ${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ this.amount }. Gradido @@ -114,11 +118,12 @@ export default { ${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( 'gdd_per_link.validUntilDate', { date: this.$d(new Date(this.validUntil), 'short') }, - )}`) - .then(() => { - this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) - }) - .catch(() => { + )}`, + ) + .then(() => { + this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) + }) + .catch(() => { this.$bvModal.show('modalPopoverCopyError' + this.id) this.toastError(this.$t('gdd_per_link.not-copied')) }) From 4274974207a4c61640be98414e1d3edf3d8d60a2 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 10:36:44 +0200 Subject: [PATCH 028/103] reformat string to avoid unwanted indents --- .../components/TransactionLinks/TransactionLink.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index 1476c3be6..b9256331e 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -110,12 +110,12 @@ export default { copyLinkWithText() { navigator.clipboard .writeText( - `${this.link} - ${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ + `${this.link}\n` + + `${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ this.amount - }. Gradido - "${this.memo}" - ${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( + } Gradido.\n` + + `"${this.memo}"\n`+ + `${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( 'gdd_per_link.validUntilDate', { date: this.$d(new Date(this.validUntil), 'short') }, )}`, From a61df84a398728995bb3315cc786d7d3add8cada Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 10:37:17 +0200 Subject: [PATCH 029/103] add unit tests for new feature --- .../TransactionLinks/TransactionLink.spec.js | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.spec.js b/frontend/src/components/TransactionLinks/TransactionLink.spec.js index 13aaea900..2f9c91337 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.spec.js +++ b/frontend/src/components/TransactionLinks/TransactionLink.spec.js @@ -25,6 +25,7 @@ const propsData = { link: 'http://localhost/redeem/c00000000c000000c0000', holdAvailableAmount: '5.13109484759482747111', id: 12, + firstname: 'Testy' memo: 'Katzenauge, Eulenschrei, was verschwunden komm herbei!', validUntil: '2022-03-30T14:22:40.000Z', } @@ -77,7 +78,7 @@ describe('TransactionLink', () => { navigator.clipboard = navigatorClipboard }) - describe('copy with success', () => { + describe('copy link with success', () => { beforeEach(async () => { navigatorClipboardMock.mockResolvedValue() await wrapper.find('.test-copy-link .dropdown-item').trigger('click') @@ -93,7 +94,26 @@ describe('TransactionLink', () => { }) }) - describe('copy with error', () => { + describe('copy link and text with success', () => { + beforeEach(async () => { + navigatorClipboardMock.mockResolvedValue() + await wrapper.find('.test-copy-text .dropdown-item').trigger('click') + }) + + it('should call clipboard.writeText', () => { + expect(navigator.clipboard.writeText).toHaveBeenCalledWith( + `http://localhost/redeem/c00000000c000000c0000\n + Testy wants to send you 75 Gradido.\n + "Katzenauge, Eulenschrei, was verschwunden komm herbei!"\n + For the Gradido to be credited, click on the link! The link is valid until 3/30/2022.`, + ) + }) + it('toasts success message', () => { + expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.link-copied') + }) + }) + + describe('copy link with error', () => { beforeEach(async () => { navigatorClipboardMock.mockRejectedValue() await wrapper.find('.test-copy-link .dropdown-item').trigger('click') @@ -103,6 +123,17 @@ describe('TransactionLink', () => { expect(toastErrorSpy).toBeCalledWith('gdd_per_link.not-copied') }) }) + + describe('copy link and text with error', () => { + beforeEach(async () => { + navigatorClipboardMock.mockRejectedValue() + await wrapper.find('.test-copy-text .dropdown-item').trigger('click') + }) + + it('toasts an error', () => { + expect(toastErrorSpy).toBeCalledWith('gdd_per_link.not-copied') + }) + }) }) describe('qr code modal', () => { From 45e7fecd3979774c2c19a02e03217a4ece328838 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 10:47:16 +0200 Subject: [PATCH 030/103] fix unit test --- .../src/components/TransactionLinks/TransactionLink.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.spec.js b/frontend/src/components/TransactionLinks/TransactionLink.spec.js index 2f9c91337..d0abe462d 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.spec.js +++ b/frontend/src/components/TransactionLinks/TransactionLink.spec.js @@ -25,7 +25,7 @@ const propsData = { link: 'http://localhost/redeem/c00000000c000000c0000', holdAvailableAmount: '5.13109484759482747111', id: 12, - firstname: 'Testy' + firstname: 'Testy', memo: 'Katzenauge, Eulenschrei, was verschwunden komm herbei!', validUntil: '2022-03-30T14:22:40.000Z', } From 794bcbdfa37e831c4872ed4bc0e6e9088f33623e Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 11:20:48 +0200 Subject: [PATCH 031/103] update unit test --- .../TransactionLinks/TransactionLink.spec.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.spec.js b/frontend/src/components/TransactionLinks/TransactionLink.spec.js index d0abe462d..469a8377e 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.spec.js +++ b/frontend/src/components/TransactionLinks/TransactionLink.spec.js @@ -102,14 +102,14 @@ describe('TransactionLink', () => { it('should call clipboard.writeText', () => { expect(navigator.clipboard.writeText).toHaveBeenCalledWith( - `http://localhost/redeem/c00000000c000000c0000\n - Testy wants to send you 75 Gradido.\n - "Katzenauge, Eulenschrei, was verschwunden komm herbei!"\n - For the Gradido to be credited, click on the link! The link is valid until 3/30/2022.`, + 'http://localhost/redeem/c00000000c000000c0000\n' + + 'Testy wants to send you 75 Gradido.\n' + + '"Katzenauge, Eulenschrei, was verschwunden komm herbei!"\n' + + 'For the Gradido to be credited, click on the link! The link is valid until 3/30/2022.', ) }) it('toasts success message', () => { - expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.link-copied') + expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.link-and-text-copied') }) }) From 7d9253e4c7ae00ea058660ba8f6be277437db68e Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 11:49:52 +0200 Subject: [PATCH 032/103] Update frontend/src/components/TransactionLinks/TransactionLink.vue Co-authored-by: Moriz Wahl --- .../components/TransactionLinks/TransactionLink.vue | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index b9256331e..b7dc03db5 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -110,15 +110,10 @@ export default { copyLinkWithText() { navigator.clipboard .writeText( - `${this.link}\n` + - `${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${ - this.amount - } Gradido.\n` + - `"${this.memo}"\n`+ - `${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t( - 'gdd_per_link.validUntilDate', - { date: this.$d(new Date(this.validUntil), 'short') }, - )}`, + `${this.link}\n +${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${this.amount} Gradido. +"${this.memo}" +${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', { date: this.$d(new Date(this.validUntil), 'short') })}`, ) .then(() => { this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) From ca8732bd750317fe853c29a5530f89d58d6c42ff Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 11:50:52 +0200 Subject: [PATCH 033/103] Update frontend/src/locales/en.json Co-authored-by: Moriz Wahl --- frontend/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 735ae28bd..088a006a7 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -125,7 +125,7 @@ "gdd_per_link": { "choose-amount": "Select an amount that you would like to send via link. You can also enter a message. Click 'Generate now' to create a link that you can share.", "copy": "copy", - "copy-with-text": "copy link and text", + "copy-with-text": "Copy link and text", "created": "Link was created!", "credit-your-gradido": "For the Gradido to be credited, click on the link!", "decay-14-day": "Decay for 14 days", From a9a518c9bbbe2fe882f8f87f48085227d3d5d48d Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 5 Jul 2022 11:59:32 +0200 Subject: [PATCH 034/103] fix linting errors --- frontend/src/components/TransactionLinks/TransactionLink.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index b7dc03db5..d5491835c 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -113,7 +113,9 @@ export default { `${this.link}\n ${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${this.amount} Gradido. "${this.memo}" -${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', { date: this.$d(new Date(this.validUntil), 'short') })}`, +${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', { + date: this.$d(new Date(this.validUntil), 'short'), + })}`, ) .then(() => { this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) From e4a4744f4e4be78367ed5128410709be95ad1ef0 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 5 Jul 2022 12:30:46 +0200 Subject: [PATCH 035/103] fix unit tests --- .../TransactionLinks/TransactionLink.spec.js | 15 ++++++++------- .../TransactionLinks/TransactionLink.vue | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.spec.js b/frontend/src/components/TransactionLinks/TransactionLink.spec.js index 469a8377e..50f1588d7 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.spec.js +++ b/frontend/src/components/TransactionLinks/TransactionLink.spec.js @@ -9,15 +9,16 @@ const mockAPIcall = jest.fn() const navigatorClipboardMock = jest.fn() const mocks = { - $i18n: { - locale: 'en', - }, $t: jest.fn((t) => t), $d: jest.fn((d) => d), - $tc: jest.fn((tc) => tc), $apollo: { mutate: mockAPIcall, }, + $store: { + state: { + firstName: 'Testy', + }, + }, } const propsData = { @@ -103,9 +104,9 @@ describe('TransactionLink', () => { it('should call clipboard.writeText', () => { expect(navigator.clipboard.writeText).toHaveBeenCalledWith( 'http://localhost/redeem/c00000000c000000c0000\n' + - 'Testy wants to send you 75 Gradido.\n' + - '"Katzenauge, Eulenschrei, was verschwunden komm herbei!"\n' + - 'For the Gradido to be credited, click on the link! The link is valid until 3/30/2022.', + 'Testy transaction-link.send_you 75 Gradido.\n' + + '"Katzenauge, Eulenschrei, was verschwunden komm herbei!"\n' + + 'gdd_per_link.credit-your-gradido gdd_per_link.validUntilDate', ) }) it('toasts success message', () => { diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index d5491835c..5618c8696 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -110,7 +110,7 @@ export default { copyLinkWithText() { navigator.clipboard .writeText( - `${this.link}\n + `${this.link} ${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${this.amount} Gradido. "${this.memo}" ${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', { From 19253d7ce79935e5c240cada9940df4dc22017c7 Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Tue, 5 Jul 2022 16:18:34 +0200 Subject: [PATCH 036/103] change generic mysql query to easy raw mysql queries --- ...0041-update_transactions_for_blockchain.ts | 1919 ++++++++++++++++- 1 file changed, 1867 insertions(+), 52 deletions(-) diff --git a/database/migrations/0041-update_transactions_for_blockchain.ts b/database/migrations/0041-update_transactions_for_blockchain.ts index 44f5bd87d..066c78ee0 100644 --- a/database/migrations/0041-update_transactions_for_blockchain.ts +++ b/database/migrations/0041-update_transactions_for_blockchain.ts @@ -11,15 +11,19 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis ] const creationDate = new Date('2020-03-30 06:59:55') - await queryFn(`UPDATE \`transactions\` set \`amount\` = 1000, \`balance\` = 1000, \`memo\` = ? WHERE \`id\` = 150`, [ - transactionMemos[0], - ]) + await queryFn( + `UPDATE \`transactions\` set \`amount\` = 1000, \`balance\` = 1000, \`memo\` = ? WHERE \`id\` = 150`, + [transactionMemos[0]], + ) // [ RowDataPacket { 'MAX(`id`)': 6828 } ] - const lastTransactionId = (await queryFn(`SELECT MAX(\`id\`) as max_id from \`transactions\``))[0].max_id + const lastTransactionId = (await queryFn(`SELECT MAX(\`id\`) as max_id from \`transactions\``))[0] + .max_id // dummy id to insert two transactions before this (previous has an index on it) - await queryFn(`UPDATE \`transactions\` set \`previous\` = ? WHERE \`id\` = 278`, [lastTransactionId + 30]) - + await queryFn(`UPDATE \`transactions\` set \`previous\` = ? WHERE \`id\` = 278`, [ + lastTransactionId + 30, + ]) + await queryFn( `INSERT INTO \`transactions\`( \`user_id\`, \`previous\`, \`type_id\`, \`amount\`, \`balance\`, @@ -38,76 +42,1887 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis 275, LAST_INSERT_ID(), 1, 1000, 3000, ?, 0, ?, ? )`, - [creationDate, transactionMemos[2], creationDate], + [creationDate, transactionMemos[2], creationDate], ) await queryFn(`UPDATE \`transactions\` set \`previous\` = LAST_INSERT_ID() WHERE \`id\` = 278`) // ---------------------------------------------------------------------------------------------- // update creation_date for transactions with creation_date == balance_date - // !cannot made be undone easily! - - // make copy of transaction_creations table for easy debugging workflow - await queryFn(`DROP TABLE IF EXISTS \`transactions_temp\``) - await queryFn(`CREATE TABLE \`transactions_temp\` LIKE transactions`) - await queryFn(`INSERT INTO \`transactions_temp\` SELECT * FROM \`transactions\``) - - // update entries from which memo contain month name (most cases) + /* js code for generating mysql raw queries + // print mysql raw querys interface ReplaceSet { - monthName: string + monthName: RegExp monthValue: number - yearValue: number } + // js month starting with 0 for Jan const replaceSets: ReplaceSet[] = [ - { monthName: '%Dez%', monthValue: 12, yearValue: 2019 }, - { monthName: '%Jan%', monthValue: 1, yearValue: 2020 }, - { monthName: '%Feb%', monthValue: 2, yearValue: 2020 }, - { monthName: '%M_rz%', monthValue: 3, yearValue: 2020 }, - { monthName: '%April%', monthValue: 4, yearValue: 2020 }, + { monthName: new RegExp('.*Dez.*'), monthValue: -1}, + { monthName: new RegExp('.*Jan.*'), monthValue: 0 }, + { monthName: new RegExp('.*Feb.*'), monthValue: 1 }, + { monthName: new RegExp('.*M.rz.*'), monthValue: 2 }, + { monthName: new RegExp('.*April.*'), monthValue: 3 }, ] - for(const replaceSet of replaceSets) { - let sqlQuery = `update \`transactions_temp\` - SET \`creation_date\` = DATE_FORMAT(\`creation_date\`, CONCAT(?, '-', ?, '-', ` - if (replaceSet.monthName === '%Feb%') { - sqlQuery += "IF(DATE_FORMAT(`creation_date`, '%d') <= 28, '%d', 28)" - } else { - sqlQuery += "'%d'" - } - sqlQuery += `, ' %H:%i:%s')) - WHERE \`balance_date\` = \`creation_date\` - AND \`type_id\` = 1 - AND \`memo\` LIKE ?` - - await queryFn(sqlQuery, [replaceSet.yearValue, replaceSet.monthValue, replaceSet.monthName]) - } - - // update entries without month name in memo, simply move creation_date 1 month before balance_date - await queryFn(`UPDATE \`transactions_temp\` - set creation_date = CAST(DATE_FORMAT(creation_date, CONCAT( - IF(DATE_FORMAT(creation_date, '%m') = 1, DATE_FORMAT(creation_date, '%Y') - 1, '%Y'), - '-', - IF(DATE_FORMAT(creation_date, '%m') = 1, 12, DATE_FORMAT(creation_date, '%m') - 1), - '-', - IF(DATE_FORMAT(creation_date, '%m') = 3, IF(DATE_FORMAT(creation_date, '%d') <= 28, '%d', 28), '%d'), - ' %H:%i:%s')) AS DATETIME) - WHERE balance_date = creation_date + const transaction_ids = await queryFn(` + SELECT id, balance_date, creation_date, memo + FROM \`transactions\` + WHERE \`balance_date\` = \`creation_date\` + AND \`type_id\` = 1 `) + let downgradeQueries = '' + for(let id in transaction_ids) { + const transaction = transaction_ids[id] + let updatedCreationDate: Date | null = null + // determine correct creation date + for(const replaceSet of replaceSets) { + // check if target creation can be determine which help of the memo + if(transaction.memo.match(replaceSet.monthName)) { + const oldCreationDate = transaction.creation_date + updatedCreationDate = new Date(oldCreationDate) + updatedCreationDate.setMonth(replaceSet.monthValue) + break + } + } + // couldn't find info in memo, simply set date 1 month back + if(updatedCreationDate === null) { + //date.setMonth(date.getMonth() - numOfMonths); + updatedCreationDate = new Date(transaction.creation_date) + updatedCreationDate.setMonth(transaction.creation_date.getMonth() - 1) + } + if(updatedCreationDate.getMonth() == 1) { + // only 28 februars exist so let us fix it + if(updatedCreationDate.getDate() > 28) { + updatedCreationDate.setDate(28) + } + } + console.log('// %s, original creation date: %s\nawait queryFn(`UPDATE \\`transactions\\` SET creation_date = \'%s\' WHERE \\`id\\` = %d`)\n', + transaction.memo, + transaction.creation_date.toISOString().slice(0, 19).replace('T', ' '), + updatedCreationDate.toISOString().slice(0, 19).replace('T', ' '), + transaction.id + ) + downgradeQueries += 'await queryFn(`UPDATE \\`transactions\\` SET creation_date = \'' + downgradeQueries += transaction.creation_date.toISOString().slice(0, 19).replace('T', ' ') + downgradeQueries += '\' WHERE \\`id\\` = ' + downgradeQueries += transaction.id + downgradeQueries += '`)\n' + } + console.log("downgrade: \n%s", downgradeQueries) + console.log("transactions count: %d", transaction_ids.length) // 224 +*/ + + // Erste Schöpfung, viel Spaß damit ;), original creation date: 2019-12-17 13:06:13 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-11-17 13:06:13' WHERE \`id\` = 1`, + ) + + // Erste Schöpfung, viel Spaß damit ;), original creation date: 2019-12-17 13:06:16 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-11-17 13:06:16' WHERE \`id\` = 2`, + ) + + // Erste Schöpfung, viel Spaß damit ;), original creation date: 2019-12-17 13:06:19 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-11-17 13:06:19' WHERE \`id\` = 3`, + ) + + // Erste Schöpfung, viel Spaß damit ;), original creation date: 2019-12-17 13:06:21 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-11-17 13:06:21' WHERE \`id\` = 4`, + ) + + // Test1 , original creation date: 2019-12-17 13:07:01 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-11-17 13:07:01' WHERE \`id\` = 5`, + ) + + // EIn bisschen Nachschub für dich ;), original creation date: 2019-12-19 17:35:16 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-11-19 17:35:16' WHERE \`id\` = 6`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-08 10:34:40 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-08 10:34:40' WHERE \`id\` = 7`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-08 11:02:41 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-08 11:02:41' WHERE \`id\` = 8`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-08 11:06:42 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-08 11:06:42' WHERE \`id\` = 9`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-08 11:16:11 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-08 11:16:11' WHERE \`id\` = 10`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-08 11:16:15 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-08 11:16:15' WHERE \`id\` = 11`, + ) + + // Für deine tolle Arbeit ;), original creation date: 2020-01-08 13:24:29 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-08 13:24:29' WHERE \`id\` = 12`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-09 12:02:48 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-09 12:02:48' WHERE \`id\` = 13`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-09 12:02:52 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-09 12:02:52' WHERE \`id\` = 14`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-09 12:02:54 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-09 12:02:54' WHERE \`id\` = 15`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-09 12:09:08 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-09 12:09:08' WHERE \`id\` = 16`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-11 11:10:55 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-11 11:10:55' WHERE \`id\` = 17`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-11 11:11:24 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-11 11:11:24' WHERE \`id\` = 18`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-11 11:12:09 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-11 11:12:09' WHERE \`id\` = 19`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-11 11:31:20 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-11 11:31:20' WHERE \`id\` = 20`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-11 11:37:13 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-11 11:37:13' WHERE \`id\` = 21`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-11 11:37:42 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-11 11:37:42' WHERE \`id\` = 22`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-11 19:01:06 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-11 19:01:06' WHERE \`id\` = 23`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-13 16:27:07 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-13 16:27:07' WHERE \`id\` = 24`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-13 16:28:05 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-13 16:28:05' WHERE \`id\` = 25`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-13 16:28:57 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-13 16:28:57' WHERE \`id\` = 26`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-13 16:29:45 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-13 16:29:45' WHERE \`id\` = 27`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-17 13:47:28 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-17 13:47:28' WHERE \`id\` = 28`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-17 13:48:52 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-17 13:48:52' WHERE \`id\` = 29`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-17 13:49:21 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-17 13:49:21' WHERE \`id\` = 30`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-23 13:08:44 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-23 13:08:44' WHERE \`id\` = 31`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-27 08:12:16 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-27 08:12:16' WHERE \`id\` = 32`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 14:49:58 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 14:49:58' WHERE \`id\` = 33`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 14:50:35 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 14:50:35' WHERE \`id\` = 34`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 14:50:55 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 14:50:55' WHERE \`id\` = 35`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 14:52:03 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 14:52:03' WHERE \`id\` = 36`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 14:52:33 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 14:52:33' WHERE \`id\` = 37`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 14:52:53 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 14:52:53' WHERE \`id\` = 38`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 14:53:45 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 14:53:45' WHERE \`id\` = 39`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 14:54:13 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 14:54:13' WHERE \`id\` = 40`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 14:54:50 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 14:54:50' WHERE \`id\` = 41`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 15:03:26 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 15:03:26' WHERE \`id\` = 42`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 15:10:39 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 15:10:39' WHERE \`id\` = 43`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 15:13:10 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 15:13:10' WHERE \`id\` = 44`, + ) + + // AGE Dezember 2019, original creation date: 2020-01-30 15:26:45 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 15:26:45' WHERE \`id\` = 45`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:54:31 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:54:31' WHERE \`id\` = 46`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:55:30 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:55:30' WHERE \`id\` = 47`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:55:33 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:55:33' WHERE \`id\` = 48`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:55:36 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:55:36' WHERE \`id\` = 49`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:55:39 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:55:39' WHERE \`id\` = 50`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:55:43 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:55:43' WHERE \`id\` = 51`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:55:46 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:55:46' WHERE \`id\` = 52`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:55:48 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:55:48' WHERE \`id\` = 53`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:55:50 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:55:50' WHERE \`id\` = 54`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:55:52 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:55:52' WHERE \`id\` = 55`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:55:54 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:55:54' WHERE \`id\` = 56`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:55:56 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:55:56' WHERE \`id\` = 57`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:55:59 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:55:59' WHERE \`id\` = 58`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:56:02 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:56:02' WHERE \`id\` = 59`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:56:05 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:56:05' WHERE \`id\` = 60`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:56:07 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:56:07' WHERE \`id\` = 61`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:56:10 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:56:10' WHERE \`id\` = 62`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:56:12 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:56:12' WHERE \`id\` = 63`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:56:14 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:56:14' WHERE \`id\` = 64`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:56:21 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:56:21' WHERE \`id\` = 65`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:56:24 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:56:24' WHERE \`id\` = 66`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:56:26 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:56:26' WHERE \`id\` = 67`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:56:28 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:56:28' WHERE \`id\` = 68`, + ) + + // Grundeinkommen für Gemeinschaftsleistungen Jan. 2020, original creation date: 2020-02-19 08:56:31 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-19 08:56:31' WHERE \`id\` = 69`, + ) + + // Grundeinkommen rückwirkend Dezember, original creation date: 2020-02-20 06:40:36 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-20 06:40:36' WHERE \`id\` = 70`, + ) + + // Grundeinkommen für GLJanuar 2020, original creation date: 2020-02-20 06:43:41 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-20 06:43:41' WHERE \`id\` = 71`, + ) + + // Grundeinkommen für GLJanuar 2020, original creation date: 2020-02-20 06:43:43 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-20 06:43:43' WHERE \`id\` = 72`, + ) + + // Grundeinkommen für GLJanuar 2020, original creation date: 2020-02-20 06:43:45 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-20 06:43:45' WHERE \`id\` = 73`, + ) + + // Grundeinkommen für GLJanuar 2020, original creation date: 2020-02-20 06:43:47 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-20 06:43:47' WHERE \`id\` = 74`, + ) + + // Grundeinkommen, original creation date: 2020-02-20 07:09:05 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-20 07:09:05' WHERE \`id\` = 75`, + ) + + // Grundeinkommen für GLJanuar 2020, original creation date: 2020-02-20 08:03:31 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-20 08:03:31' WHERE \`id\` = 76`, + ) + + // AGE für Gemeinschaftsleistungen Januar 2020, original creation date: 2020-02-29 16:17:24 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-29 16:17:24' WHERE \`id\` = 77`, + ) + + // AGE für Gemeinschaftsleistungen Januar 2020, original creation date: 2020-02-29 16:17:35 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-29 16:17:35' WHERE \`id\` = 78`, + ) + + // AGE für Gemeinschaftsleistungen Januar 2020, original creation date: 2020-02-29 16:17:42 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-29 16:17:42' WHERE \`id\` = 79`, + ) + + // AGE für Gemeinschaftsleistungen Januar 2020, original creation date: 2020-02-29 16:29:47 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-29 16:29:47' WHERE \`id\` = 80`, + ) + + // AGE für Gemeinschaftsleistungen Januar 2020, original creation date: 2020-02-29 16:29:48 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-29 16:29:48' WHERE \`id\` = 81`, + ) + + // AGE für Gemeinschaftsleistungen Januar 2020, original creation date: 2020-02-29 16:29:55 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-29 16:29:55' WHERE \`id\` = 82`, + ) + + // AGE rückwirkend für Januar 2020, original creation date: 2020-03-04 09:08:54 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-04 09:08:54' WHERE \`id\` = 83`, + ) + + // AGE für Gemeinschaftsleitungen Januar, original creation date: 2020-03-07 07:59:42 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-07 07:59:42' WHERE \`id\` = 84`, + ) + + // AGE für Gemeinschaftsleitungen Januar, original creation date: 2020-03-07 07:59:51 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-07 07:59:51' WHERE \`id\` = 85`, + ) + + // AGE für Gemeinschaftsleitungen Januar, original creation date: 2020-03-07 07:59:54 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-07 07:59:54' WHERE \`id\` = 86`, + ) + + // AGE für Gemeinschaftsleitungen Januar, original creation date: 2020-03-07 07:59:57 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-07 07:59:57' WHERE \`id\` = 87`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:15:48 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:15:48' WHERE \`id\` = 88`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:15:53 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:15:53' WHERE \`id\` = 89`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:15:56 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:15:56' WHERE \`id\` = 90`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:15:59 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:15:59' WHERE \`id\` = 91`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:16:01 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:16:01' WHERE \`id\` = 92`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:16:05 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:16:05' WHERE \`id\` = 93`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:16:07 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:16:07' WHERE \`id\` = 94`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:16:10 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:16:10' WHERE \`id\` = 95`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:17:00 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:17:00' WHERE \`id\` = 96`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:17:03 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:17:03' WHERE \`id\` = 97`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:17:05 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:17:05' WHERE \`id\` = 98`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:17:07 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:17:07' WHERE \`id\` = 99`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:17:09 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:17:09' WHERE \`id\` = 100`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:17:11 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:17:11' WHERE \`id\` = 101`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:17:13 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:17:13' WHERE \`id\` = 102`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:17:21 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:17:21' WHERE \`id\` = 103`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:17:25 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:17:25' WHERE \`id\` = 104`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-07 08:17:28 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:17:28' WHERE \`id\` = 105`, + ) + + // AGE für Gemeinschaftsleistungen Februar, original creation date: 2020-03-07 08:19:15 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-07 08:19:15' WHERE \`id\` = 106`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 geschöpft und gutgeschrieben., original creation date: 2020-03-08 18:00:20 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-08 18:00:20' WHERE \`id\` = 107`, + ) + + // AGE für Februar, original creation date: 2020-03-09 11:43:30 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-09 11:43:30' WHERE \`id\` = 108`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-09 17:48:34 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-09 17:48:34' WHERE \`id\` = 109`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-09 17:48:36 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-09 17:48:36' WHERE \`id\` = 110`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-09 17:48:38 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-09 17:48:38' WHERE \`id\` = 111`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-09 17:48:40 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-09 17:48:40' WHERE \`id\` = 112`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020, original creation date: 2020-03-09 17:48:43 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-09 17:48:43' WHERE \`id\` = 113`, + ) + + // AGE für Gemeinschaftsleistungen rückwirkend für Januar 2020 , original creation date: 2020-03-11 21:11:03 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-11 21:11:03' WHERE \`id\` = 114`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 , original creation date: 2020-03-11 21:17:22 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-11 21:17:22' WHERE \`id\` = 115`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 , original creation date: 2020-03-11 21:17:26 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-11 21:17:26' WHERE \`id\` = 116`, + ) + + // AGE für Gemeinschaftsleistungen rückwirkend für Januar, original creation date: 2020-03-18 15:44:07 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-18 15:44:07' WHERE \`id\` = 117`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 , original creation date: 2020-03-18 15:54:59 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-18 15:54:59' WHERE \`id\` = 118`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 , original creation date: 2020-03-18 15:55:32 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-18 15:55:32' WHERE \`id\` = 119`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 , original creation date: 2020-03-18 15:56:32 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-18 15:56:32' WHERE \`id\` = 120`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 , original creation date: 2020-03-18 15:56:48 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-18 15:56:48' WHERE \`id\` = 121`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 , original creation date: 2020-03-18 15:57:14 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-18 15:57:14' WHERE \`id\` = 122`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 , original creation date: 2020-03-18 15:58:41 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-18 15:58:41' WHERE \`id\` = 123`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 , original creation date: 2020-03-18 15:59:03 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-18 15:59:03' WHERE \`id\` = 124`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 , original creation date: 2020-03-18 15:59:26 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-18 15:59:26' WHERE \`id\` = 125`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 , original creation date: 2020-03-18 16:00:05 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-18 16:00:05' WHERE \`id\` = 126`, + ) + + // AGE für Gemeinschaftsleistungen Februar 2020 , original creation date: 2020-03-18 16:00:12 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-18 16:00:12' WHERE \`id\` = 127`, + ) + + // Aktives Grundeinkommen, original creation date: 2020-03-23 07:35:35 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-23 07:35:35' WHERE \`id\` = 128`, + ) + + // Aktives Grundeinkommen, original creation date: 2020-03-23 07:35:38 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-23 07:35:38' WHERE \`id\` = 129`, + ) + + // Aktives Grundeinkommen, original creation date: 2020-03-23 07:35:42 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-23 07:35:42' WHERE \`id\` = 130`, + ) + + // Aktives Grundeinkommen Januar , original creation date: 2020-03-24 17:00:05 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-24 17:00:05' WHERE \`id\` = 131`, + ) + + // Aktives Grundeinkommen Februar, original creation date: 2020-03-24 17:06:50 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-24 17:06:50' WHERE \`id\` = 132`, + ) + + // Aktives Grundeinkommen Februar, original creation date: 2020-03-24 17:06:54 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-24 17:06:54' WHERE \`id\` = 133`, + ) + + // Aktives Grundeinkommen März, original creation date: 2020-03-24 17:14:21 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-24 17:14:21' WHERE \`id\` = 134`, + ) + + // Aktives Grundeinkommen März, original creation date: 2020-03-24 17:14:27 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-24 17:14:27' WHERE \`id\` = 135`, + ) + + // Aktives Grundeinkommen März, original creation date: 2020-03-24 17:14:28 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-24 17:14:28' WHERE \`id\` = 136`, + ) + + // Aktives Grundeinkommen März, original creation date: 2020-03-24 17:14:30 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-24 17:14:30' WHERE \`id\` = 137`, + ) + + // Aktives Grundeinkommen geschöpft , original creation date: 2020-03-27 09:06:16 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-27 09:06:16' WHERE \`id\` = 138`, + ) + + // Aktives Grundeinkommen für GL Februar, original creation date: 2020-03-27 09:44:27 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-27 09:44:27' WHERE \`id\` = 139`, + ) + + // Aktives Grundeinkommen für GL Februar, original creation date: 2020-03-27 09:44:29 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-27 09:44:29' WHERE \`id\` = 140`, + ) + + // Aktives Grundeinkommen für GL Februar, original creation date: 2020-03-27 09:44:30 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-27 09:44:30' WHERE \`id\` = 141`, + ) + + // Aktives Grundeinkommen für GL Februar, original creation date: 2020-03-27 09:44:35 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-27 09:44:35' WHERE \`id\` = 142`, + ) + + // Aktives Grundeinkommen für GL Februar, original creation date: 2020-03-27 09:44:36 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-27 09:44:36' WHERE \`id\` = 143`, + ) + + // Aktives Grundeinkommen für GL Februar, original creation date: 2020-03-27 09:44:40 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-27 09:44:40' WHERE \`id\` = 144`, + ) + + // Aktives Grundeinkommen für GL Februar, original creation date: 2020-03-27 09:44:42 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-27 09:44:42' WHERE \`id\` = 145`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-03-28 09:28:24 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-28 09:28:24' WHERE \`id\` = 146`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-03-28 09:34:30 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-28 09:34:30' WHERE \`id\` = 147`, + ) + + // , original creation date: 2020-03-29 17:21:33 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-28 17:21:33' WHERE \`id\` = 148`, + ) + + // , original creation date: 2020-03-29 17:21:35 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-28 17:21:35' WHERE \`id\` = 149`, + ) + + // Aktives Grundeinkommen für GL. Dez, original creation date: 2020-03-30 06:59:55 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 06:59:55' WHERE \`id\` = 150`, + ) + + // Aktives Grundeinkommen für GL. Dez 2019, original creation date: 2020-03-30 07:05:14 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-30 07:05:14' WHERE \`id\` = 151`, + ) + + // Aktives Grundeinkommen für GL. Jan 2020, original creation date: 2020-03-30 07:09:52 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 07:09:52' WHERE \`id\` = 152`, + ) + + // Aktives Grundeinkommen für GL. Februar 2020, original creation date: 2020-03-30 07:15:43 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-01 07:15:43' WHERE \`id\` = 153`, + ) + + // Aktives Grundeinkommen für GL., original creation date: 2020-03-30 07:16:33 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-01 07:16:33' WHERE \`id\` = 154`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-03-30 07:21:07 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 07:21:07' WHERE \`id\` = 155`, + ) + + // Aktives Grundeinkommen für GL. Feb. 2020, original creation date: 2020-03-30 11:47:55 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-01 11:47:55' WHERE \`id\` = 156`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-01 06:56:20 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-01 06:56:20' WHERE \`id\` = 157`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-01 06:56:26 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-01 06:56:26' WHERE \`id\` = 158`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-01 06:56:29 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-01 06:56:29' WHERE \`id\` = 159`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-01 06:56:31 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-01 06:56:31' WHERE \`id\` = 160`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-01 06:58:10 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-01 06:58:10' WHERE \`id\` = 161`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-07 14:09:26 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 14:09:26' WHERE \`id\` = 162`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-07 14:09:28 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 14:09:28' WHERE \`id\` = 163`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-07 14:09:29 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 14:09:29' WHERE \`id\` = 164`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-07 14:09:32 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 14:09:32' WHERE \`id\` = 165`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-08 18:41:17 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-08 18:41:17' WHERE \`id\` = 166`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-08 18:41:20 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-08 18:41:20' WHERE \`id\` = 167`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-08 18:41:21 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-08 18:41:21' WHERE \`id\` = 168`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-08 18:41:23 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-08 18:41:23' WHERE \`id\` = 169`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-08 18:41:27 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-08 18:41:27' WHERE \`id\` = 170`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-08 18:58:15 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-08 18:58:15' WHERE \`id\` = 171`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-15 16:10:54 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-15 16:10:54' WHERE \`id\` = 172`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-15 16:10:56 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-15 16:10:56' WHERE \`id\` = 173`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-15 16:10:58 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-15 16:10:58' WHERE \`id\` = 174`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-15 16:11:01 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-15 16:11:01' WHERE \`id\` = 175`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-15 16:11:02 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-15 16:11:02' WHERE \`id\` = 176`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-15 16:11:04 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-15 16:11:04' WHERE \`id\` = 177`, + ) + + // Aktives Grundeinkommen für GL. März, original creation date: 2020-04-15 16:11:07 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-15 16:11:07' WHERE \`id\` = 178`, + ) + + // Aktives Grundeinkommen für GL.März 2020, original creation date: 2020-04-17 16:54:39 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-17 16:54:39' WHERE \`id\` = 179`, + ) + + // Aktives Grundeinkommen für GL.März 2020, original creation date: 2020-04-17 16:54:40 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-17 16:54:40' WHERE \`id\` = 180`, + ) + + // Aktives Grundeinkommen für GL.März 2020, original creation date: 2020-04-17 16:54:42 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-17 16:54:42' WHERE \`id\` = 181`, + ) + + // Aktives Grundeinkommen für GL.März 2020, original creation date: 2020-04-17 16:54:44 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-17 16:54:44' WHERE \`id\` = 182`, + ) + + // Aktives Grundeinkommen geschöpft und gutgeschrieben. + // Tausend Dank, weil Du bei uns bist und gemeinsam mit uns das Lebensgeld der Zukunft erschaffst!, original creation date: 2020-04-18 08:58:42 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 08:58:42' WHERE \`id\` = 183`, + ) + + // Aktives Grundeinkommen geschöpft und gutgeschrieben. + // Tausend Dank, weil Du bei uns bist und gemeinsam mit uns das Lebensgeld der Zukunft erschaffst!, original creation date: 2020-04-18 08:58:44 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 08:58:44' WHERE \`id\` = 184`, + ) + + // Aktives Grundeinkommen für GL.März 2020, original creation date: 2020-04-20 17:44:36 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-20 17:44:36' WHERE \`id\` = 185`, + ) + + // Aktives Grundeinkommen für GL.März 2020, original creation date: 2020-04-20 17:44:38 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-20 17:44:38' WHERE \`id\` = 186`, + ) + + // Aktives Grundeinkommen für GL.März 2020, original creation date: 2020-04-20 17:44:40 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-20 17:44:40' WHERE \`id\` = 187`, + ) + + // Aktives Grundeinkommen für GL.März 2020, original creation date: 2020-04-20 17:44:43 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-20 17:44:43' WHERE \`id\` = 188`, + ) + + // Aktives Grundeinkommen für GL März 2020, original creation date: 2020-04-25 06:30:13 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-25 06:30:13' WHERE \`id\` = 189`, + ) + + // Aktives Grundeinkommen für GL März 2020, original creation date: 2020-04-25 06:30:19 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-25 06:30:19' WHERE \`id\` = 190`, + ) + + // Aktives Grundeinkommen für GL März 2020, original creation date: 2020-04-25 06:30:21 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-25 06:30:21' WHERE \`id\` = 191`, + ) + + // Aktives Grundeinkommen für GL März 2020, original creation date: 2020-04-25 06:30:23 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-25 06:30:23' WHERE \`id\` = 192`, + ) + + // Aktives Grundeinkommen für GL März 2020, original creation date: 2020-04-25 06:30:24 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-25 06:30:24' WHERE \`id\` = 193`, + ) + + // Aktives Grundeinkommen für GL März 2020, original creation date: 2020-04-25 06:30:26 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-25 06:30:26' WHERE \`id\` = 194`, + ) + + // Aktives Grundeinkommen für G März 2020, original creation date: 2020-04-25 18:41:55 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-25 18:41:55' WHERE \`id\` = 195`, + ) + + // Aktives Grundeinkommen für G März 2020, original creation date: 2020-04-25 18:42:25 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-25 18:42:25' WHERE \`id\` = 196`, + ) + + // Aktives Grundeinkommen für März 2020, original creation date: 2020-04-25 18:46:01 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-25 18:46:01' WHERE \`id\` = 197`, + ) + + // Aktives Grundeinkommen für März 2020, original creation date: 2020-04-30 06:40:39 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 06:40:39' WHERE \`id\` = 198`, + ) + + // Aktives Grundeinkommen für März 2020, original creation date: 2020-04-30 06:40:41 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 06:40:41' WHERE \`id\` = 199`, + ) + + // Aktives Grundeinkommen für März 2020, original creation date: 2020-04-30 06:40:42 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 06:40:42' WHERE \`id\` = 200`, + ) + + // Aktives Grundeinkommen für März 2020, original creation date: 2020-04-30 06:40:45 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 06:40:45' WHERE \`id\` = 201`, + ) + + // Aktives Grundeinkommen für März 2020, original creation date: 2020-04-30 06:40:46 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 06:40:46' WHERE \`id\` = 202`, + ) + + // Aktives Grundeinkommen für März 2020, original creation date: 2020-04-30 06:40:50 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 06:40:50' WHERE \`id\` = 203`, + ) + + // Aktives Grundeinkommen für März 2020, original creation date: 2020-05-02 08:25:27 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-02 08:25:27' WHERE \`id\` = 204`, + ) + + // Aktives Grundeinkommen für März 2020, original creation date: 2020-05-02 08:25:29 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-02 08:25:29' WHERE \`id\` = 205`, + ) + + // Aktives Grundeinkommen für März 2020, original creation date: 2020-05-02 08:25:32 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-02 08:25:32' WHERE \`id\` = 206`, + ) + + // Aktives Grundeinkommen für März 2020, original creation date: 2020-05-02 08:28:14 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-02 08:28:14' WHERE \`id\` = 207`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:43:49 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:43:49' WHERE \`id\` = 208`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:43:51 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:43:51' WHERE \`id\` = 209`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:43:54 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:43:54' WHERE \`id\` = 210`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:43:56 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:43:56' WHERE \`id\` = 211`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:43:57 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:43:57' WHERE \`id\` = 212`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:43:59 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:43:59' WHERE \`id\` = 213`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:44:01 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:44:01' WHERE \`id\` = 214`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:44:02 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:44:02' WHERE \`id\` = 215`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:44:05 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:44:05' WHERE \`id\` = 216`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:44:10 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:44:10' WHERE \`id\` = 217`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:44:12 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:44:12' WHERE \`id\` = 218`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:44:14 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:44:14' WHERE \`id\` = 219`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-02 08:44:17 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-02 08:44:17' WHERE \`id\` = 220`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-03 09:00:04 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-03 09:00:04' WHERE \`id\` = 221`, + ) + + // Aktives Grundeinkommen für April 2020, original creation date: 2020-05-03 09:00:07 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-03 09:00:07' WHERE \`id\` = 222`, + ) + + // Aktives Grundeinkommen für GL. Jan, original creation date: 2020-03-30 06:59:55 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 06:59:55' WHERE \`id\` = 6869`, + ) + + // Aktives Grundeinkommen für GL. Feb, original creation date: 2020-03-30 06:59:55 + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-01 06:59:55' WHERE \`id\` = 6870`, + ) } - export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { - + // reverse creation date changes + + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-17 13:06:13' WHERE \`id\` = 1`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-17 13:06:16' WHERE \`id\` = 2`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-17 13:06:19' WHERE \`id\` = 3`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-17 13:06:21' WHERE \`id\` = 4`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-17 13:07:01' WHERE \`id\` = 5`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2019-12-19 17:35:16' WHERE \`id\` = 6`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-08 10:34:40' WHERE \`id\` = 7`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-08 11:02:41' WHERE \`id\` = 8`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-08 11:06:42' WHERE \`id\` = 9`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-08 11:16:11' WHERE \`id\` = 10`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-08 11:16:15' WHERE \`id\` = 11`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-08 13:24:29' WHERE \`id\` = 12`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-09 12:02:48' WHERE \`id\` = 13`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-09 12:02:52' WHERE \`id\` = 14`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-09 12:02:54' WHERE \`id\` = 15`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-09 12:09:08' WHERE \`id\` = 16`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-11 11:10:55' WHERE \`id\` = 17`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-11 11:11:24' WHERE \`id\` = 18`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-11 11:12:09' WHERE \`id\` = 19`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-11 11:31:20' WHERE \`id\` = 20`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-11 11:37:13' WHERE \`id\` = 21`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-11 11:37:42' WHERE \`id\` = 22`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-11 19:01:06' WHERE \`id\` = 23`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-13 16:27:07' WHERE \`id\` = 24`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-13 16:28:05' WHERE \`id\` = 25`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-13 16:28:57' WHERE \`id\` = 26`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-13 16:29:45' WHERE \`id\` = 27`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-17 13:47:28' WHERE \`id\` = 28`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-17 13:48:52' WHERE \`id\` = 29`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-17 13:49:21' WHERE \`id\` = 30`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-23 13:08:44' WHERE \`id\` = 31`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-27 08:12:16' WHERE \`id\` = 32`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 14:49:58' WHERE \`id\` = 33`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 14:50:35' WHERE \`id\` = 34`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 14:50:55' WHERE \`id\` = 35`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 14:52:03' WHERE \`id\` = 36`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 14:52:33' WHERE \`id\` = 37`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 14:52:53' WHERE \`id\` = 38`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 14:53:45' WHERE \`id\` = 39`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 14:54:13' WHERE \`id\` = 40`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 14:54:50' WHERE \`id\` = 41`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 15:03:26' WHERE \`id\` = 42`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 15:10:39' WHERE \`id\` = 43`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 15:13:10' WHERE \`id\` = 44`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-01-30 15:26:45' WHERE \`id\` = 45`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:54:31' WHERE \`id\` = 46`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:55:30' WHERE \`id\` = 47`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:55:33' WHERE \`id\` = 48`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:55:36' WHERE \`id\` = 49`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:55:39' WHERE \`id\` = 50`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:55:43' WHERE \`id\` = 51`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:55:46' WHERE \`id\` = 52`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:55:48' WHERE \`id\` = 53`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:55:50' WHERE \`id\` = 54`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:55:52' WHERE \`id\` = 55`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:55:54' WHERE \`id\` = 56`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:55:56' WHERE \`id\` = 57`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:55:59' WHERE \`id\` = 58`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:56:02' WHERE \`id\` = 59`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:56:05' WHERE \`id\` = 60`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:56:07' WHERE \`id\` = 61`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:56:10' WHERE \`id\` = 62`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:56:12' WHERE \`id\` = 63`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:56:14' WHERE \`id\` = 64`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:56:21' WHERE \`id\` = 65`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:56:24' WHERE \`id\` = 66`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:56:26' WHERE \`id\` = 67`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:56:28' WHERE \`id\` = 68`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-19 08:56:31' WHERE \`id\` = 69`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-20 06:40:36' WHERE \`id\` = 70`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-20 06:43:41' WHERE \`id\` = 71`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-20 06:43:43' WHERE \`id\` = 72`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-20 06:43:45' WHERE \`id\` = 73`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-20 06:43:47' WHERE \`id\` = 74`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-20 07:09:05' WHERE \`id\` = 75`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-20 08:03:31' WHERE \`id\` = 76`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-29 16:17:24' WHERE \`id\` = 77`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-29 16:17:35' WHERE \`id\` = 78`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-29 16:17:42' WHERE \`id\` = 79`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-29 16:29:47' WHERE \`id\` = 80`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-29 16:29:48' WHERE \`id\` = 81`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-02-29 16:29:55' WHERE \`id\` = 82`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-04 09:08:54' WHERE \`id\` = 83`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 07:59:42' WHERE \`id\` = 84`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 07:59:51' WHERE \`id\` = 85`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 07:59:54' WHERE \`id\` = 86`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 07:59:57' WHERE \`id\` = 87`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:15:48' WHERE \`id\` = 88`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:15:53' WHERE \`id\` = 89`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:15:56' WHERE \`id\` = 90`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:15:59' WHERE \`id\` = 91`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:16:01' WHERE \`id\` = 92`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:16:05' WHERE \`id\` = 93`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:16:07' WHERE \`id\` = 94`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:16:10' WHERE \`id\` = 95`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:17:00' WHERE \`id\` = 96`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:17:03' WHERE \`id\` = 97`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:17:05' WHERE \`id\` = 98`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:17:07' WHERE \`id\` = 99`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:17:09' WHERE \`id\` = 100`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:17:11' WHERE \`id\` = 101`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:17:13' WHERE \`id\` = 102`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:17:21' WHERE \`id\` = 103`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:17:25' WHERE \`id\` = 104`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:17:28' WHERE \`id\` = 105`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-07 08:19:15' WHERE \`id\` = 106`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-08 18:00:20' WHERE \`id\` = 107`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-09 11:43:30' WHERE \`id\` = 108`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-09 17:48:34' WHERE \`id\` = 109`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-09 17:48:36' WHERE \`id\` = 110`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-09 17:48:38' WHERE \`id\` = 111`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-09 17:48:40' WHERE \`id\` = 112`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-09 17:48:43' WHERE \`id\` = 113`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-11 21:11:03' WHERE \`id\` = 114`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-11 21:17:22' WHERE \`id\` = 115`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-11 21:17:26' WHERE \`id\` = 116`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 15:44:07' WHERE \`id\` = 117`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 15:54:59' WHERE \`id\` = 118`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 15:55:32' WHERE \`id\` = 119`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 15:56:32' WHERE \`id\` = 120`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 15:56:48' WHERE \`id\` = 121`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 15:57:14' WHERE \`id\` = 122`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 15:58:41' WHERE \`id\` = 123`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 15:59:03' WHERE \`id\` = 124`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 15:59:26' WHERE \`id\` = 125`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 16:00:05' WHERE \`id\` = 126`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-18 16:00:12' WHERE \`id\` = 127`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-23 07:35:35' WHERE \`id\` = 128`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-23 07:35:38' WHERE \`id\` = 129`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-23 07:35:42' WHERE \`id\` = 130`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-24 17:00:05' WHERE \`id\` = 131`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-24 17:06:50' WHERE \`id\` = 132`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-24 17:06:54' WHERE \`id\` = 133`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-24 17:14:21' WHERE \`id\` = 134`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-24 17:14:27' WHERE \`id\` = 135`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-24 17:14:28' WHERE \`id\` = 136`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-24 17:14:30' WHERE \`id\` = 137`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-27 09:06:16' WHERE \`id\` = 138`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-27 09:44:27' WHERE \`id\` = 139`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-27 09:44:29' WHERE \`id\` = 140`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-27 09:44:30' WHERE \`id\` = 141`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-27 09:44:35' WHERE \`id\` = 142`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-27 09:44:36' WHERE \`id\` = 143`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-27 09:44:40' WHERE \`id\` = 144`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-27 09:44:42' WHERE \`id\` = 145`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-28 09:28:24' WHERE \`id\` = 146`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-28 09:34:30' WHERE \`id\` = 147`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-29 17:21:33' WHERE \`id\` = 148`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-29 17:21:35' WHERE \`id\` = 149`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 06:59:55' WHERE \`id\` = 150`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 07:05:14' WHERE \`id\` = 151`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 07:09:52' WHERE \`id\` = 152`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 07:15:43' WHERE \`id\` = 153`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 07:16:33' WHERE \`id\` = 154`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 07:21:07' WHERE \`id\` = 155`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 11:47:55' WHERE \`id\` = 156`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-01 06:56:20' WHERE \`id\` = 157`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-01 06:56:26' WHERE \`id\` = 158`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-01 06:56:29' WHERE \`id\` = 159`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-01 06:56:31' WHERE \`id\` = 160`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-01 06:58:10' WHERE \`id\` = 161`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-07 14:09:26' WHERE \`id\` = 162`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-07 14:09:28' WHERE \`id\` = 163`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-07 14:09:29' WHERE \`id\` = 164`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-07 14:09:32' WHERE \`id\` = 165`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-08 18:41:17' WHERE \`id\` = 166`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-08 18:41:20' WHERE \`id\` = 167`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-08 18:41:21' WHERE \`id\` = 168`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-08 18:41:23' WHERE \`id\` = 169`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-08 18:41:27' WHERE \`id\` = 170`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-08 18:58:15' WHERE \`id\` = 171`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-15 16:10:54' WHERE \`id\` = 172`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-15 16:10:56' WHERE \`id\` = 173`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-15 16:10:58' WHERE \`id\` = 174`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-15 16:11:01' WHERE \`id\` = 175`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-15 16:11:02' WHERE \`id\` = 176`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-15 16:11:04' WHERE \`id\` = 177`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-15 16:11:07' WHERE \`id\` = 178`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-17 16:54:39' WHERE \`id\` = 179`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-17 16:54:40' WHERE \`id\` = 180`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-17 16:54:42' WHERE \`id\` = 181`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-17 16:54:44' WHERE \`id\` = 182`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-18 08:58:42' WHERE \`id\` = 183`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-18 08:58:44' WHERE \`id\` = 184`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-20 17:44:36' WHERE \`id\` = 185`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-20 17:44:38' WHERE \`id\` = 186`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-20 17:44:40' WHERE \`id\` = 187`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-20 17:44:43' WHERE \`id\` = 188`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-25 06:30:13' WHERE \`id\` = 189`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-25 06:30:19' WHERE \`id\` = 190`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-25 06:30:21' WHERE \`id\` = 191`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-25 06:30:23' WHERE \`id\` = 192`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-25 06:30:24' WHERE \`id\` = 193`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-25 06:30:26' WHERE \`id\` = 194`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-25 18:41:55' WHERE \`id\` = 195`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-25 18:42:25' WHERE \`id\` = 196`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-25 18:46:01' WHERE \`id\` = 197`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-30 06:40:39' WHERE \`id\` = 198`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-30 06:40:41' WHERE \`id\` = 199`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-30 06:40:42' WHERE \`id\` = 200`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-30 06:40:45' WHERE \`id\` = 201`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-30 06:40:46' WHERE \`id\` = 202`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-04-30 06:40:50' WHERE \`id\` = 203`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:25:27' WHERE \`id\` = 204`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:25:29' WHERE \`id\` = 205`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:25:32' WHERE \`id\` = 206`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:28:14' WHERE \`id\` = 207`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:43:49' WHERE \`id\` = 208`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:43:51' WHERE \`id\` = 209`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:43:54' WHERE \`id\` = 210`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:43:56' WHERE \`id\` = 211`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:43:57' WHERE \`id\` = 212`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:43:59' WHERE \`id\` = 213`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:44:01' WHERE \`id\` = 214`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:44:02' WHERE \`id\` = 215`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:44:05' WHERE \`id\` = 216`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:44:10' WHERE \`id\` = 217`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:44:12' WHERE \`id\` = 218`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:44:14' WHERE \`id\` = 219`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-02 08:44:17' WHERE \`id\` = 220`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-03 09:00:04' WHERE \`id\` = 221`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-05-03 09:00:07' WHERE \`id\` = 222`, + ) + + // from upgrade added, could be also delete because nevertheless they will be deleted + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 06:59:55' WHERE \`id\` = 6869`, + ) + await queryFn( + `UPDATE \`transactions\` SET creation_date = '2020-03-30 06:59:55' WHERE \`id\` = 6870`, + ) + // remove added transaction await queryFn( `DELETE FROM \`transactions\` WHERE \`user_id\` = 275 AND \`balance\` IN (2000, 3000) AND \`amount\` = 1000`, ) - + // rewind transaction to split await queryFn( `UPDATE \`transactions\` set \`amount\` = 3000, \`memo\` = 'Aktives Grundeinkommen für GL. Dez, Jan, Feb' WHERE \`id\` = 150`, ) - + await queryFn(`UPDATE \`transactions\` set \`previous\` = 150 WHERE \`id\` = 278`) // drop temp table await queryFn(`DROP TABLE IF EXISTS \`transactions_temp\``) From 6b3813a0c8ee52087e48e57791bc22b26c69600a Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Tue, 5 Jul 2022 17:09:31 +0200 Subject: [PATCH 037/103] add code for moving user creation date if transaction before exist --- .../0042-move_users_creation_date.ts | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 database/migrations/0042-move_users_creation_date.ts diff --git a/database/migrations/0042-move_users_creation_date.ts b/database/migrations/0042-move_users_creation_date.ts new file mode 100644 index 000000000..27353a5b4 --- /dev/null +++ b/database/migrations/0042-move_users_creation_date.ts @@ -0,0 +1,130 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +/* +Move forward the creation date of the users by 1 or 2 hours, +for which there are transactions created before their account creation. + +Because of a error by importing data from old db format into new, all older transactions balance_date +are 1 or 2 hours off + +*/ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + /* generate raw mysql queries + const usersToMove = await queryFn( + ` + SELECT u.id, u.created, t.balance_date + FROM \`users\` as u + LEFT JOIN \`transactions\` as t + ON t.user_id = u.id where t.balance_date < u.created + order by id + ` + ) + let downgradeQueries = '' + for(const id in usersToMove) { + const user = usersToMove[id] + const diff = (user.created - user.balance_date) / 1000 + const correcture = diff < 3600 ? 1: 2 + const correctedDate = new Date(user.created) + correctedDate.setHours(correctedDate.getHours() - correcture) + //console.log("%d, %s, %s, %s, %d", user.id, user.created, user.balance_date, diff, correcture) + console.log('await queryFn(`UPDATE \\`users\\` SET \\`created\\` = \'%s\' WHERE \\`id\\` = %d`)', + correctedDate.toISOString().slice(0, 19).replace('T', ' '), + user.id + ) + downgradeQueries += 'await queryFn(`UPDATE \\`users\\` SET \\`created\\` = \'' + downgradeQueries += user.created.toISOString().slice(0, 19).replace('T', ' ') + downgradeQueries += '\' WHERE \\`id\\` = ' + downgradeQueries += user.id + downgradeQueries += '`)\n' + } + console.log('downgrade: \n%s', downgradeQueries) + */ + + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-01-25 08:01:52' WHERE \`id\` = 179`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-05-26 10:21:57' WHERE \`id\` = 443`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-06-08 17:04:41' WHERE \`id\` = 490`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-06-12 20:07:17' WHERE \`id\` = 508`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-07-17 19:20:36' WHERE \`id\` = 621`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-11-22 16:31:48' WHERE \`id\` = 788`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-12-17 20:09:16' WHERE \`id\` = 825`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-01-26 13:09:35' WHERE \`id\` = 949`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-03-20 16:55:46' WHERE \`id\` = 1057`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 15:59:30' WHERE \`id\` = 1228`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 17:38:47' WHERE \`id\` = 1229`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 17:38:47' WHERE \`id\` = 1229`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 17:38:47' WHERE \`id\` = 1229`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 17:58:15' WHERE \`id\` = 1230`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 17:58:15' WHERE \`id\` = 1230`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 14:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 14:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 14:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 14:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-17 22:51:19' WHERE \`id\` = 1239`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-03 07:23:28' WHERE \`id\` = 1273`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-09 06:16:18' WHERE \`id\` = 1287`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-17 11:26:41' WHERE \`id\` = 1298`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-30 15:56:27' WHERE \`id\` = 1315`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-30 15:56:27' WHERE \`id\` = 1315`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-30 15:56:27' WHERE \`id\` = 1315`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-08 07:24:57' WHERE \`id\` = 1326`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-08 07:24:57' WHERE \`id\` = 1326`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-13 12:07:29' WHERE \`id\` = 1342`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-16 15:32:48' WHERE \`id\` = 1348`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-09-30 14:06:40' WHERE \`id\` = 1470`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-10-15 14:35:37' WHERE \`id\` = 1490`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-10-16 06:42:00' WHERE \`id\` = 1492`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-10-16 06:42:00' WHERE \`id\` = 1492`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-11-22 09:45:15' WHERE \`id\` = 1576`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-11-23 13:55:37' WHERE \`id\` = 1582`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-11 14:58:12' WHERE \`id\` = 1729`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-11 18:03:10' WHERE \`id\` = 1732`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-19 15:00:38' WHERE \`id\` = 1756`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-19 20:01:58' WHERE \`id\` = 1757`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-21 15:58:48' WHERE \`id\` = 1762`) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-01-25 09:01:52' WHERE \`id\` = 179`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-05-26 11:21:57' WHERE \`id\` = 443`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-06-08 19:04:41' WHERE \`id\` = 490`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-06-12 22:07:17' WHERE \`id\` = 508`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-07-17 21:20:36' WHERE \`id\` = 621`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-11-22 17:31:48' WHERE \`id\` = 788`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2020-12-17 21:09:16' WHERE \`id\` = 825`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-01-26 14:09:35' WHERE \`id\` = 949`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-03-20 17:55:46' WHERE \`id\` = 1057`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 17:59:30' WHERE \`id\` = 1228`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 19:38:47' WHERE \`id\` = 1229`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 19:38:47' WHERE \`id\` = 1229`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 19:38:47' WHERE \`id\` = 1229`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 19:58:15' WHERE \`id\` = 1230`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-13 19:58:15' WHERE \`id\` = 1230`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 16:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 16:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 16:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-14 16:27:49' WHERE \`id\` = 1231`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-05-18 00:51:19' WHERE \`id\` = 1239`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-03 09:23:28' WHERE \`id\` = 1273`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-09 08:16:18' WHERE \`id\` = 1287`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-17 13:26:41' WHERE \`id\` = 1298`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-30 17:56:27' WHERE \`id\` = 1315`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-30 17:56:27' WHERE \`id\` = 1315`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-06-30 17:56:27' WHERE \`id\` = 1315`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-08 09:24:57' WHERE \`id\` = 1326`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-08 09:24:57' WHERE \`id\` = 1326`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-13 14:07:29' WHERE \`id\` = 1342`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-07-16 16:32:48' WHERE \`id\` = 1348`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-09-30 16:06:40' WHERE \`id\` = 1470`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-10-15 16:35:37' WHERE \`id\` = 1490`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-10-16 08:42:00' WHERE \`id\` = 1492`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-10-16 08:42:00' WHERE \`id\` = 1492`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-11-22 10:45:15' WHERE \`id\` = 1576`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2021-11-23 14:55:37' WHERE \`id\` = 1582`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-11 15:58:12' WHERE \`id\` = 1729`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-11 19:03:10' WHERE \`id\` = 1732`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-19 16:00:38' WHERE \`id\` = 1756`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-19 21:01:58' WHERE \`id\` = 1757`) + await queryFn(`UPDATE \`users\` SET \`created\` = '2022-01-21 16:58:48' WHERE \`id\` = 1762`) +} From a2ffab2d4d96c1420d80654d1686433a6c900238 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Wed, 6 Jul 2022 10:27:21 +0200 Subject: [PATCH 038/103] Update database/migrations/0041-update_transactions_for_blockchain.ts Co-authored-by: Moriz Wahl --- database/migrations/0041-update_transactions_for_blockchain.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/0041-update_transactions_for_blockchain.ts b/database/migrations/0041-update_transactions_for_blockchain.ts index 066c78ee0..ca44d0d3b 100644 --- a/database/migrations/0041-update_transactions_for_blockchain.ts +++ b/database/migrations/0041-update_transactions_for_blockchain.ts @@ -32,7 +32,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis 275, 150, 1, 1000, 2000, ?, 0, ?, ? )`, - [creationDate, transactionMemos[1], creationDate], + [creationDate, transactionMemos[1], new Date(creationDate.getFullYear(), creationDate.getMonth() - 1, 1)], ) await queryFn( `INSERT INTO \`transactions\`( From 2774594f1362791bec4b34749c1a9062d388a1fd Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Wed, 6 Jul 2022 10:32:34 +0200 Subject: [PATCH 039/103] apply suggestions, remove added transactions from creation date fix sql queries --- ...0041-update_transactions_for_blockchain.ts | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/database/migrations/0041-update_transactions_for_blockchain.ts b/database/migrations/0041-update_transactions_for_blockchain.ts index ca44d0d3b..c4e025e86 100644 --- a/database/migrations/0041-update_transactions_for_blockchain.ts +++ b/database/migrations/0041-update_transactions_for_blockchain.ts @@ -32,7 +32,11 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis 275, 150, 1, 1000, 2000, ?, 0, ?, ? )`, - [creationDate, transactionMemos[1], new Date(creationDate.getFullYear(), creationDate.getMonth() - 1, 1)], + [ + creationDate, + transactionMemos[1], + new Date(creationDate.getFullYear(), creationDate.getMonth() - 1, 1), + ], ) await queryFn( `INSERT INTO \`transactions\`( @@ -42,7 +46,11 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis 275, LAST_INSERT_ID(), 1, 1000, 3000, ?, 0, ?, ? )`, - [creationDate, transactionMemos[2], creationDate], + [ + creationDate, + transactionMemos[2], + new Date(creationDate.getFullYear(), creationDate.getMonth() - 2, 1), + ], ) await queryFn(`UPDATE \`transactions\` set \`previous\` = LAST_INSERT_ID() WHERE \`id\` = 278`) @@ -1221,16 +1229,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis await queryFn( `UPDATE \`transactions\` SET creation_date = '2020-04-03 09:00:07' WHERE \`id\` = 222`, ) - - // Aktives Grundeinkommen für GL. Jan, original creation date: 2020-03-30 06:59:55 - await queryFn( - `UPDATE \`transactions\` SET creation_date = '2020-01-30 06:59:55' WHERE \`id\` = 6869`, - ) - - // Aktives Grundeinkommen für GL. Feb, original creation date: 2020-03-30 06:59:55 - await queryFn( - `UPDATE \`transactions\` SET creation_date = '2020-03-01 06:59:55' WHERE \`id\` = 6870`, - ) } export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { @@ -1903,14 +1901,6 @@ export async function downgrade(queryFn: (query: string, values?: any[]) => Prom `UPDATE \`transactions\` SET creation_date = '2020-05-03 09:00:07' WHERE \`id\` = 222`, ) - // from upgrade added, could be also delete because nevertheless they will be deleted - await queryFn( - `UPDATE \`transactions\` SET creation_date = '2020-03-30 06:59:55' WHERE \`id\` = 6869`, - ) - await queryFn( - `UPDATE \`transactions\` SET creation_date = '2020-03-30 06:59:55' WHERE \`id\` = 6870`, - ) - // remove added transaction await queryFn( `DELETE FROM \`transactions\` From 9272ca87cd92218e694eea032cef1d24b18c9375 Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 6 Jul 2022 11:39:59 +0200 Subject: [PATCH 040/103] fix unit test --- frontend/src/components/TransactionLinks/TransactionLink.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.spec.js b/frontend/src/components/TransactionLinks/TransactionLink.spec.js index 50f1588d7..d06f0f726 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.spec.js +++ b/frontend/src/components/TransactionLinks/TransactionLink.spec.js @@ -26,7 +26,6 @@ const propsData = { link: 'http://localhost/redeem/c00000000c000000c0000', holdAvailableAmount: '5.13109484759482747111', id: 12, - firstname: 'Testy', memo: 'Katzenauge, Eulenschrei, was verschwunden komm herbei!', validUntil: '2022-03-30T14:22:40.000Z', } From ca84fc3bae8d9c0943cafa5a6d6f6589db1530cd Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 7 Jul 2022 07:42:39 +0200 Subject: [PATCH 041/103] change text from page --- frontend/src/components/Auth/AuthMobileStart.vue | 2 +- frontend/src/locales/de.json | 3 +-- frontend/src/locales/en.json | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Auth/AuthMobileStart.vue b/frontend/src/components/Auth/AuthMobileStart.vue index 09985dd77..690b8f895 100644 --- a/frontend/src/components/Auth/AuthMobileStart.vue +++ b/frontend/src/components/Auth/AuthMobileStart.vue @@ -6,7 +6,7 @@ {{ $t('auth.left.gratitude') }}
- {{ $t('auth.left.newCurrency') }} + {{ $t('auth.left.oneGratitude') }}
Date: Sun, 10 Jul 2022 08:10:26 +0200 Subject: [PATCH 042/103] finalize, merge with current master --- backend/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index aa4197a43..cd24ee0c8 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0040-add_contribution_link_id_to_user', + DB_VERSION: '0041-update_transactions_for_blockchain', 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 From 1841d9969d9689d7745baa5caa1d0faf5466c5d9 Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Sun, 10 Jul 2022 08:39:25 +0200 Subject: [PATCH 043/103] finalize --- backend/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index aa4197a43..1f355623c 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0040-add_contribution_link_id_to_user', + DB_VERSION: '0042-move_users_creation_date', 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 From 971473965afed6642ddabdf5dc6102dec882e759 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Mon, 11 Jul 2022 10:59:27 +0200 Subject: [PATCH 044/103] Update en.json --- frontend/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 4271e85f8..0bfde65ed 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -14,7 +14,7 @@ "learnMore": "Learn more …", "oneDignity": "We gift to each other and give thanks with Gradido.", "oneDonation": "You are a gift for the community. 1000 thanks because you are with us.", - "oneGratitude": "The new currency. For each other, for all people, for nature." + "oneGratitude": "For each other, for all people, for nature." }, "navbar": { "aboutGradido": "About Gradido" From 3718f0dc56ef3d0363c2911bca6c4da9891f3959 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 11:42:24 +0200 Subject: [PATCH 045/103] Change the test so that we can test if the contribution list finds only created but not confirmed contribution --- .../resolver/ContributionResolver.test.ts | 91 ++++++++++++------- backend/src/seeds/graphql/mutations.ts | 1 + backend/src/seeds/graphql/queries.ts | 1 + 3 files changed, 59 insertions(+), 34 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 2308cd4e7..01ece7440 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -13,6 +13,7 @@ import { peterLustig } from '@/seeds/users/peter-lustig' let mutate: any, query: any, con: any let testEnv: any +let result: any beforeAll(async () => { testEnv = await testEnvironment() @@ -114,6 +115,7 @@ describe('ContributionResolver', () => { expect.objectContaining({ data: { createContribution: { + id: expect.any(Number), amount: '100', memo: 'Test env contribution', }, @@ -148,25 +150,22 @@ describe('ContributionResolver', () => { describe('authenticated', () => { beforeAll(async () => { - await userFactory(testEnv, peterLustig) await userFactory(testEnv, bibiBloxberg) - // bibi needs GDDs - const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await creationFactory(testEnv, bibisCreation!) - // await userFactory(testEnv, bibiBloxberg) await query({ query: login, variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, }) + await mutate({ + mutation: createContribution, + variables: { + amount: 100.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), + }, + }) }) - afterAll(async () => { - await cleanDB() - resetToken() - }) - - it('returns an empty array for unconfirmed creation filter', async () => { + it('returns only unconfirmed creations', async () => { await expect( query({ query: listContributions, @@ -177,39 +176,63 @@ describe('ContributionResolver', () => { filterConfirmed: true, }, }), - ).resolves.toEqual( - expect.objectContaining({ - data: { - listContributions: [], - }, - }), - ) - }) - - it('returns confirmed creation', async () => { - await expect( - query({ - query: listContributions, - variables: { - currentPage: 1, - pageSize: 25, - order: 'DESC', - filterConfirmed: false, - }, - }), ).resolves.toEqual( expect.objectContaining({ data: { listContributions: expect.arrayContaining([ expect.objectContaining({ - memo: 'Herzlich Willkommen bei Gradido!', - amount: '1000', + id: expect.any(Number), + memo: 'Test env contribution', + amount: '100', }), ]), }, }), ) }) + + describe('Adding confirmed creations', () => { + beforeAll(async () => { + await userFactory(testEnv, peterLustig) + const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') + await creationFactory(testEnv, bibisCreation!) + await query({ + query: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + }) + + it('returns confirmed and unconfirmed creation', async () => { + await expect( + query({ + query: listContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: false, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listContributions: expect.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.objectContaining({ + id: expect.any(Number), + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }), + ) + }) + }) }) }) }) diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 4926f706f..185485f2c 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -234,6 +234,7 @@ export const deleteContributionLink = gql` export const createContribution = gql` mutation ($amount: Decimal!, $memo: String!, $creationDate: String!) { createContribution(amount: $amount, memo: $memo, creationDate: $creationDate) { + id amount memo } diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index cf0fd09bd..c27ecdd66 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -185,6 +185,7 @@ export const listContributions = gql` order: $order filterConfirmed: $filterConfirmed ) { + id amount memo } From a2eccb12ed5b2e421d3ee8fd328afcc94c4def13 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 11:42:39 +0200 Subject: [PATCH 046/103] Change the variable name contribution to contributions. --- backend/src/graphql/resolver/ContributionResolver.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 59f1f359f..0925fac9c 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -48,9 +48,9 @@ export class ContributionResolver { @Ctx() context: Context, ): Promise { const user = getUser(context) - let contribution + let contributions if (filterConfirmed) { - contribution = await dbContribution.find({ + contributions = await dbContribution.find({ where: { userId: user.id, confirmedBy: IsNull(), @@ -62,7 +62,7 @@ export class ContributionResolver { take: pageSize, }) } else { - contribution = await dbContribution.find({ + contributions = await dbContribution.find({ where: { userId: user.id, }, @@ -73,6 +73,6 @@ export class ContributionResolver { take: pageSize, }) } - return contribution.map((contr) => new Contribution(contr, new User(user))) + return contributions.map((contribution) => new Contribution(contribution, new User(user))) } } From ae52b520dd0288e08f1fff35d461687bf3b96446 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 12:04:46 +0200 Subject: [PATCH 047/103] Withdrew where clause to an variable with inline condition. --- .../graphql/resolver/ContributionResolver.ts | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 0925fac9c..acf1b4cb0 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -48,31 +48,22 @@ export class ContributionResolver { @Ctx() context: Context, ): Promise { const user = getUser(context) - let contributions - if (filterConfirmed) { - contributions = await dbContribution.find({ - where: { + const where = filterConfirmed + ? { userId: user.id, confirmedBy: IsNull(), - }, - order: { - createdAt: order, - }, - skip: (currentPage - 1) * pageSize, - take: pageSize, - }) - } else { - contributions = await dbContribution.find({ - where: { + } + : { userId: user.id, - }, - order: { - createdAt: order, - }, - skip: (currentPage - 1) * pageSize, - take: pageSize, - }) - } + } + const contributions = await dbContribution.find({ + where, + order: { + createdAt: order, + }, + skip: (currentPage - 1) * pageSize, + take: pageSize, + }) return contributions.map((contribution) => new Contribution(contribution, new User(user))) } } From 9239f93096afe579bc1f2a0cc0b44bed1d730d7f Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 12:21:51 +0200 Subject: [PATCH 048/103] Add no non nullable assertion to admin Creation. --- backend/src/graphql/resolver/ContributionResolver.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 01ece7440..fcaaca11a 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -13,7 +13,6 @@ import { peterLustig } from '@/seeds/users/peter-lustig' let mutate: any, query: any, con: any let testEnv: any -let result: any beforeAll(async () => { testEnv = await testEnvironment() @@ -195,6 +194,7 @@ describe('ContributionResolver', () => { beforeAll(async () => { await userFactory(testEnv, peterLustig) const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion await creationFactory(testEnv, bibisCreation!) await query({ query: login, From 72a4c1145d41108f62d3d9c4c092dc2adf8bca1e Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Mon, 11 Jul 2022 12:39:35 +0200 Subject: [PATCH 049/103] remove forgotten drop transactions_temp table --- .../migrations/0041-update_transactions_for_blockchain.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/database/migrations/0041-update_transactions_for_blockchain.ts b/database/migrations/0041-update_transactions_for_blockchain.ts index c4e025e86..9d41ac4df 100644 --- a/database/migrations/0041-update_transactions_for_blockchain.ts +++ b/database/migrations/0041-update_transactions_for_blockchain.ts @@ -1913,7 +1913,5 @@ export async function downgrade(queryFn: (query: string, values?: any[]) => Prom WHERE \`id\` = 150`, ) - await queryFn(`UPDATE \`transactions\` set \`previous\` = 150 WHERE \`id\` = 278`) - // drop temp table - await queryFn(`DROP TABLE IF EXISTS \`transactions_temp\``) + await queryFn(`UPDATE \`transactions\` set \`previous\` = 150 WHERE \`id\` = 278`) } From caf4e9ae3e627cc6440636edf720cedd51fa51ec Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 14:04:38 +0200 Subject: [PATCH 050/103] Change the test name to filterConfirmed is false. --- backend/src/graphql/resolver/ContributionResolver.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index fcaaca11a..1e3034b59 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -202,7 +202,7 @@ describe('ContributionResolver', () => { }) }) - it('returns confirmed and unconfirmed creation', async () => { + it('filter confirmed is false', async () => { await expect( query({ query: listContributions, From 2113061629310c0eee75049f300af42ba79bdaa1 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 14:05:57 +0200 Subject: [PATCH 051/103] Change the imports to the standard. --- .../src/graphql/resolver/ContributionResolver.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index acf1b4cb0..a54a5e6bf 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -3,13 +3,13 @@ import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { Contribution as dbContribution } from '@entity/Contribution' import { Arg, Args, Authorized, Ctx, Mutation, Query, Resolver } from 'type-graphql' -import { IsNull } from '../../../../database/node_modules/typeorm' -import ContributionArgs from '../arg/ContributionArgs' -import Paginated from '../arg/Paginated' -import { Order } from '../enum/Order' -import { Contribution } from '../model/Contribution' -import { UnconfirmedContribution } from '../model/UnconfirmedContribution' -import { User } from '../model/User' +import { IsNull } from '@dbTools/typeorm' +import ContributionArgs from '@arg/ContributionArgs' +import Paginated from '@arg/Paginated' +import { Order } from '@enum/Order' +import { Contribution } from '@model/Contribution' +import { UnconfirmedContribution } from '@model/UnconfirmedContribution' +import { User } from '@model/User' import { validateContribution, getUserCreation } from './util/creations' @Resolver() From f8cdad7e58bfb232d7780543974a6f39787fadfd Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 14:07:57 +0200 Subject: [PATCH 052/103] Change the where clause to a defined object. --- .../src/graphql/resolver/ContributionResolver.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index a54a5e6bf..3e13c404c 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -3,7 +3,7 @@ import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { Contribution as dbContribution } from '@entity/Contribution' import { Arg, Args, Authorized, Ctx, Mutation, Query, Resolver } from 'type-graphql' -import { IsNull } from '@dbTools/typeorm' +import { FindOperator, IsNull } from '@dbTools/typeorm' import ContributionArgs from '@arg/ContributionArgs' import Paginated from '@arg/Paginated' import { Order } from '@enum/Order' @@ -48,14 +48,11 @@ export class ContributionResolver { @Ctx() context: Context, ): Promise { const user = getUser(context) - const where = filterConfirmed - ? { - userId: user.id, - confirmedBy: IsNull(), - } - : { - userId: user.id, - } + const where: { + userId: number + confirmedBy?: FindOperator | null + } = { userId: user.id } + if (filterConfirmed) where.confirmedBy = IsNull() const contributions = await dbContribution.find({ where, order: { From 70db65044cfd5bf3bb42cce63968257616f1f1ed Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 14:09:40 +0200 Subject: [PATCH 053/103] Fix linting. --- backend/src/graphql/resolver/ContributionResolver.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 3e13c404c..41f6c9cd4 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -50,6 +50,7 @@ export class ContributionResolver { const user = getUser(context) const where: { userId: number + // eslint-disable-next-line @typescript-eslint/no-explicit-any confirmedBy?: FindOperator | null } = { userId: user.id } if (filterConfirmed) where.confirmedBy = IsNull() From d423e2d097b3e323b2408075baf48a16b750bf44 Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Mon, 11 Jul 2022 14:47:34 +0200 Subject: [PATCH 054/103] lint fix --- database/migrations/0041-update_transactions_for_blockchain.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/0041-update_transactions_for_blockchain.ts b/database/migrations/0041-update_transactions_for_blockchain.ts index 9d41ac4df..d7b26abbd 100644 --- a/database/migrations/0041-update_transactions_for_blockchain.ts +++ b/database/migrations/0041-update_transactions_for_blockchain.ts @@ -1913,5 +1913,5 @@ export async function downgrade(queryFn: (query: string, values?: any[]) => Prom WHERE \`id\` = 150`, ) - await queryFn(`UPDATE \`transactions\` set \`previous\` = 150 WHERE \`id\` = 278`) + await queryFn(`UPDATE \`transactions\` set \`previous\` = 150 WHERE \`id\` = 278`) } From eeafe2ddabb7262a7ee9fbaedd3b99a74c571a0c Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Mon, 11 Jul 2022 15:07:07 +0200 Subject: [PATCH 055/103] change order with other migration --- backend/src/config/index.ts | 2 +- ...blockchain.ts => 0042-update_transactions_for_blockchain.ts} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename database/migrations/{0041-update_transactions_for_blockchain.ts => 0042-update_transactions_for_blockchain.ts} (100%) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index cd24ee0c8..8b84c059d 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0041-update_transactions_for_blockchain', + DB_VERSION: '0042-update_transactions_for_blockchain', 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/database/migrations/0041-update_transactions_for_blockchain.ts b/database/migrations/0042-update_transactions_for_blockchain.ts similarity index 100% rename from database/migrations/0041-update_transactions_for_blockchain.ts rename to database/migrations/0042-update_transactions_for_blockchain.ts From 6d4d03013602569ce8543227bb324c9610a9220e Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Mon, 11 Jul 2022 15:08:41 +0200 Subject: [PATCH 056/103] exchanged order with other migration --- backend/src/config/index.ts | 2 +- ..._users_creation_date.ts => 0041-move_users_creation_date.ts} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename database/migrations/{0042-move_users_creation_date.ts => 0041-move_users_creation_date.ts} (100%) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 1f355623c..490ac0121 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0042-move_users_creation_date', + DB_VERSION: '0041-move_users_creation_date', 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/database/migrations/0042-move_users_creation_date.ts b/database/migrations/0041-move_users_creation_date.ts similarity index 100% rename from database/migrations/0042-move_users_creation_date.ts rename to database/migrations/0041-move_users_creation_date.ts From 339b32a02f76d41eb10d49934c16d7c8cb31a94f Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 11 Jul 2022 17:16:31 +0200 Subject: [PATCH 057/103] Change FindOperator to --- backend/src/graphql/resolver/ContributionResolver.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 41f6c9cd4..4424b40d0 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -50,8 +50,7 @@ export class ContributionResolver { const user = getUser(context) const where: { userId: number - // eslint-disable-next-line @typescript-eslint/no-explicit-any - confirmedBy?: FindOperator | null + confirmedBy?: FindOperator | null } = { userId: user.id } if (filterConfirmed) where.confirmedBy = IsNull() const contributions = await dbContribution.find({ From b6f1b0730a51dcfc6c8a97a84b021cadd0644bbf Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 08:44:36 +0200 Subject: [PATCH 058/103] Change the orders and structure from the tests for listContributions. --- .../resolver/ContributionResolver.test.ts | 75 +++++++++---------- 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 1e3034b59..b3d6aeb3c 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -150,6 +150,10 @@ describe('ContributionResolver', () => { describe('authenticated', () => { beforeAll(async () => { await userFactory(testEnv, bibiBloxberg) + await userFactory(testEnv, peterLustig) + const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + await creationFactory(testEnv, bibisCreation!) await query({ query: login, variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, @@ -163,46 +167,9 @@ describe('ContributionResolver', () => { }, }) }) - - it('returns only unconfirmed creations', async () => { - await expect( - query({ - query: listContributions, - variables: { - currentPage: 1, - pageSize: 25, - order: 'DESC', - filterConfirmed: true, - }, - }), - ).resolves.toEqual( - expect.objectContaining({ - data: { - listContributions: expect.arrayContaining([ - expect.objectContaining({ - id: expect.any(Number), - memo: 'Test env contribution', - amount: '100', - }), - ]), - }, - }), - ) - }) - - describe('Adding confirmed creations', () => { - beforeAll(async () => { - await userFactory(testEnv, peterLustig) - const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await creationFactory(testEnv, bibisCreation!) - await query({ - query: login, - variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, - }) - }) - - it('filter confirmed is false', async () => { + + describe('filter confirmed is false', () => { + it('returns creations', async () => { await expect( query({ query: listContributions, @@ -233,6 +200,34 @@ describe('ContributionResolver', () => { ) }) }) + + describe('filter confirmed is true', () => { + it('returns only unconfirmed creations', async () => { + await expect( + query({ + query: listContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: true, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listContributions: expect.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }), + ) + }) + }) }) }) }) From 0e13c7c2e12a66e6cbd41c1e6a167e6f5d32046c Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 08:47:15 +0200 Subject: [PATCH 059/103] Remove spaces. --- backend/src/graphql/resolver/ContributionResolver.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index b3d6aeb3c..9b0f6a3bc 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -167,7 +167,7 @@ describe('ContributionResolver', () => { }, }) }) - + describe('filter confirmed is false', () => { it('returns creations', async () => { await expect( From 5369aced43ee60b6788c6a00ca492efaa6f0452e Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 09:37:06 +0200 Subject: [PATCH 060/103] Change mutation to include id in the result, write test to update contribution with inexistent id. --- .../resolver/ContributionResolver.test.ts | 53 +++++++++++++++++++ backend/src/seeds/graphql/mutations.ts | 1 + 2 files changed, 54 insertions(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index c9302cf64..697c5ae43 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -13,6 +13,7 @@ import { peterLustig } from '@/seeds/users/peter-lustig' let mutate: any, query: any, con: any let testEnv: any +let result: any beforeAll(async () => { testEnv = await testEnvironment() @@ -159,6 +160,14 @@ describe('ContributionResolver', () => { query: login, variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, }) + await mutate({ + mutation: createContribution, + variables: { + amount: 100.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), + }, + }) }) afterAll(async () => { @@ -233,5 +242,49 @@ describe('ContributionResolver', () => { ) }) }) + + describe('authenticated', () => { + beforeAll(async () => { + await userFactory(testEnv, peterLustig) + await userFactory(testEnv, bibiBloxberg) + // bibi needs GDDs + const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + await creationFactory(testEnv, bibisCreation!) + // await userFactory(testEnv, bibiBloxberg) + await query({ + query: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + result = await mutate({ + mutation: createContribution, + variables: { + amount: 100.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), + }, + }) + }) + + describe('wrong contribution id', () => { + it('throws an error', async () => { + await expect( + mutate({ + mutation: updateContribution, + variables: { + contributionId: -1, + amount: 100.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('No contribution found to given id.')], + }), + ) + }) + }) + }) }) }) diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 45adeacc8..bfa9847e0 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -234,6 +234,7 @@ export const deleteContributionLink = gql` export const createContribution = gql` mutation ($amount: Decimal!, $memo: String!, $creationDate: String!) { createContribution(amount: $amount, memo: $memo, creationDate: $creationDate) { + id amount memo } From 86433478ec24dd58de4f6dcbd6f8560836eabe30 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 09:38:19 +0200 Subject: [PATCH 061/103] Test that only the user that created the contribution can update it with the updateContribution mutation. --- .../resolver/ContributionResolver.test.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 697c5ae43..41b5808a1 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -285,6 +285,37 @@ describe('ContributionResolver', () => { ) }) }) + + describe('wrong user tries to update the contribution', () => { + beforeAll(async () => { + await query({ + query: login, + variables: { email: 'peter@lustig.de', password: 'Aa12345_' }, + }) + }) + + it('throws an error', async () => { + await expect( + mutate({ + mutation: updateContribution, + variables: { + contributionId: result.data.createContribution.id, + amount: 10.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [ + new GraphQLError( + 'user of the pending contribution and send user does not correspond', + ), + ], + }), + ) + }) + }) }) }) }) From 6348756ab31a18fd1fcb7946918d8fc20a911487 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 09:39:24 +0200 Subject: [PATCH 062/103] Test that the updateContribution mutation can not update more gdd's than allowed in the month. --- .../resolver/ContributionResolver.test.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 41b5808a1..bdb8453da 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -316,6 +316,37 @@ describe('ContributionResolver', () => { ) }) }) + + describe('update to much so that the limit is exceeded', () => { + beforeAll(async () => { + await query({ + query: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + }) + + it('throws an error', async () => { + await expect( + mutate({ + mutation: updateContribution, + variables: { + contributionId: result.data.createContribution.id, + amount: 1019.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [ + new GraphQLError( + 'The amount (1019 GDD) to be created exceeds the amount (1000 GDD) still available for this month.', + ), + ], + }), + ) + }) + }) }) }) }) From 9e355f9202d05e208dcaf36438bfae489d3c8521 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 09:43:47 +0200 Subject: [PATCH 063/103] Test that the updateContribution mutation can not update contribution to a date that is older than 3 month. --- .../resolver/ContributionResolver.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index bdb8453da..d3d42be86 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -347,6 +347,29 @@ describe('ContributionResolver', () => { ) }) }) + + describe('update creation to a date that is older than 3 month', () => { + it('throws an error', async () => { + const date = new Date() // , + await expect( + mutate({ + mutation: updateContribution, + variables: { + contributionId: result.data.createContribution.id, + amount: 1019.0, + memo: 'Test env contribution', + creationDate: date.setMonth(date.getMonth() - 3).toString(), + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [ + new GraphQLError('No information for available creations for the given date'), + ], + }), + ) + }) + }) }) }) }) From 9ee40767bbf019e5ed44ed732909d287b00c6fb0 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 09:45:48 +0200 Subject: [PATCH 064/103] Change test so that only the date is to old and the amount could be right. --- backend/src/graphql/resolver/ContributionResolver.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index d3d42be86..31d46e2ae 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -356,7 +356,7 @@ describe('ContributionResolver', () => { mutation: updateContribution, variables: { contributionId: result.data.createContribution.id, - amount: 1019.0, + amount: 10.0, memo: 'Test env contribution', creationDate: date.setMonth(date.getMonth() - 3).toString(), }, From c6ae5760c3072bb89d4d68f395062f1b7eff208a Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 09:55:03 +0200 Subject: [PATCH 065/103] Test that the updateContribution mutation updates the contribution with the right values. --- .../resolver/ContributionResolver.test.ts | 26 +++++++++++++++++++ backend/src/seeds/graphql/mutations.ts | 1 + 2 files changed, 27 insertions(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 31d46e2ae..3c8046bc2 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -370,6 +370,32 @@ describe('ContributionResolver', () => { ) }) }) + + describe('valid input', () => { + it('updates contribution', async () => { + await expect( + mutate({ + mutation: updateContribution, + variables: { + contributionId: result.data.createContribution.id, + amount: 10.0, + memo: 'Test contribution', + creationDate: new Date().toString(), + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + updateContribution: { + id: result.data.createContribution.id, + amount: '10', + memo: 'Test contribution', + }, + }, + }), + ) + }) + }) }) }) }) diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index bfa9847e0..4e7fa8a90 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -249,6 +249,7 @@ export const updateContribution = gql` memo: $memo creationDate: $creationDate ) { + id amount memo } From b991bb0467035a5c18aa409ca99b93292fea41cd Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 10:11:28 +0200 Subject: [PATCH 066/103] Delete datas after all listContributions and updateContribution Tests. --- .../src/graphql/resolver/ContributionResolver.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index f690e10b1..a1f274fc6 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -169,6 +169,11 @@ describe('ContributionResolver', () => { }) }) + afterAll(async () => { + await cleanDB() + resetToken() + }) + describe('filter confirmed is false', () => { it('returns creations', async () => { await expect( @@ -276,6 +281,11 @@ describe('ContributionResolver', () => { }) }) + afterAll(async () => { + await cleanDB() + resetToken() + }) + describe('wrong contribution id', () => { it('throws an error', async () => { await expect( From 8a3c8253716d499fc8d0c6af421cc3dab6d02840 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 12 Jul 2022 10:27:52 +0200 Subject: [PATCH 067/103] feat: Login Returns Open Creations for User --- backend/src/graphql/model/User.ts | 8 +++++++- backend/src/graphql/resolver/UserResolver.ts | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/src/graphql/model/User.ts b/backend/src/graphql/model/User.ts index 86c56312f..0642be630 100644 --- a/backend/src/graphql/model/User.ts +++ b/backend/src/graphql/model/User.ts @@ -1,10 +1,12 @@ import { ObjectType, Field } from 'type-graphql' import { KlickTipp } from './KlickTipp' import { User as dbUser } from '@entity/User' +import Decimal from 'decimal.js-light' +import { FULL_CREATION_AVAILABLE } from '../resolver/const/const' @ObjectType() export class User { - constructor(user: dbUser) { + constructor(user: dbUser, creation: Decimal[] = FULL_CREATION_AVAILABLE) { this.id = user.id this.email = user.email this.firstName = user.firstName @@ -17,6 +19,7 @@ export class User { this.isAdmin = user.isAdmin this.klickTipp = null this.hasElopage = null + this.creation = creation } @Field(() => Number) @@ -64,4 +67,7 @@ export class User { @Field(() => Boolean, { nullable: true }) hasElopage: boolean | null + + @Field(() => [Decimal]) + creation: Decimal[] } diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 0bde22ae6..5b824b38f 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -23,6 +23,7 @@ import { sendAccountMultiRegistrationEmail } from '@/mailer/sendAccountMultiRegi import { klicktippSignIn } from '@/apis/KlicktippController' import { RIGHTS } from '@/auth/RIGHTS' import { hasElopageBuys } from '@/util/hasElopageBuys' +import { getUserCreation } from './util/creations' // eslint-disable-next-line @typescript-eslint/no-var-requires const sodium = require('sodium-native') @@ -224,7 +225,7 @@ export class UserResolver { logger.info('verifyLogin...') // TODO refactor and do not have duplicate code with login(see below) const userEntity = getUser(context) - const user = new User(userEntity) + const user = new User(userEntity, await getUserCreation(userEntity.id)) // user.pubkey = userEntity.pubKey.toString('hex') // Elopage Status & Stored PublisherId user.hasElopage = await this.hasElopage(context) @@ -274,7 +275,7 @@ export class UserResolver { logger.addContext('user', dbUser.id) logger.debug('login credentials valid...') - const user = new User(dbUser) + const user = new User(dbUser, await getUserCreation(dbUser.id)) logger.debug('user=' + user) // Elopage Status & Stored PublisherId From 0380609deeea78f4713205c3e0b217814ac2b018 Mon Sep 17 00:00:00 2001 From: Hannes Heine Date: Tue, 12 Jul 2022 12:54:46 +0200 Subject: [PATCH 068/103] Update backend/src/graphql/resolver/ContributionResolver.test.ts Co-authored-by: Moriz Wahl --- backend/src/graphql/resolver/ContributionResolver.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index a1f274fc6..a5c9b2f55 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -368,7 +368,7 @@ describe('ContributionResolver', () => { }) }) - describe('update creation to a date that is older than 3 month', () => { + describe('update creation to a date that is older than 3 months', () => { it('throws an error', async () => { const date = new Date() // , await expect( From 90d2ffbff3bc91713510a1817dcb10f901197a66 Mon Sep 17 00:00:00 2001 From: Hannes Heine Date: Tue, 12 Jul 2022 12:54:55 +0200 Subject: [PATCH 069/103] Update backend/src/graphql/resolver/ContributionResolver.test.ts Co-authored-by: Moriz Wahl --- backend/src/graphql/resolver/ContributionResolver.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index a5c9b2f55..731a897c1 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -370,7 +370,7 @@ describe('ContributionResolver', () => { describe('update creation to a date that is older than 3 months', () => { it('throws an error', async () => { - const date = new Date() // , + const date = new Date() await expect( mutate({ mutation: updateContribution, From 32d79bb61cdf19adee86e0403977e3f54255773f Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 12 Jul 2022 13:01:46 +0200 Subject: [PATCH 070/103] Corrected the spelling errors and withdrew admin creation on update scenario. --- backend/src/graphql/resolver/ContributionResolver.test.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 731a897c1..394d9fc7d 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -262,11 +262,6 @@ describe('ContributionResolver', () => { beforeAll(async () => { await userFactory(testEnv, peterLustig) await userFactory(testEnv, bibiBloxberg) - // bibi needs GDDs - const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await creationFactory(testEnv, bibisCreation!) - // await userFactory(testEnv, bibiBloxberg) await query({ query: login, variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, @@ -337,7 +332,7 @@ describe('ContributionResolver', () => { }) }) - describe('update to much so that the limit is exceeded', () => { + describe('update too much so that the limit is exceeded', () => { beforeAll(async () => { await query({ query: login, From 3e471eb81ee0037e40c6d127e90ef546250378aa Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 12 Jul 2022 16:54:37 +0200 Subject: [PATCH 071/103] add creation on login query and store --- frontend/src/graphql/queries.js | 2 ++ frontend/src/store/store.js | 6 ++++++ frontend/src/store/store.test.js | 25 +++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index adcd653a4..27e63d568 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -13,6 +13,7 @@ export const login = gql` hasElopage publisherId isAdmin + creation } } ` @@ -30,6 +31,7 @@ export const verifyLogin = gql` hasElopage publisherId isAdmin + creation } } ` diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index e95eec7b9..8fdbc519e 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -47,6 +47,9 @@ export const mutations = { hasElopage: (state, hasElopage) => { state.hasElopage = hasElopage }, + creation: (state, creation) => { + state.creation = creation + }, } export const actions = { @@ -60,6 +63,7 @@ export const actions = { commit('hasElopage', data.hasElopage) commit('publisherId', data.publisherId) commit('isAdmin', data.isAdmin) + commit('creation', data.creation) }, logout: ({ commit, state }) => { commit('token', null) @@ -71,6 +75,7 @@ export const actions = { commit('hasElopage', false) commit('publisherId', null) commit('isAdmin', false) + commit('creation', null) localStorage.clear() }, } @@ -96,6 +101,7 @@ try { newsletterState: null, hasElopage: false, publisherId: null, + creation: null, }, getters: {}, // Syncronous mutation of the state diff --git a/frontend/src/store/store.test.js b/frontend/src/store/store.test.js index 3f942fa35..0493d7f53 100644 --- a/frontend/src/store/store.test.js +++ b/frontend/src/store/store.test.js @@ -30,6 +30,7 @@ const { publisherId, isAdmin, hasElopage, + creation, } = mutations const { login, logout } = actions @@ -139,6 +140,14 @@ describe('Vuex store', () => { expect(state.hasElopage).toBeTruthy() }) }) + + describe('creation', () => { + it('sets the state of creation', () => { + const state = { creation: null } + creation(state, true) + expect(state.creation).toEqual(true) + }) + }) }) describe('actions', () => { @@ -156,11 +165,12 @@ describe('Vuex store', () => { hasElopage: false, publisherId: 1234, isAdmin: true, + creation: ['1000', '1000', '1000'], } it('calls nine commits', () => { login({ commit, state }, commitedData) - expect(commit).toHaveBeenCalledTimes(8) + expect(commit).toHaveBeenCalledTimes(9) }) it('commits email', () => { @@ -202,6 +212,11 @@ describe('Vuex store', () => { login({ commit, state }, commitedData) expect(commit).toHaveBeenNthCalledWith(8, 'isAdmin', true) }) + + it('commits creation', () => { + login({ commit, state }, commitedData) + expect(commit).toHaveBeenNthCalledWith(9, 'creation', ['1000', '1000', '1000']) + }) }) describe('logout', () => { @@ -210,7 +225,7 @@ describe('Vuex store', () => { it('calls nine commits', () => { logout({ commit, state }) - expect(commit).toHaveBeenCalledTimes(8) + expect(commit).toHaveBeenCalledTimes(9) }) it('commits token', () => { @@ -253,6 +268,12 @@ describe('Vuex store', () => { expect(commit).toHaveBeenNthCalledWith(8, 'isAdmin', false) }) + it('commits creation', () => { + logout({ commit, state }) + expect(commit).toHaveBeenNthCalledWith(9, 'creation', null) + }) + + // how to get this working? it.skip('calls localStorage.clear()', () => { const clearStorageMock = jest.fn() From bc8078c427883aa5192a5d1b54556fb8f285e5d6 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 12 Jul 2022 16:55:50 +0200 Subject: [PATCH 072/103] fix lint --- frontend/src/store/store.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/store/store.test.js b/frontend/src/store/store.test.js index 0493d7f53..651a3ccc5 100644 --- a/frontend/src/store/store.test.js +++ b/frontend/src/store/store.test.js @@ -273,7 +273,6 @@ describe('Vuex store', () => { expect(commit).toHaveBeenNthCalledWith(9, 'creation', null) }) - // how to get this working? it.skip('calls localStorage.clear()', () => { const clearStorageMock = jest.fn() From c6bab99a2c96e8fcdf80e72c7878ec8e9f5502c2 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 13 Jul 2022 08:26:30 +0200 Subject: [PATCH 073/103] Add Test that adminUpdateContribution is not allowed on creation made by createContribution mutation. --- .../resolver/ContributionResolver.test.ts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 394d9fc7d..75d6d1128 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -2,7 +2,7 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' -import { createContribution, updateContribution } from '@/seeds/graphql/mutations' +import { adminUpdateContribution, createContribution, updateContribution } from '@/seeds/graphql/mutations' import { listContributions, login } from '@/seeds/graphql/queries' import { cleanDB, resetToken, testEnvironment } from '@test/helpers' import { GraphQLError } from 'graphql' @@ -332,6 +332,27 @@ describe('ContributionResolver', () => { }) }) + describe('admin tries to update a user contribution', () => { + it('throws an error', async () => { + await expect( + mutate({ + mutation: adminUpdateContribution, + variables: { + id: result.data.createContribution.id, + email: 'bibi@bloxberg.de', + amount: 10.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('An admin is not allowed to update a user contribution.')], + }), + ) + }) + }) + describe('update too much so that the limit is exceeded', () => { beforeAll(async () => { await query({ From 801e223cfd29398004b267ced763eb9d530421f7 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 13 Jul 2022 08:27:05 +0200 Subject: [PATCH 074/103] Implement that adminUpdateContribution is not allowed when moderator is null. --- backend/src/graphql/resolver/AdminResolver.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index e3c61c300..12cad529c 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -321,6 +321,10 @@ export class AdminResolver { throw new Error('user of the pending contribution and send user does not correspond') } + if (contributionToUpdate.moderatorId === null) { + throw new Error('An admin is not allowed to update a user contribution.') + } + const creationDateObj = new Date(creationDate) let creations = await getUserCreation(user.id) if (contributionToUpdate.contributionDate.getMonth() === creationDateObj.getMonth()) { From e1d50cacb521b3fabec9eaae67cdf29987531139 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 13 Jul 2022 09:55:21 +0200 Subject: [PATCH 075/103] Fix linting. --- backend/src/graphql/resolver/ContributionResolver.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 75d6d1128..7afae08f6 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -2,7 +2,11 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' -import { adminUpdateContribution, createContribution, updateContribution } from '@/seeds/graphql/mutations' +import { + adminUpdateContribution, + createContribution, + updateContribution, +} from '@/seeds/graphql/mutations' import { listContributions, login } from '@/seeds/graphql/queries' import { cleanDB, resetToken, testEnvironment } from '@test/helpers' import { GraphQLError } from 'graphql' From 9d9d1a78f18abda66333139ac1b4ffd66e631607 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 13 Jul 2022 11:01:44 +0200 Subject: [PATCH 076/103] Add confirmedBy and confirmedAt for the contribution query. --- backend/src/graphql/model/Contribution.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts index dc1dd39e9..348a6eb98 100644 --- a/backend/src/graphql/model/Contribution.ts +++ b/backend/src/graphql/model/Contribution.ts @@ -12,6 +12,8 @@ export class Contribution { this.memo = contribution.memo this.createdAt = contribution.createdAt this.deletedAt = contribution.deletedAt + this.confirmedAt = contribution.confirmedAt + this.confirmedBy = contribution.confirmedBy } @Field(() => Number) @@ -31,6 +33,12 @@ export class Contribution { @Field(() => Date, { nullable: true }) deletedAt: Date | null + + @Field(() => Date, { nullable: true }) + confirmedAt: Date | null + + @Field(() => Number, { nullable: true }) + confirmedBy: number | null } @ObjectType() From 99c4e8367048fe1d100a307be5febd84b6036177 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 13 Jul 2022 11:26:18 +0200 Subject: [PATCH 077/103] Add deleted contribution to the list of contribution. --- backend/src/graphql/resolver/ContributionResolver.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 4424b40d0..562859116 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -58,6 +58,7 @@ export class ContributionResolver { order: { createdAt: order, }, + withDeleted: true, skip: (currentPage - 1) * pageSize, take: pageSize, }) From b7c24978392ae1f74baf3442ed32521d167c6637 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 13 Jul 2022 12:18:47 +0200 Subject: [PATCH 078/103] Add new right LIST_ALL_CONFIRMED_CONTRIBUTIONS. --- backend/src/auth/RIGHTS.ts | 1 + backend/src/auth/ROLES.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/backend/src/auth/RIGHTS.ts b/backend/src/auth/RIGHTS.ts index 6a6f8b7c0..975c2006a 100644 --- a/backend/src/auth/RIGHTS.ts +++ b/backend/src/auth/RIGHTS.ts @@ -27,6 +27,7 @@ export enum RIGHTS { GDT_BALANCE = 'GDT_BALANCE', CREATE_CONTRIBUTION = 'CREATE_CONTRIBUTION', LIST_CONTRIBUTIONS = 'LIST_CONTRIBUTIONS', + LIST_ALL_CONFIRMED_CONTRIBUTIONS = 'LIST_ALL_CONFIRMED_CONTRIBUTIONS', // Admin SEARCH_USERS = 'SEARCH_USERS', SET_USER_ROLE = 'SET_USER_ROLE', diff --git a/backend/src/auth/ROLES.ts b/backend/src/auth/ROLES.ts index f56106664..e5628bb62 100644 --- a/backend/src/auth/ROLES.ts +++ b/backend/src/auth/ROLES.ts @@ -25,6 +25,7 @@ export const ROLE_USER = new Role('user', [ RIGHTS.GDT_BALANCE, RIGHTS.CREATE_CONTRIBUTION, RIGHTS.LIST_CONTRIBUTIONS, + RIGHTS.LIST_ALL_CONFIRMED_CONTRIBUTIONS, ]) export const ROLE_ADMIN = new Role('admin', Object.values(RIGHTS)) // all rights From ed10d7d1a00b8cc8ae65d6efa1323921e800e649 Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 13 Jul 2022 14:54:17 +0200 Subject: [PATCH 079/103] set session timer to 0, if expiration is greater then 0 seconds --- frontend/src/components/SessionLogoutTimeout.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/SessionLogoutTimeout.vue b/frontend/src/components/SessionLogoutTimeout.vue index 1e5a27998..113362abf 100644 --- a/frontend/src/components/SessionLogoutTimeout.vue +++ b/frontend/src/components/SessionLogoutTimeout.vue @@ -65,7 +65,7 @@ export default { this.$timer.restart('tokenExpires') this.$bvModal.show('modalSessionTimeOut') } - if (this.tokenExpiresInSeconds <= 0) { + if (this.tokenExpiresInSeconds === 0) { this.$timer.stop('tokenExpires') this.$emit('logout') } @@ -90,7 +90,11 @@ export default { }, computed: { tokenExpiresInSeconds() { - return Math.floor((new Date(this.$store.state.tokenTime * 1000).getTime() - this.now) / 1000) + const remainingSecs = Math.floor( + (new Date(this.$store.state.tokenTime * 1000).getTime() - this.now) / 1000, + ) + if (remainingSecs <= 0) return 0 + return remainingSecs }, }, beforeDestroy() { From b2164e6d1dc90fed257fcbb95601b5b5cc218e46 Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 13 Jul 2022 14:54:47 +0200 Subject: [PATCH 080/103] add unit test for this fix --- frontend/src/components/SessionLogoutTimeout.spec.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/SessionLogoutTimeout.spec.js b/frontend/src/components/SessionLogoutTimeout.spec.js index 0f5d21d36..94751f9cb 100644 --- a/frontend/src/components/SessionLogoutTimeout.spec.js +++ b/frontend/src/components/SessionLogoutTimeout.spec.js @@ -62,12 +62,16 @@ describe('SessionLogoutTimeout', () => { }) }) - describe('token is expired', () => { + describe('token is expired for several seconds', () => { beforeEach(() => { mocks.$store.state.tokenTime = setTokenTime(-60) wrapper = Wrapper() }) + it('value for remaining seconds is 0', () => { + expect(wrapper.tokenExpiresInSeconds === 0) + }) + it('emits logout', () => { expect(wrapper.emitted('logout')).toBeTruthy() }) From 1d1cc7e960aa845de7a659f6e5f4f25442c52e1b Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 13 Jul 2022 15:36:15 +0200 Subject: [PATCH 081/103] Update frontend/src/components/SessionLogoutTimeout.spec.js Co-authored-by: Moriz Wahl --- frontend/src/components/SessionLogoutTimeout.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/SessionLogoutTimeout.spec.js b/frontend/src/components/SessionLogoutTimeout.spec.js index 94751f9cb..bd6911d13 100644 --- a/frontend/src/components/SessionLogoutTimeout.spec.js +++ b/frontend/src/components/SessionLogoutTimeout.spec.js @@ -68,7 +68,7 @@ describe('SessionLogoutTimeout', () => { wrapper = Wrapper() }) - it('value for remaining seconds is 0', () => { + it('has value for remaining seconds equal 0', () => { expect(wrapper.tokenExpiresInSeconds === 0) }) From 2302da9054785b8b4a7ca330fd1ddbdd42826ce0 Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 13 Jul 2022 15:36:40 +0200 Subject: [PATCH 082/103] Update frontend/src/components/SessionLogoutTimeout.vue Co-authored-by: Moriz Wahl --- frontend/src/components/SessionLogoutTimeout.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/components/SessionLogoutTimeout.vue b/frontend/src/components/SessionLogoutTimeout.vue index 113362abf..f10b8114a 100644 --- a/frontend/src/components/SessionLogoutTimeout.vue +++ b/frontend/src/components/SessionLogoutTimeout.vue @@ -93,8 +93,7 @@ export default { const remainingSecs = Math.floor( (new Date(this.$store.state.tokenTime * 1000).getTime() - this.now) / 1000, ) - if (remainingSecs <= 0) return 0 - return remainingSecs + return remainingSecs <= 0 ? 0 : remainingSecs }, }, beforeDestroy() { From 90d90ca9bd9960457aa6a3267e73628d21675519 Mon Sep 17 00:00:00 2001 From: mahula Date: Wed, 13 Jul 2022 19:04:38 +0200 Subject: [PATCH 083/103] fix linting --- frontend/src/components/SessionLogoutTimeout.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/SessionLogoutTimeout.vue b/frontend/src/components/SessionLogoutTimeout.vue index f10b8114a..1ebff752a 100644 --- a/frontend/src/components/SessionLogoutTimeout.vue +++ b/frontend/src/components/SessionLogoutTimeout.vue @@ -93,7 +93,7 @@ export default { const remainingSecs = Math.floor( (new Date(this.$store.state.tokenTime * 1000).getTime() - this.now) / 1000, ) - return remainingSecs <= 0 ? 0 : remainingSecs + return remainingSecs <= 0 ? 0 : remainingSecs }, }, beforeDestroy() { From 7c698de325294811d144f6ac7bac058d44200735 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 12:25:45 +0200 Subject: [PATCH 084/103] Add constructor to ContributionListResult. --- backend/src/graphql/model/Contribution.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts index dc1dd39e9..989296848 100644 --- a/backend/src/graphql/model/Contribution.ts +++ b/backend/src/graphql/model/Contribution.ts @@ -35,6 +35,11 @@ export class Contribution { @ObjectType() export class ContributionListResult { + constructor(count: number, list: Contribution[]) { + this.linkCount = count + this.linkList = list + } + @Field(() => Int) linkCount: number From 2f90bd981126ef77f744beacb5fa8d27bc3cc225 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 12:58:01 +0200 Subject: [PATCH 085/103] Withdrew User from Contribution object and replaced it with userId, firstName and lastName. --- backend/src/graphql/model/Contribution.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts index 989296848..324b0ff07 100644 --- a/backend/src/graphql/model/Contribution.ts +++ b/backend/src/graphql/model/Contribution.ts @@ -7,7 +7,9 @@ import { User } from './User' export class Contribution { constructor(contribution: dbContribution, user: User) { this.id = contribution.id - this.user = user + this.userId = user ? user.id : null + this.firstName = user ? user.firstName : null + this.lastName = user ? user.lastName : null this.amount = contribution.amount this.memo = contribution.memo this.createdAt = contribution.createdAt @@ -17,8 +19,14 @@ export class Contribution { @Field(() => Number) id: number - @Field(() => User) - user: User + @Field(() => Number, { nullable: true }) + userId: number | null + + @Field(() => String, { nullable: true }) + firstName: string | null + + @Field(() => String, { nullable: true }) + lastName: string | null @Field(() => Decimal) amount: Decimal From c02f575780166a8f2e6c29df4a83ffac59fcd36d Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 12:59:21 +0200 Subject: [PATCH 086/103] Withdrew userid from contribution object. --- backend/src/graphql/model/Contribution.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts index 324b0ff07..a1537244d 100644 --- a/backend/src/graphql/model/Contribution.ts +++ b/backend/src/graphql/model/Contribution.ts @@ -7,7 +7,6 @@ import { User } from './User' export class Contribution { constructor(contribution: dbContribution, user: User) { this.id = contribution.id - this.userId = user ? user.id : null this.firstName = user ? user.firstName : null this.lastName = user ? user.lastName : null this.amount = contribution.amount @@ -19,9 +18,6 @@ export class Contribution { @Field(() => Number) id: number - @Field(() => Number, { nullable: true }) - userId: number | null - @Field(() => String, { nullable: true }) firstName: string | null From 8c6ec08e88aa4350134c2efd812a77ddfbeea2d6 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 16:42:55 +0200 Subject: [PATCH 087/103] Gives a list of allCreations and calls the User one time in the creation. --- .../graphql/resolver/ContributionResolver.ts | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 4424b40d0..8a23b3150 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -2,12 +2,13 @@ import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { Contribution as dbContribution } from '@entity/Contribution' +import { User as dbUser } from '@entity/User' import { Arg, Args, Authorized, Ctx, Mutation, Query, Resolver } from 'type-graphql' -import { FindOperator, IsNull } from '@dbTools/typeorm' +import { FindOperator, IsNull, Not } from '@dbTools/typeorm' import ContributionArgs from '@arg/ContributionArgs' import Paginated from '@arg/Paginated' import { Order } from '@enum/Order' -import { Contribution } from '@model/Contribution' +import { Contribution, ContributionListResult } from '@model/Contribution' import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import { User } from '@model/User' import { validateContribution, getUserCreation } from './util/creations' @@ -63,4 +64,37 @@ export class ContributionResolver { }) return contributions.map((contribution) => new Contribution(contribution, new User(user))) } + + @Authorized([RIGHTS.LIST_ALL_CONFIRMED_CONTRIBUTIONS]) + @Query(() => ContributionListResult) + async listAllConfirmedContributions( + @Args() + { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, + ): Promise { + const dbContributions = await dbContribution.find({ + order: { + createdAt: order, + }, + skip: (currentPage - 1) * pageSize, + take: pageSize, + }) + const contributions: Contribution[] = [] + const userIds: number[] = [] + dbContributions.forEach(async (dbContribution) => { + userIds.push(dbContribution.userId) + }) + userIds.filter((elem, index, self) => { + return index === self.indexOf(elem) + }) + const users = new Map() + for (let i = 0; i < userIds.length; i++) { + const id = userIds[i] + const user = await dbUser.findOneOrFail({ id }) + users.set(id, user) + } + dbContributions.forEach((dbContribution) => { + contributions.push(new Contribution(dbContribution, users.get(dbContribution.userId))) + }) + return new ContributionListResult(contributions.length, contributions) + } } From fdea5f68ef8fd78176ce3ea5707c6cc270d2abbd Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 16:43:20 +0200 Subject: [PATCH 088/103] Add confirmedBy and confirmedAt for the contribution query. --- backend/src/graphql/model/Contribution.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts index a1537244d..34bffd6d7 100644 --- a/backend/src/graphql/model/Contribution.ts +++ b/backend/src/graphql/model/Contribution.ts @@ -13,6 +13,8 @@ export class Contribution { this.memo = contribution.memo this.createdAt = contribution.createdAt this.deletedAt = contribution.deletedAt + this.confirmedAt = contribution.confirmedAt + this.confirmedBy = contribution.confirmedBy } @Field(() => Number) @@ -35,6 +37,12 @@ export class Contribution { @Field(() => Date, { nullable: true }) deletedAt: Date | null + + @Field(() => Date, { nullable: true }) + confirmedAt: Date | null + + @Field(() => Number, { nullable: true }) + confirmedBy: number | null } @ObjectType() From cbbe0ffad2cf8a528d5a3c5c5a336cfed7afe82b Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 16:45:19 +0200 Subject: [PATCH 089/103] Change the method name from listAllConfirmedContributions to listAllContributions. --- backend/src/auth/RIGHTS.ts | 2 +- backend/src/auth/ROLES.ts | 2 +- backend/src/graphql/resolver/ContributionResolver.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/auth/RIGHTS.ts b/backend/src/auth/RIGHTS.ts index 975c2006a..5258c9e3b 100644 --- a/backend/src/auth/RIGHTS.ts +++ b/backend/src/auth/RIGHTS.ts @@ -27,7 +27,7 @@ export enum RIGHTS { GDT_BALANCE = 'GDT_BALANCE', CREATE_CONTRIBUTION = 'CREATE_CONTRIBUTION', LIST_CONTRIBUTIONS = 'LIST_CONTRIBUTIONS', - LIST_ALL_CONFIRMED_CONTRIBUTIONS = 'LIST_ALL_CONFIRMED_CONTRIBUTIONS', + LIST_ALL_CONTRIBUTIONS = 'LIST_ALL_CONTRIBUTIONS', // Admin SEARCH_USERS = 'SEARCH_USERS', SET_USER_ROLE = 'SET_USER_ROLE', diff --git a/backend/src/auth/ROLES.ts b/backend/src/auth/ROLES.ts index e5628bb62..4a96d4813 100644 --- a/backend/src/auth/ROLES.ts +++ b/backend/src/auth/ROLES.ts @@ -25,7 +25,7 @@ export const ROLE_USER = new Role('user', [ RIGHTS.GDT_BALANCE, RIGHTS.CREATE_CONTRIBUTION, RIGHTS.LIST_CONTRIBUTIONS, - RIGHTS.LIST_ALL_CONFIRMED_CONTRIBUTIONS, + RIGHTS.LIST_ALL_CONTRIBUTIONS, ]) export const ROLE_ADMIN = new Role('admin', Object.values(RIGHTS)) // all rights diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 8a23b3150..c015496c1 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -65,9 +65,9 @@ export class ContributionResolver { return contributions.map((contribution) => new Contribution(contribution, new User(user))) } - @Authorized([RIGHTS.LIST_ALL_CONFIRMED_CONTRIBUTIONS]) + @Authorized([RIGHTS.LIST_ALL_CONTRIBUTIONS]) @Query(() => ContributionListResult) - async listAllConfirmedContributions( + async listAllContributions( @Args() { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, ): Promise { From ab77a798f589c4907ae149f127e9e7c7c56219bb Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 16:57:25 +0200 Subject: [PATCH 090/103] Add query seed for listAllContributions. --- backend/src/seeds/graphql/queries.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index c27ecdd66..deae5f97b 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -191,6 +191,24 @@ export const listContributions = gql` } } ` + +export const listAllContributions = ` +query ($currentPage: Int = 1, $pageSize: Int = 5, $order: Order = DESC) { + listAllContributions(currentPage: $currentPage, pageSize: $pageSize, order: $order) { + linkCount + linkList { + id + firstName + lastName + amount + memo + createdAt + confirmedAt + confirmedBy + } + } +} +` // from admin interface export const listUnconfirmedContributions = gql` From ba90911aec704026ee6953e9db0f3731ef263116 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 16:57:57 +0200 Subject: [PATCH 091/103] Test that unauthenticated user can not query listAllContributions. --- .../resolver/ContributionResolver.test.ts | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 9b0f6a3bc..a4cb1d714 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -3,7 +3,7 @@ import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { createContribution } from '@/seeds/graphql/mutations' -import { listContributions, login } from '@/seeds/graphql/queries' +import { listAllContributions, listContributions, login } from '@/seeds/graphql/queries' import { cleanDB, resetToken, testEnvironment } from '@test/helpers' import { GraphQLError } from 'graphql' import { userFactory } from '@/seeds/factory/user' @@ -168,6 +168,11 @@ describe('ContributionResolver', () => { }) }) + afterAll(async () => { + await cleanDB() + await con.close() + }) + describe('filter confirmed is false', () => { it('returns creations', async () => { await expect( @@ -230,4 +235,53 @@ describe('ContributionResolver', () => { }) }) }) + + describe('listAllContribution', () => { + describe('unauthenticated', () => { + it('returns an error', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: false, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) + + describe('authenticated', () => { + beforeAll(async () => { + await userFactory(testEnv, bibiBloxberg) + await userFactory(testEnv, peterLustig) + const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + await creationFactory(testEnv, bibisCreation!) + await query({ + query: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + await mutate({ + mutation: createContribution, + variables: { + amount: 100.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), + }, + }) + }) + + afterAll(async () => { + await cleanDB() + await con.close() + }) + }) + }) }) From 246edadc1314e6092eb51daa7ffdf9eeff72e72f Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 17:22:22 +0200 Subject: [PATCH 092/103] Test that authenticated user gets allContributions. --- .../resolver/ContributionResolver.test.ts | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index a4cb1d714..9aa247d4e 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -261,9 +261,9 @@ describe('ContributionResolver', () => { beforeAll(async () => { await userFactory(testEnv, bibiBloxberg) await userFactory(testEnv, peterLustig) - const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') + creations.forEach(async (creation) => await creationFactory(testEnv, creation!)) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await creationFactory(testEnv, bibisCreation!) + // await creationFactory(testEnv, creations!) await query({ query: login, variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, @@ -282,6 +282,37 @@ describe('ContributionResolver', () => { await cleanDB() await con.close() }) + + it('returns allCreation', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: false, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listAllContributions: expect.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.objectContaining({ + id: expect.any(Number), + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }), + ) + }) }) }) }) From 3733bf511483f09fae6d37c2e5926c75ae247487 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 17:30:21 +0200 Subject: [PATCH 093/103] Change con.close to resetToken method. --- backend/src/graphql/resolver/ContributionResolver.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 9aa247d4e..124adff18 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -170,7 +170,7 @@ describe('ContributionResolver', () => { afterAll(async () => { await cleanDB() - await con.close() + resetToken() }) describe('filter confirmed is false', () => { @@ -280,7 +280,7 @@ describe('ContributionResolver', () => { afterAll(async () => { await cleanDB() - await con.close() + resetToken() }) it('returns allCreation', async () => { From 34de4bb9014497a0db5a2d0d5cdcf662ff954ee2 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 17:42:49 +0200 Subject: [PATCH 094/103] Merge conflict on contribution resolver test file --- .../resolver/ContributionResolver.test.ts | 142 ++++++++++-------- 1 file changed, 78 insertions(+), 64 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index fd9636439..4f57cc0a1 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -2,17 +2,12 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' -<<<<<<< HEAD -import { createContribution } from '@/seeds/graphql/mutations' -import { listAllContributions, listContributions, login } from '@/seeds/graphql/queries' -======= import { adminUpdateContribution, createContribution, updateContribution, } from '@/seeds/graphql/mutations' -import { listContributions, login } from '@/seeds/graphql/queries' ->>>>>>> master +import { listAllContributions, listContributions, login } from '@/seeds/graphql/queries' import { cleanDB, resetToken, testEnvironment } from '@test/helpers' import { GraphQLError } from 'graphql' import { userFactory } from '@/seeds/factory/user' @@ -246,19 +241,6 @@ describe('ContributionResolver', () => { }) }) -<<<<<<< HEAD - describe('listAllContribution', () => { - describe('unauthenticated', () => { - it('returns an error', async () => { - await expect( - query({ - query: listAllContributions, - variables: { - currentPage: 1, - pageSize: 25, - order: 'DESC', - filterConfirmed: false, -======= describe('updateContribution', () => { describe('unauthenticated', () => { it('returns an error', async () => { @@ -270,7 +252,6 @@ describe('ContributionResolver', () => { amount: 100.0, memo: 'Test Contribution', creationDate: 'not-valid', ->>>>>>> master }, }), ).resolves.toEqual( @@ -283,25 +264,13 @@ describe('ContributionResolver', () => { describe('authenticated', () => { beforeAll(async () => { -<<<<<<< HEAD - await userFactory(testEnv, bibiBloxberg) - await userFactory(testEnv, peterLustig) - creations.forEach(async (creation) => await creationFactory(testEnv, creation!)) - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - // await creationFactory(testEnv, creations!) -======= await userFactory(testEnv, peterLustig) await userFactory(testEnv, bibiBloxberg) ->>>>>>> master await query({ query: login, variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, }) -<<<<<<< HEAD - await mutate({ -======= result = await mutate({ ->>>>>>> master mutation: createContribution, variables: { amount: 100.0, @@ -316,37 +285,6 @@ describe('ContributionResolver', () => { resetToken() }) -<<<<<<< HEAD - it('returns allCreation', async () => { - await expect( - query({ - query: listAllContributions, - variables: { - currentPage: 1, - pageSize: 25, - order: 'DESC', - filterConfirmed: false, - }, - }), - ).resolves.toEqual( - expect.objectContaining({ - data: { - listAllContributions: expect.arrayContaining([ - expect.objectContaining({ - id: expect.any(Number), - memo: 'Herzlich Willkommen bei Gradido!', - amount: '1000', - }), - expect.objectContaining({ - id: expect.any(Number), - memo: 'Test env contribution', - amount: '100', - }), - ]), - }, - }), - ) -======= describe('wrong contribution id', () => { it('throws an error', async () => { await expect( @@ -497,8 +435,84 @@ describe('ContributionResolver', () => { }), ) }) ->>>>>>> master + }) + + describe('listAllContribution', () => { + describe('unauthenticated', () => { + it('returns an error', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: false, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) }) }) }) + + describe('authenticated', () => { + beforeAll(async () => { + await userFactory(testEnv, bibiBloxberg) + await userFactory(testEnv, peterLustig) + creations.forEach(async (creation) => await creationFactory(testEnv, creation!)) + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + // await creationFactory(testEnv, creations!) + await userFactory(testEnv, peterLustig) + await userFactory(testEnv, bibiBloxberg) + await query({ + query: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + result = await mutate({ + mutation: createContribution, + variables: { + amount: 100.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), + }, + }) + }) + + it('returns allCreation', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: false, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listAllContributions: expect.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.objectContaining({ + id: expect.any(Number), + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }), + ) + }) + }) }) From c242f977337a5e048dcd1cfecf818f3d92d0456d Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 17:52:31 +0200 Subject: [PATCH 095/103] Change the test for listAllContributions to have every seed user and create all creations, add Test suite that checks if every seeded data arrives as well. --- .../resolver/ContributionResolver.test.ts | 141 +++++++++--------- 1 file changed, 72 insertions(+), 69 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 4f57cc0a1..b294fb40d 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -14,6 +14,8 @@ import { userFactory } from '@/seeds/factory/user' import { creationFactory } from '@/seeds/factory/creation' import { creations } from '@/seeds/creation/index' import { peterLustig } from '@/seeds/users/peter-lustig' +import { bobBaumeister } from '@/seeds/users/bob-baumeister' +import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz' let mutate: any, query: any, con: any let testEnv: any @@ -436,83 +438,84 @@ describe('ContributionResolver', () => { ) }) }) - - describe('listAllContribution', () => { - describe('unauthenticated', () => { - it('returns an error', async () => { - await expect( - query({ - query: listAllContributions, - variables: { - currentPage: 1, - pageSize: 25, - order: 'DESC', - filterConfirmed: false, - }, - }), - ).resolves.toEqual( - expect.objectContaining({ - errors: [new GraphQLError('401 Unauthorized')], - }), - ) - }) - }) - }) }) }) - describe('authenticated', () => { - beforeAll(async () => { - await userFactory(testEnv, bibiBloxberg) - await userFactory(testEnv, peterLustig) - creations.forEach(async (creation) => await creationFactory(testEnv, creation!)) - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - // await creationFactory(testEnv, creations!) - await userFactory(testEnv, peterLustig) - await userFactory(testEnv, bibiBloxberg) - await query({ - query: login, - variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, - }) - result = await mutate({ - mutation: createContribution, - variables: { - amount: 100.0, - memo: 'Test env contribution', - creationDate: new Date().toString(), - }, + describe('listAllContribution', () => { + describe('unauthenticated', () => { + it('returns an error', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: false, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) }) }) - it('returns allCreation', async () => { - await expect( - query({ - query: listAllContributions, + describe('authenticated', () => { + beforeAll(async () => { + await userFactory(testEnv, bibiBloxberg) + await userFactory(testEnv, peterLustig) + await userFactory(testEnv, raeuberHotzenplotz) + await userFactory(testEnv, bobBaumeister) + creations.forEach(async (creation) => await creationFactory(testEnv, creation!)) + await query({ + query: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + result = await mutate({ + mutation: createContribution, variables: { - currentPage: 1, - pageSize: 25, - order: 'DESC', - filterConfirmed: false, + amount: 100.0, + memo: 'Test env contribution', + creationDate: new Date().toString(), }, - }), - ).resolves.toEqual( - expect.objectContaining({ - data: { - listAllContributions: expect.arrayContaining([ - expect.objectContaining({ - id: expect.any(Number), - memo: 'Herzlich Willkommen bei Gradido!', - amount: '1000', - }), - expect.objectContaining({ - id: expect.any(Number), - memo: 'Test env contribution', - amount: '100', - }), - ]), - }, - }), - ) + }) + }) + + it('returns allCreation', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterConfirmed: false, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listAllContributions: { + linkCount: 25, + linkList: expect.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.objectContaining({ + id: expect.any(Number), + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }, + }), + ) + }) }) }) }) From b86ddbf8b0be90856de0a3a3e2b990745e9a5804 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 14 Jul 2022 18:08:51 +0200 Subject: [PATCH 096/103] Fix linting. --- backend/src/graphql/resolver/ContributionResolver.test.ts | 1 + backend/src/graphql/resolver/ContributionResolver.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index b294fb40d..247d1be0e 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -468,6 +468,7 @@ describe('ContributionResolver', () => { await userFactory(testEnv, peterLustig) await userFactory(testEnv, raeuberHotzenplotz) await userFactory(testEnv, bobBaumeister) + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion creations.forEach(async (creation) => await creationFactory(testEnv, creation!)) await query({ query: login, diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 3faffb95d..cdaa5faa3 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -4,7 +4,7 @@ import { backendLogger as logger } from '@/server/logger' import { Contribution as dbContribution } from '@entity/Contribution' import { User as dbUser } from '@entity/User' import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' -import { FindOperator, IsNull, Not } from '@dbTools/typeorm' +import { FindOperator, IsNull } from '@dbTools/typeorm' import ContributionArgs from '@arg/ContributionArgs' import Paginated from '@arg/Paginated' import { Order } from '@enum/Order' From 175bc514be7fea2f1737e4e6861c1fa7c5680e5b Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 15 Jul 2022 13:36:31 +0200 Subject: [PATCH 097/103] feat: Do not log IntrospectionQuery from Query Browser --- backend/src/server/plugins.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/src/server/plugins.ts b/backend/src/server/plugins.ts index 1972bc1c8..24df45baa 100644 --- a/backend/src/server/plugins.ts +++ b/backend/src/server/plugins.ts @@ -31,20 +31,24 @@ const filterVariables = (variables: any) => { const logPlugin = { requestDidStart(requestContext: any) { const { logger } = requestContext - const { query, mutation, variables } = requestContext.request - logger.info(`Request: + const { query, mutation, variables, operationName } = requestContext.request + if (operationName !== 'IntrospectionQuery') { + logger.info(`Request: ${mutation || query}variables: ${JSON.stringify(filterVariables(variables), null, 2)}`) + } return { willSendResponse(requestContext: any) { - if (requestContext.context.user) logger.info(`User ID: ${requestContext.context.user.id}`) - if (requestContext.response.data) { - logger.info('Response Success!') - logger.trace(`Response-Data: + if (operationName !== 'IntrospectionQuery') { + if (requestContext.context.user) logger.info(`User ID: ${requestContext.context.user.id}`) + if (requestContext.response.data) { + logger.info('Response Success!') + logger.trace(`Response-Data: ${JSON.stringify(requestContext.response.data, null, 2)}`) - } - if (requestContext.response.errors) - logger.error(`Response-Errors: + } + if (requestContext.response.errors) + logger.error(`Response-Errors: ${JSON.stringify(requestContext.response.errors, null, 2)}`) + } return requestContext }, } From d0662270431f112710c23748c72c6577c99eef3e Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 15 Jul 2022 14:13:33 +0200 Subject: [PATCH 098/103] Change the Contribution entity to join on user. --- .../0039-contributions_table/Contribution.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/database/entity/0039-contributions_table/Contribution.ts b/database/entity/0039-contributions_table/Contribution.ts index 6c7358f90..ee6e0f73f 100644 --- a/database/entity/0039-contributions_table/Contribution.ts +++ b/database/entity/0039-contributions_table/Contribution.ts @@ -1,6 +1,15 @@ import Decimal from 'decimal.js-light' -import { BaseEntity, Column, Entity, PrimaryGeneratedColumn, DeleteDateColumn } from 'typeorm' +import { + BaseEntity, + Column, + Entity, + PrimaryGeneratedColumn, + DeleteDateColumn, + OneToOne, + JoinColumn, +} from 'typeorm' import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' +import { User } from '../User' @Entity('contributions') export class Contribution extends BaseEntity { @@ -10,6 +19,10 @@ export class Contribution extends BaseEntity { @Column({ unsigned: true, nullable: false, name: 'user_id' }) userId: number + @OneToOne(() => User) + @JoinColumn({ name: 'user_id' }) + user: User + @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP', name: 'created_at' }) createdAt: Date From 5f5c19e6ba364ee036284fb47a197a6da3683832 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 15 Jul 2022 14:14:15 +0200 Subject: [PATCH 099/103] Change find to much more efficient code. --- .../graphql/resolver/ContributionResolver.ts | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 812e81527..d71ecac59 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -2,7 +2,6 @@ import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { Contribution as dbContribution } from '@entity/Contribution' -import { User as dbUser } from '@entity/User' import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' import { FindOperator, IsNull } from '@dbTools/typeorm' import ContributionArgs from '@arg/ContributionArgs' @@ -72,31 +71,20 @@ export class ContributionResolver { @Args() { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, ): Promise { - const dbContributions = await dbContribution.find({ + const [dbContributions, count] = await dbContribution.findAndCount({ + relations: ['user'], order: { createdAt: order, }, skip: (currentPage - 1) * pageSize, take: pageSize, }) - const contributions: Contribution[] = [] - const userIds: number[] = [] - dbContributions.forEach(async (dbContribution) => { - userIds.push(dbContribution.userId) - }) - userIds.filter((elem, index, self) => { - return index === self.indexOf(elem) - }) - const users = new Map() - for (let i = 0; i < userIds.length; i++) { - const id = userIds[i] - const user = await dbUser.findOneOrFail({ id }) - users.set(id, user) - } - dbContributions.forEach((dbContribution) => { - contributions.push(new Contribution(dbContribution, users.get(dbContribution.userId))) - }) - return new ContributionListResult(contributions.length, contributions) + return new ContributionListResult( + count, + dbContributions.map( + (contribution) => new Contribution(contribution, new User(contribution.user)), + ), + ) } @Authorized([RIGHTS.UPDATE_CONTRIBUTION]) From 382211f3ca12fa9585ef853751d886672997876e Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 15 Jul 2022 14:14:55 +0200 Subject: [PATCH 100/103] Adapt test so that we check findAllContributions. --- .../src/graphql/resolver/ContributionResolver.test.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 247d1be0e..fd5ff68a2 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -466,15 +466,14 @@ describe('ContributionResolver', () => { beforeAll(async () => { await userFactory(testEnv, bibiBloxberg) await userFactory(testEnv, peterLustig) - await userFactory(testEnv, raeuberHotzenplotz) - await userFactory(testEnv, bobBaumeister) + const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - creations.forEach(async (creation) => await creationFactory(testEnv, creation!)) + await creationFactory(testEnv, bibisCreation!) await query({ query: login, variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, }) - result = await mutate({ + await mutate({ mutation: createContribution, variables: { amount: 100.0, @@ -499,7 +498,7 @@ describe('ContributionResolver', () => { expect.objectContaining({ data: { listAllContributions: { - linkCount: 25, + linkCount: 2, linkList: expect.arrayContaining([ expect.objectContaining({ id: expect.any(Number), From cada4eca19cfa95b3ba7603838f2f163effb05ad Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 15 Jul 2022 14:32:20 +0200 Subject: [PATCH 101/103] Change OneToOne relation to OneToMany / ManyToOne. --- .../0039-contributions_table/Contribution.ts | 3 ++- .../0040-add_contribution_link_id_to_user/User.ts | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/database/entity/0039-contributions_table/Contribution.ts b/database/entity/0039-contributions_table/Contribution.ts index ee6e0f73f..5df527530 100644 --- a/database/entity/0039-contributions_table/Contribution.ts +++ b/database/entity/0039-contributions_table/Contribution.ts @@ -7,6 +7,7 @@ import { DeleteDateColumn, OneToOne, JoinColumn, + ManyToOne, } from 'typeorm' import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' import { User } from '../User' @@ -19,7 +20,7 @@ export class Contribution extends BaseEntity { @Column({ unsigned: true, nullable: false, name: 'user_id' }) userId: number - @OneToOne(() => User) + @ManyToOne(() => User, (user) => user.contributions) @JoinColumn({ name: 'user_id' }) user: User diff --git a/database/entity/0040-add_contribution_link_id_to_user/User.ts b/database/entity/0040-add_contribution_link_id_to_user/User.ts index 9bf76e5f5..56047345a 100644 --- a/database/entity/0040-add_contribution_link_id_to_user/User.ts +++ b/database/entity/0040-add_contribution_link_id_to_user/User.ts @@ -1,4 +1,13 @@ -import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } from 'typeorm' +import { + BaseEntity, + Entity, + PrimaryGeneratedColumn, + Column, + DeleteDateColumn, + OneToMany, + JoinColumn, +} from 'typeorm' +import { Contribution } from '../Contribution' @Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { @@ -76,4 +85,8 @@ export class User extends BaseEntity { default: null, }) passphrase: string + + @OneToMany(() => Contribution, (contribution) => contribution.user) + @JoinColumn({ name: 'user_id' }) + contributions?: Contribution[] } From 843993e34085397eb86b8e67477bf58e94debd6a Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 15 Jul 2022 14:34:47 +0200 Subject: [PATCH 102/103] Fix linting. --- backend/src/graphql/resolver/ContributionResolver.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index fd5ff68a2..e6478ffc2 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -14,8 +14,6 @@ import { userFactory } from '@/seeds/factory/user' import { creationFactory } from '@/seeds/factory/creation' import { creations } from '@/seeds/creation/index' import { peterLustig } from '@/seeds/users/peter-lustig' -import { bobBaumeister } from '@/seeds/users/bob-baumeister' -import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz' let mutate: any, query: any, con: any let testEnv: any From 5892f7b42947db8270fe4d26a4faed587abe68c3 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 15 Jul 2022 14:48:51 +0200 Subject: [PATCH 103/103] Remove OneToOne import from contribution entity. --- database/entity/0039-contributions_table/Contribution.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/database/entity/0039-contributions_table/Contribution.ts b/database/entity/0039-contributions_table/Contribution.ts index 5df527530..b5e6ac0e0 100644 --- a/database/entity/0039-contributions_table/Contribution.ts +++ b/database/entity/0039-contributions_table/Contribution.ts @@ -5,7 +5,6 @@ import { Entity, PrimaryGeneratedColumn, DeleteDateColumn, - OneToOne, JoinColumn, ManyToOne, } from 'typeorm'