From a9a3f5b55aff11ff43072f818398ff09f6f634df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 19 May 2022 17:09:40 +0200 Subject: [PATCH 01/51] Rename filters properties --- admin/src/pages/Creation.spec.js | 16 ++++++------- admin/src/pages/Creation.vue | 4 ++-- admin/src/pages/UserSearch.spec.js | 24 +++++++++---------- admin/src/pages/UserSearch.vue | 24 +++++++------------ backend/src/graphql/arg/SearchUsersFilters.ts | 4 ++-- .../src/graphql/arg/TransactionLinkFilters.ts | 6 ++--- .../graphql/resolver/AdminResolver.test.ts | 18 +++++++------- backend/src/graphql/resolver/AdminResolver.ts | 14 +++++------ 8 files changed, 52 insertions(+), 58 deletions(-) diff --git a/admin/src/pages/Creation.spec.js b/admin/src/pages/Creation.spec.js index 98c03d277..47a111215 100644 --- a/admin/src/pages/Creation.spec.js +++ b/admin/src/pages/Creation.spec.js @@ -71,8 +71,8 @@ describe('Creation', () => { searchText: '', currentPage: 1, pageSize: 25, - filterByActivated: true, - filterByDeleted: false, + byActivated: true, // Wolle: used 'filters' object? + byDeleted: false, }, }), ) @@ -271,8 +271,8 @@ describe('Creation', () => { searchText: 'XX', currentPage: 1, pageSize: 25, - filterByActivated: true, - filterByDeleted: false, + byActivated: true, // Wolle: used 'filters' object? + byDeleted: false, }, }), ) @@ -288,8 +288,8 @@ describe('Creation', () => { searchText: '', currentPage: 1, pageSize: 25, - filterByActivated: true, - filterByDeleted: false, + byActivated: true, // Wolle: used 'filters' object? + byDeleted: false, }, }), ) @@ -305,8 +305,8 @@ describe('Creation', () => { searchText: '', currentPage: 2, pageSize: 25, - filterByActivated: true, - filterByDeleted: false, + byActivated: true, // Wolle: used 'filters' object? + byDeleted: false, }, }), ) diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 54bc0d735..8d3f3edaa 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -102,8 +102,8 @@ export default { searchText: this.criteria, currentPage: this.currentPage, pageSize: this.perPage, - filterByActivated: true, - filterByDeleted: false, + byActivated: true, // Wolle: used 'filters' object? + byDeleted: false, }, fetchPolicy: 'network-only', }) diff --git a/admin/src/pages/UserSearch.spec.js b/admin/src/pages/UserSearch.spec.js index 1a23b4292..e990fd0ad 100644 --- a/admin/src/pages/UserSearch.spec.js +++ b/admin/src/pages/UserSearch.spec.js @@ -83,8 +83,8 @@ describe('UserSearch', () => { currentPage: 1, pageSize: 25, filters: { - filterByActivated: null, - filterByDeleted: null, + byActivated: null, + byDeleted: null, }, }, }), @@ -104,8 +104,8 @@ describe('UserSearch', () => { currentPage: 1, pageSize: 25, filters: { - filterByActivated: false, - filterByDeleted: null, + byActivated: false, + byDeleted: null, }, }, }), @@ -126,8 +126,8 @@ describe('UserSearch', () => { currentPage: 1, pageSize: 25, filters: { - filterByActivated: null, - filterByDeleted: true, + byActivated: null, + byDeleted: true, }, }, }), @@ -148,8 +148,8 @@ describe('UserSearch', () => { currentPage: 2, pageSize: 25, filters: { - filterByActivated: null, - filterByDeleted: null, + byActivated: null, + byDeleted: null, }, }, }), @@ -170,8 +170,8 @@ describe('UserSearch', () => { currentPage: 1, pageSize: 25, filters: { - filterByActivated: null, - filterByDeleted: null, + byActivated: null, + byDeleted: null, }, }, }), @@ -189,8 +189,8 @@ describe('UserSearch', () => { currentPage: 1, pageSize: 25, filters: { - filterByActivated: null, - filterByDeleted: null, + byActivated: null, + byDeleted: null, }, }, }), diff --git a/admin/src/pages/UserSearch.vue b/admin/src/pages/UserSearch.vue index 7b638c316..29ead3e25 100644 --- a/admin/src/pages/UserSearch.vue +++ b/admin/src/pages/UserSearch.vue @@ -4,22 +4,16 @@ {{ - filterByActivated === null + byActivated === null ? $t('all_emails') - : filterByActivated === false + : byActivated === false ? $t('unregistered_emails') : '' }} - {{ - filterByDeleted === null - ? $t('all_emails') - : filterByDeleted === true - ? $t('deleted_user') - : '' - }} + {{ byDeleted === null ? $t('all_emails') : byDeleted === true ? $t('deleted_user') : '' }} @@ -72,8 +66,8 @@ export default { searchResult: [], massCreation: [], criteria: '', - filterByActivated: null, - filterByDeleted: null, + byActivated: null, // Wolle: used 'filters' object? + byDeleted: null, rows: 0, currentPage: 1, perPage: 25, @@ -82,11 +76,11 @@ export default { }, methods: { unconfirmedRegisterMails() { - this.filterByActivated = this.filterByActivated === null ? false : null + this.byActivated = this.byActivated === null ? false : null this.getUsers() }, deletedUserSearch() { - this.filterByDeleted = this.filterByDeleted === null ? true : null + this.byDeleted = this.byDeleted === null ? true : null this.getUsers() }, getUsers() { @@ -98,8 +92,8 @@ export default { currentPage: this.currentPage, pageSize: this.perPage, filters: { - filterByActivated: this.filterByActivated, - filterByDeleted: this.filterByDeleted, + byActivated: this.byActivated, + byDeleted: this.byDeleted, }, }, fetchPolicy: 'no-cache', diff --git a/backend/src/graphql/arg/SearchUsersFilters.ts b/backend/src/graphql/arg/SearchUsersFilters.ts index de7c7c20a..8cc1426b3 100644 --- a/backend/src/graphql/arg/SearchUsersFilters.ts +++ b/backend/src/graphql/arg/SearchUsersFilters.ts @@ -4,8 +4,8 @@ import { Field, InputType, ObjectType } from 'type-graphql' @InputType('SearchUsersFiltersInput') export default class SearchUsersFilters { @Field(() => Boolean, { nullable: true, defaultValue: null }) - filterByActivated?: boolean | null + byActivated?: boolean | null @Field(() => Boolean, { nullable: true, defaultValue: null }) - filterByDeleted?: boolean | null + byDeleted?: boolean | null } diff --git a/backend/src/graphql/arg/TransactionLinkFilters.ts b/backend/src/graphql/arg/TransactionLinkFilters.ts index b009a3180..98c12703e 100644 --- a/backend/src/graphql/arg/TransactionLinkFilters.ts +++ b/backend/src/graphql/arg/TransactionLinkFilters.ts @@ -3,11 +3,11 @@ import { ArgsType, Field } from 'type-graphql' @ArgsType() export default class TransactionLinkFilters { @Field(() => Boolean, { nullable: true, defaultValue: true }) - filterByDeleted?: boolean + byDeleted?: boolean @Field(() => Boolean, { nullable: true, defaultValue: true }) - filterByExpired?: boolean + byExpired?: boolean @Field(() => Boolean, { nullable: true, defaultValue: true }) - filterByRedeemed?: boolean + byRedeemed?: boolean } diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 1df80aa1a..b4a4f0d46 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -373,15 +373,15 @@ describe('AdminResolver', () => { ) }) - it('all users by "filterByActivated === null && filterByDeleted === null"', async () => { + it('all users by "byActivated === null && byDeleted === null"', async () => { await expect( query({ query: searchUsers, variables: { ...variablesWithoutTextAndFilters, filters: { - filterByActivated: null, - filterByDeleted: null, + byActivated: null, + byDeleted: null, }, }, }), @@ -404,8 +404,8 @@ describe('AdminResolver', () => { variables: { ...variablesWithoutTextAndFilters, filters: { - filterByActivated: false, - filterByDeleted: null, + byActivated: false, + byDeleted: null, }, }, }), @@ -428,8 +428,8 @@ describe('AdminResolver', () => { variables: { ...variablesWithoutTextAndFilters, filters: { - filterByActivated: null, - filterByDeleted: true, + byActivated: null, + byDeleted: true, }, }, }), @@ -452,8 +452,8 @@ describe('AdminResolver', () => { variables: { ...variablesWithoutTextAndFilters, filters: { - filterByActivated: false, - filterByDeleted: true, + byActivated: false, + byDeleted: true, }, }, }), diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index fe4075cd1..0cf57ac53 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -57,12 +57,12 @@ export class AdminResolver { const userRepository = getCustomRepository(UserRepository) const filterCriteria: ObjectLiteral[] = [] - if (filters && filters.filterByActivated !== null) { - filterCriteria.push({ emailChecked: filters.filterByActivated }) + if (filters && filters.byActivated !== null) { + filterCriteria.push({ emailChecked: filters.byActivated }) } - if (filters && filters.filterByDeleted !== null) { - filterCriteria.push({ deletedAt: filters.filterByDeleted ? Not(IsNull()) : IsNull() }) + if (filters && filters.byDeleted !== null) { + filterCriteria.push({ deletedAt: filters.byDeleted ? Not(IsNull()) : IsNull() }) } const userFields = ['id', 'firstName', 'lastName', 'email', 'emailChecked', 'deletedAt'] @@ -436,11 +436,11 @@ export class AdminResolver { } = { userId, } - if (!filters.filterByRedeemed) where.redeemedBy = null - if (!filters.filterByExpired) where.validUntil = MoreThan(new Date()) + if (!filters.byRedeemed) where.redeemedBy = null + if (!filters.byExpired) where.validUntil = MoreThan(new Date()) const [transactionLinks, count] = await dbTransactionLink.findAndCount({ where, - withDeleted: filters.filterByDeleted, + withDeleted: filters.byDeleted, order: { createdAt: order, }, From 36ed5e5d5af6d6e04fe72cfbd23022a9d06cf132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 19 May 2022 18:48:01 +0200 Subject: [PATCH 02/51] Refactor to use filters object in UserSearch.vue --- admin/src/pages/UserSearch.vue | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/admin/src/pages/UserSearch.vue b/admin/src/pages/UserSearch.vue index 29ead3e25..f1ca31d14 100644 --- a/admin/src/pages/UserSearch.vue +++ b/admin/src/pages/UserSearch.vue @@ -4,16 +4,22 @@ {{ - byActivated === null + filters.byActivated === null ? $t('all_emails') - : byActivated === false + : filters.byActivated === false ? $t('unregistered_emails') : '' }} - {{ byDeleted === null ? $t('all_emails') : byDeleted === true ? $t('deleted_user') : '' }} + {{ + filters.byDeleted === null + ? $t('all_emails') + : filters.byDeleted === true + ? $t('deleted_user') + : '' + }} @@ -66,8 +72,10 @@ export default { searchResult: [], massCreation: [], criteria: '', - byActivated: null, // Wolle: used 'filters' object? - byDeleted: null, + filters: { + byActivated: null, + byDeleted: null, + }, rows: 0, currentPage: 1, perPage: 25, @@ -76,11 +84,11 @@ export default { }, methods: { unconfirmedRegisterMails() { - this.byActivated = this.byActivated === null ? false : null + this.filters.byActivated = this.filters.byActivated === null ? false : null this.getUsers() }, deletedUserSearch() { - this.byDeleted = this.byDeleted === null ? true : null + this.filters.byDeleted = this.filters.byDeleted === null ? true : null this.getUsers() }, getUsers() { @@ -91,10 +99,7 @@ export default { searchText: this.criteria, currentPage: this.currentPage, pageSize: this.perPage, - filters: { - byActivated: this.byActivated, - byDeleted: this.byDeleted, - }, + filters: this.filters, }, fetchPolicy: 'no-cache', }) From 14ea920a248f4f1e7d3d1d5e2b99584e0d23661f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 23 May 2022 06:57:43 +0200 Subject: [PATCH 03/51] Remove ObjectType from SearchUsersFilters and rename SearchUsersFiltersInput to the same name --- admin/src/graphql/searchUsers.js | 7 +------ backend/src/graphql/arg/SearchUsersFilters.ts | 5 ++--- backend/src/seeds/graphql/mutations.ts | 7 +------ 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/admin/src/graphql/searchUsers.js b/admin/src/graphql/searchUsers.js index 5740e24cc..cc7f83b1c 100644 --- a/admin/src/graphql/searchUsers.js +++ b/admin/src/graphql/searchUsers.js @@ -1,12 +1,7 @@ import gql from 'graphql-tag' export const searchUsers = gql` - query ( - $searchText: String! - $currentPage: Int - $pageSize: Int - $filters: SearchUsersFiltersInput - ) { + query ($searchText: String!, $currentPage: Int, $pageSize: Int, $filters: SearchUsersFilters) { searchUsers( searchText: $searchText currentPage: $currentPage diff --git a/backend/src/graphql/arg/SearchUsersFilters.ts b/backend/src/graphql/arg/SearchUsersFilters.ts index 8cc1426b3..efcdfa00d 100644 --- a/backend/src/graphql/arg/SearchUsersFilters.ts +++ b/backend/src/graphql/arg/SearchUsersFilters.ts @@ -1,7 +1,6 @@ -import { Field, InputType, ObjectType } from 'type-graphql' +import { Field, InputType } from 'type-graphql' -@ObjectType() -@InputType('SearchUsersFiltersInput') +@InputType() export default class SearchUsersFilters { @Field(() => Boolean, { nullable: true, defaultValue: null }) byActivated?: boolean | null diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 4598cbbe2..982de3bcc 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -108,12 +108,7 @@ export const unDeleteUser = gql` ` export const searchUsers = gql` - query ( - $searchText: String! - $currentPage: Int - $pageSize: Int - $filters: SearchUsersFiltersInput - ) { + query ($searchText: String!, $currentPage: Int, $pageSize: Int, $filters: SearchUsersFilters) { searchUsers( searchText: $searchText currentPage: $currentPage From 35b47844b715dd2d6e8dbd272b5da9da4367a642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 23 May 2022 07:02:32 +0200 Subject: [PATCH 04/51] Rename convertObjValuesToArray to objectValuesToArray --- backend/src/graphql/resolver/AdminResolver.test.ts | 6 +++--- backend/src/util/utilities.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 9181943d0..40949810e 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { convertObjValuesToArray } from '@/util/utilities' +import { objectValuesToArray } from '@/util/utilities' import { testEnvironment, resetToken, cleanDB } from '@test/helpers' import { userFactory } from '@/seeds/factory/user' import { creationFactory } from '@/seeds/factory/creation' @@ -366,7 +366,7 @@ describe('AdminResolver', () => { data: { searchUsers: { userCount: 4, - userList: expect.arrayContaining(convertObjValuesToArray(allUsers)), + userList: expect.arrayContaining(objectValuesToArray(allUsers)), }, }, }), @@ -392,7 +392,7 @@ describe('AdminResolver', () => { data: { searchUsers: { userCount: 4, - userList: expect.arrayContaining(convertObjValuesToArray(allUsers)), + userList: expect.arrayContaining(objectValuesToArray(allUsers)), }, }, }), diff --git a/backend/src/util/utilities.ts b/backend/src/util/utilities.ts index f77ad05ec..9abb31554 100644 --- a/backend/src/util/utilities.ts +++ b/backend/src/util/utilities.ts @@ -1,4 +1,4 @@ -export const convertObjValuesToArray = (obj: { [x: string]: string }): Array => { +export const objectValuesToArray = (obj: { [x: string]: string }): Array => { return Object.keys(obj).map(function (key) { return obj[key] }) From 85eaa4b391f12bee993ab4a3c4831c1cfd2fe205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 23 May 2022 11:23:56 +0200 Subject: [PATCH 05/51] Refactor to use filters in query listTransactionLinksAdmin --- backend/src/graphql/arg/SearchUsersFilters.ts | 4 +-- .../src/graphql/arg/TransactionLinkFilters.ts | 10 +++---- backend/src/graphql/resolver/AdminResolver.ts | 2 +- backend/src/seeds/graphql/mutations.ts | 29 +++++++++++++++++++ 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/backend/src/graphql/arg/SearchUsersFilters.ts b/backend/src/graphql/arg/SearchUsersFilters.ts index efcdfa00d..dc19d456c 100644 --- a/backend/src/graphql/arg/SearchUsersFilters.ts +++ b/backend/src/graphql/arg/SearchUsersFilters.ts @@ -3,8 +3,8 @@ import { Field, InputType } from 'type-graphql' @InputType() export default class SearchUsersFilters { @Field(() => Boolean, { nullable: true, defaultValue: null }) - byActivated?: boolean | null + byActivated: boolean @Field(() => Boolean, { nullable: true, defaultValue: null }) - byDeleted?: boolean | null + byDeleted: boolean } diff --git a/backend/src/graphql/arg/TransactionLinkFilters.ts b/backend/src/graphql/arg/TransactionLinkFilters.ts index 98c12703e..0fdd5c7c6 100644 --- a/backend/src/graphql/arg/TransactionLinkFilters.ts +++ b/backend/src/graphql/arg/TransactionLinkFilters.ts @@ -1,13 +1,13 @@ -import { ArgsType, Field } from 'type-graphql' +import { Field, InputType } from 'type-graphql' -@ArgsType() +@InputType() export default class TransactionLinkFilters { @Field(() => Boolean, { nullable: true, defaultValue: true }) - byDeleted?: boolean + byDeleted: boolean @Field(() => Boolean, { nullable: true, defaultValue: true }) - byExpired?: boolean + byExpired: boolean @Field(() => Boolean, { nullable: true, defaultValue: true }) - byRedeemed?: boolean + byRedeemed: boolean } diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 4aec5ca67..7aa5cd079 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -426,7 +426,7 @@ export class AdminResolver { async listTransactionLinksAdmin( @Args() { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, - @Args() + @Arg('filters') filters: TransactionLinkFilters, @Arg('userId', () => Int) userId: number, ): Promise { diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 982de3bcc..07bc46b03 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -163,3 +163,32 @@ export const deletePendingCreation = gql` deletePendingCreation(id: $id) } ` + +export const listTransactionLinksAdmin = gql` + query ( + $userId: Int! + $filters: TransactionLinkFilters! + $currentPage: Int = 1 + $pageSize: Int = 5 + ) { + listTransactionLinksAdmin( + userId: $userId + filters: $filters + currentPage: $currentPage + pageSize: $pageSize + ) { + linkCount + linkList { + id + amount + holdAvailableAmount + memo + code + createdAt + validUntil + redeemedAt + deletedAt + } + } + } +` From 311aa023e47cb50b0cc49d85c4e3c1f7d47a53e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 23 May 2022 12:45:31 +0200 Subject: [PATCH 06/51] Test listTransactionLinksAdmin resolver, a start --- .../graphql/resolver/AdminResolver.test.ts | 244 ++++++++++++++++++ backend/src/graphql/resolver/AdminResolver.ts | 2 + 2 files changed, 246 insertions(+) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 40949810e..149fc2bcb 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -5,6 +5,9 @@ import { objectValuesToArray } from '@/util/utilities' import { testEnvironment, resetToken, cleanDB } from '@test/helpers' import { userFactory } from '@/seeds/factory/user' import { creationFactory } from '@/seeds/factory/creation' +import { creations } from '@/seeds/creation/index' +import { transactionLinkFactory } from '@/seeds/factory/transactionLink' +import { transactionLinks } from '@/seeds/transactionLink/index' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' import { stephenHawking } from '@/seeds/users/stephen-hawking' @@ -18,6 +21,7 @@ import { updatePendingCreation, deletePendingCreation, confirmPendingCreation, + listTransactionLinksAdmin, } from '@/seeds/graphql/mutations' import { getPendingCreations, login } from '@/seeds/graphql/queries' import { GraphQLError } from 'graphql' @@ -1324,4 +1328,244 @@ describe('AdminResolver', () => { }) }) }) + + describe('transaction links list', () => { + const variables = { + userId: 1, // dummy, may be replaced + filters: { + byDeleted: null, + byExpired: null, + byRedeemed: null, + }, + currentPage: 1, + pageSize: 5, + } + + describe('unauthenticated', () => { + it('returns an error', async () => { + await expect( + query({ + query: listTransactionLinksAdmin, + variables, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) + + describe('authenticated', () => { + describe('without admin rights', () => { + beforeAll(async () => { + user = await userFactory(testEnv, bibiBloxberg) + await query({ + query: login, + variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, + }) + }) + + afterAll(async () => { + await cleanDB() + resetToken() + }) + + it('returns an error', async () => { + await expect( + query({ + query: listTransactionLinksAdmin, + variables, + }), + ).resolves.toEqual( + expect.objectContaining({ + errors: [new GraphQLError('401 Unauthorized')], + }), + ) + }) + }) + + describe('with admin rights', () => { + const expectNoDeletedOrRedeemed = expect.objectContaining({ + data: { + listTransactionLinksAdmin: { + linkCount: 6, + linkList: expect.not.arrayContaining([ + expect.objectContaining({ + memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', + createdAt: new Date(2022, 0, 1), + }), + expect.objectContaining({ + memo: 'Da habe ich mich wohl etwas übernommen.', + deletedAt: true, + }), + ]), + }, + }, + }) + + beforeAll(async () => { + // admin 'peter@lustig.de' has to exists for 'creationFactory' + admin = await userFactory(testEnv, peterLustig) + + user = await userFactory(testEnv, bibiBloxberg) + variables.userId = user.id + // bibi need 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!) + // bibis transaktion links + const bibisTransaktionLinks = transactionLinks.filter( + (transactionLink) => transactionLink.email === 'bibi@bloxberg.de', + ) + for (let i = 0; i < bibisTransaktionLinks.length; i++) { + await transactionLinkFactory(testEnv, bibisTransaktionLinks[i]) + } + + // admin: only now log in + await query({ + query: login, + variables: { email: 'peter@lustig.de', password: 'Aa12345_' }, + }) + }) + + afterAll(async () => { + await cleanDB() + resetToken() + }) + + // Wolle: make filters object nullable + describe.skip('without any filters', () => { + it('finds 6 open transaction links and no deleted or redeemed', async () => { + await expect( + query({ + query: listTransactionLinksAdmin, + variables, + }), + ).resolves.toEqual(expectNoDeletedOrRedeemed) + }) + }) + + describe('all filters are null', () => { + it('finds 6 open transaction links and no deleted or redeemed', async () => { + await expect( + query({ + query: listTransactionLinksAdmin, + variables, + }), + ).resolves.toEqual(expectNoDeletedOrRedeemed) + }) + }) + + describe('filter by deleted', () => { + it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { + await expect( + query({ + query: listTransactionLinksAdmin, + variables: { + ...variables, + filters: { + byDeleted: true, // Wolle: rename to `withDeleted`? + byExpired: null, + byRedeemed: null, + }, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listTransactionLinksAdmin: { + linkCount: 7, + linkList: expect.arrayContaining([ + expect.not.objectContaining({ + memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', + // Wolle: createdAt: new Date(2022, 0, 1), + }), + expect.objectContaining({ + memo: 'Da habe ich mich wohl etwas übernommen.', + // Wolle: deletedAt: expect.any(String), + }), + ]), + }, + }, + }), + ) + }) + }) + + // Wolle: works not as expected, because of wrong 'linkCount' at least + describe.skip('filter by expired', () => { + it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { + await expect( + query({ + query: listTransactionLinksAdmin, + variables: { + ...variables, + filters: { + byDeleted: null, + byExpired: true, + byRedeemed: null, + }, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listTransactionLinksAdmin: { + linkCount: 7, // Wolle: finds 5 but counts 7 + linkList: expect.arrayContaining([ + expect.objectContaining({ + memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', + // Wolle: createdAt: new Date(2022, 0, 1), + }), + expect.not.objectContaining({ + memo: 'Da habe ich mich wohl etwas übernommen.', + // Wolle: deletedAt: expect.any(String), + }), + ]), + }, + }, + }), + ) + }) + + // Wolle: not done jet + describe.skip('filter by redeemed', () => { + it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { + await expect( + query({ + query: listTransactionLinksAdmin, + variables: { + ...variables, + filters: { + byDeleted: null, + byExpired: null, + byRedeemed: true, + }, + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listTransactionLinksAdmin: { + linkCount: 7, // Wolle: finds 5 but counts 7 + linkList: expect.arrayContaining([ + expect.objectContaining({ + memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', + // Wolle: createdAt: new Date(2022, 0, 1), + }), + expect.not.objectContaining({ + memo: 'Da habe ich mich wohl etwas übernommen.', + // Wolle: deletedAt: expect.any(String), + }), + ]), + }, + }, + }), + ) + }) + }) + }) + }) + }) }) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 7aa5cd079..8576d25cb 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -442,7 +442,9 @@ export class AdminResolver { if (!filters.byExpired) where.validUntil = MoreThan(new Date()) const [transactionLinks, count] = await dbTransactionLink.findAndCount({ where, + // Wolle: works not as expected withDeleted: filters.byDeleted, + // withDeleted: filters.byDeleted !== undefined ? !filters.byDeleted : undefined, order: { createdAt: order, }, From b9790dea708930e00852680d12db33b172ca4945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 23 May 2022 12:49:45 +0200 Subject: [PATCH 07/51] Fix an error --- backend/src/graphql/resolver/AdminResolver.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 149fc2bcb..cccf23529 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1528,6 +1528,7 @@ describe('AdminResolver', () => { }), ) }) + }) // Wolle: not done jet describe.skip('filter by redeemed', () => { From befe4f7448efc784b03c0dd24e00d930261fbed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 23 May 2022 13:15:50 +0200 Subject: [PATCH 08/51] Adjust backend test minimum to 68% --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bb2441701..b7000100e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -528,7 +528,7 @@ jobs: report_name: Coverage Backend type: lcov result_path: ./backend/coverage/lcov.info - min_coverage: 66 + min_coverage: 68 token: ${{ github.token }} ########################################################################## From cba20e84901070d96b2c61e433ea994aa89a8f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 24 May 2022 10:15:18 +0200 Subject: [PATCH 09/51] Rename TransactionLinkFilters fields from by* back to with* --- .../src/graphql/arg/TransactionLinkFilters.ts | 6 ++--- .../graphql/resolver/AdminResolver.test.ts | 24 +++++++++---------- backend/src/graphql/resolver/AdminResolver.ts | 8 +++---- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/backend/src/graphql/arg/TransactionLinkFilters.ts b/backend/src/graphql/arg/TransactionLinkFilters.ts index 0fdd5c7c6..a335f6a28 100644 --- a/backend/src/graphql/arg/TransactionLinkFilters.ts +++ b/backend/src/graphql/arg/TransactionLinkFilters.ts @@ -3,11 +3,11 @@ import { Field, InputType } from 'type-graphql' @InputType() export default class TransactionLinkFilters { @Field(() => Boolean, { nullable: true, defaultValue: true }) - byDeleted: boolean + withDeleted: boolean @Field(() => Boolean, { nullable: true, defaultValue: true }) - byExpired: boolean + withExpired: boolean @Field(() => Boolean, { nullable: true, defaultValue: true }) - byRedeemed: boolean + withRedeemed: boolean } diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index cccf23529..529d99751 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1333,9 +1333,9 @@ describe('AdminResolver', () => { const variables = { userId: 1, // dummy, may be replaced filters: { - byDeleted: null, - byExpired: null, - byRedeemed: null, + withDeleted: null, + withExpired: null, + withRedeemed: null, }, currentPage: 1, pageSize: 5, @@ -1465,9 +1465,9 @@ describe('AdminResolver', () => { variables: { ...variables, filters: { - byDeleted: true, // Wolle: rename to `withDeleted`? - byExpired: null, - byRedeemed: null, + withDeleted: true, // Wolle: rename to `withDeleted`? + withExpired: null, + withRedeemed: null, }, }, }), @@ -1502,9 +1502,9 @@ describe('AdminResolver', () => { variables: { ...variables, filters: { - byDeleted: null, - byExpired: true, - byRedeemed: null, + withDeleted: null, + withExpired: true, + withRedeemed: null, }, }, }), @@ -1539,9 +1539,9 @@ describe('AdminResolver', () => { variables: { ...variables, filters: { - byDeleted: null, - byExpired: null, - byRedeemed: true, + withDeleted: null, + withExpired: null, + withRedeemed: true, }, }, }), diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 8576d25cb..012bdde30 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -438,13 +438,11 @@ export class AdminResolver { } = { userId, } - if (!filters.byRedeemed) where.redeemedBy = null - if (!filters.byExpired) where.validUntil = MoreThan(new Date()) + if (!filters.withRedeemed) where.redeemedBy = null + if (!filters.withExpired) where.validUntil = MoreThan(new Date()) const [transactionLinks, count] = await dbTransactionLink.findAndCount({ where, - // Wolle: works not as expected - withDeleted: filters.byDeleted, - // withDeleted: filters.byDeleted !== undefined ? !filters.byDeleted : undefined, + withDeleted: filters.withDeleted, order: { createdAt: order, }, From f064575864908f3528798c582073712d6f58bb55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 25 May 2022 09:31:41 +0200 Subject: [PATCH 10/51] Refine tests in AdminResolver.test.ts --- .../graphql/resolver/AdminResolver.test.ts | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 529d99751..37250acf2 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1393,11 +1393,11 @@ describe('AdminResolver', () => { linkList: expect.not.arrayContaining([ expect.objectContaining({ memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', - createdAt: new Date(2022, 0, 1), + createdAt: expect.any(String), }), expect.objectContaining({ memo: 'Da habe ich mich wohl etwas übernommen.', - deletedAt: true, + deletedAt: expect.any(String), }), ]), }, @@ -1410,7 +1410,7 @@ describe('AdminResolver', () => { user = await userFactory(testEnv, bibiBloxberg) variables.userId = user.id - // bibi need GDDs + // 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!) @@ -1434,13 +1434,13 @@ describe('AdminResolver', () => { resetToken() }) - // Wolle: make filters object nullable + // Todo: make filters argument nullable? describe.skip('without any filters', () => { it('finds 6 open transaction links and no deleted or redeemed', async () => { await expect( query({ query: listTransactionLinksAdmin, - variables, + variables: { ...variables, filters: null }, }), ).resolves.toEqual(expectNoDeletedOrRedeemed) }) @@ -1457,7 +1457,7 @@ describe('AdminResolver', () => { }) }) - describe('filter by deleted', () => { + describe('filter with deleted', () => { it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { await expect( query({ @@ -1465,7 +1465,7 @@ describe('AdminResolver', () => { variables: { ...variables, filters: { - withDeleted: true, // Wolle: rename to `withDeleted`? + withDeleted: true, withExpired: null, withRedeemed: null, }, @@ -1479,11 +1479,11 @@ describe('AdminResolver', () => { linkList: expect.arrayContaining([ expect.not.objectContaining({ memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', - // Wolle: createdAt: new Date(2022, 0, 1), + createdAt: expect.any(String), }), expect.objectContaining({ memo: 'Da habe ich mich wohl etwas übernommen.', - // Wolle: deletedAt: expect.any(String), + deletedAt: expect.any(String), }), ]), }, @@ -1512,15 +1512,15 @@ describe('AdminResolver', () => { expect.objectContaining({ data: { listTransactionLinksAdmin: { - linkCount: 7, // Wolle: finds 5 but counts 7 + linkCount: 7, linkList: expect.arrayContaining([ expect.objectContaining({ memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', - // Wolle: createdAt: new Date(2022, 0, 1), + createdAt: expect.any(String), }), expect.not.objectContaining({ memo: 'Da habe ich mich wohl etwas übernommen.', - // Wolle: deletedAt: expect.any(String), + deletedAt: expect.any(String), }), ]), }, From 84c0c6f10b7cc07083f6b4ea439035257a28f68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 26 May 2022 02:56:38 +0200 Subject: [PATCH 11/51] start creating contributionLinks table --- .../ContributionLinks.ts | 108 ++++++++++++++++++ database/entity/ContributionLinks.ts | 1 + 2 files changed, 109 insertions(+) create mode 100644 database/entity/0038-add_contribution_links_table/ContributionLinks.ts create mode 100644 database/entity/ContributionLinks.ts diff --git a/database/entity/0038-add_contribution_links_table/ContributionLinks.ts b/database/entity/0038-add_contribution_links_table/ContributionLinks.ts new file mode 100644 index 000000000..5f78a7450 --- /dev/null +++ b/database/entity/0038-add_contribution_links_table/ContributionLinks.ts @@ -0,0 +1,108 @@ +import Decimal from 'decimal.js-light' +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm' +import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' + +export enum CycleTypes { + ONCE = 1, + HOUR = 2, + TWOHOURS = 3, + FOURHOURS = 4, + EIGHTHOURS = 5, + HALFDAY = 6, + DAY = 7, + TWODAYS = 8, + THREEDAYS = 9, + FOURDAYS = 10, + FIVEDAYS = 11, + SIXDAYS = 12, + WEEK = 13, + TWOWEEKS = 14, + MONTH = 15, + TWOMONTH = 16, + QUARTER = 17, + HALFYEAR = 18, + YEAR = 19, +} + +@Entity('contribution_links') +export class ContributionLinks extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ length: 100, nullable: false, collation: 'utf8mb4_unicode_ci' }) + name: string + + @Column({ length: 255, nullable: false, collation: 'utf8mb4_unicode_ci' }) + description: string + + @Column({ name: 'valid_from', type: 'datetime', nullable: true, default: null }) + validFrom: Date | null + + @Column({ name: 'valid_to', type: 'datetime', nullable: true, default: null }) + validTo: Date | null + + @Column({ + type: 'decimal', + precision: 40, + scale: 20, + nullable: false, + transformer: DecimalTransformer, + }) + amount: Decimal + + @Column({ name: 'cycle', unsigned: true, nullable: false }) + cycle: number + + @Column({ name: 'max_per_cycle', unsigned: true, nullable: false, default: 1 }) + maxPerCycle: number + + @Column({ + name: 'max_amount_per_month', + type: 'decimal', + precision: 40, + scale: 20, + nullable: true, + default: null, + transformer: DecimalTransformer, + }) + maxAmountPerMonth: Decimal + + @Column({ + name: 'total_max_count_of_contribution', + unsigned: true, + nullable: true, + default: null, + }) + totalMaxCountOfContribution: number | null + + @Column({ + name: 'max_account_balance', + type: 'decimal', + precision: 40, + scale: 20, + nullable: true, + default: null, + transformer: DecimalTransformer, + }) + maxAccountBalance: Decimal + + @Column({ + name: 'min_gap_hours', + unsigned: true, + nullable: true, + default: null, + }) + minGapHours: number | null + + @Column({ name: 'created_at', type: 'datetime', nullable: true, default: null }) + createdAt: Date | null + + @Column({ name: 'deleted_at', type: 'datetime', nullable: true, default: null }) + deletedAt: Date | null + + @Column({ length: 24, nullable: false, collation: 'utf8mb4_unicode_ci' }) + code: string + + @Column({ name: 'link_enabled', type: 'boolean', nullable: true, default: null }) + linkEnabled: boolean | null +} diff --git a/database/entity/ContributionLinks.ts b/database/entity/ContributionLinks.ts new file mode 100644 index 000000000..721dfd2b3 --- /dev/null +++ b/database/entity/ContributionLinks.ts @@ -0,0 +1 @@ +export { ContributionLinks } from './0038-add_contribution_links_table/ContributionLinks' From cabb844c2c8f4ddc4654b1e4e2bbd527e0ab2f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 31 May 2022 10:43:15 +0200 Subject: [PATCH 12/51] Fix creation date for transaction links for seeding - Add some commented code for future testing of 'withRedeemed', 'withExpired'. --- .../src/graphql/resolver/AdminResolver.test.ts | 17 +++++++++++------ .../transactionLink/TransactionLinkInterface.ts | 3 +++ backend/src/seeds/transactionLink/index.ts | 6 +++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 37250acf2..c923e46ad 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1493,7 +1493,7 @@ describe('AdminResolver', () => { }) }) - // Wolle: works not as expected, because of wrong 'linkCount' at least + // TODO: works not as expected, because the expired link is not in the result eventhogh a link has 'createdAt' at the very first of 2022 and should be expired describe.skip('filter by expired', () => { it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { await expect( @@ -1530,7 +1530,7 @@ describe('AdminResolver', () => { }) }) - // Wolle: not done jet + // TODO: works not as expected, because 'redeemedAt' and 'redeemedBy' have to be added to the transaktion link factory describe.skip('filter by redeemed', () => { it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { await expect( @@ -1549,15 +1549,20 @@ describe('AdminResolver', () => { expect.objectContaining({ data: { listTransactionLinksAdmin: { - linkCount: 7, // Wolle: finds 5 but counts 7 + linkCount: 6, linkList: expect.arrayContaining([ - expect.objectContaining({ + expect.not.objectContaining({ memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', - // Wolle: createdAt: new Date(2022, 0, 1), + createdAt: expect.any(String), + }), + expect.objectContaining({ + memo: 'Yeah, eingelöst!', + redeemedAt: expect.any(String), + redeemedBy: expect.any(Number), }), expect.not.objectContaining({ memo: 'Da habe ich mich wohl etwas übernommen.', - // Wolle: deletedAt: expect.any(String), + deletedAt: expect.any(String), }), ]), }, diff --git a/backend/src/seeds/transactionLink/TransactionLinkInterface.ts b/backend/src/seeds/transactionLink/TransactionLinkInterface.ts index ddc835b33..eaacfdf92 100644 --- a/backend/src/seeds/transactionLink/TransactionLinkInterface.ts +++ b/backend/src/seeds/transactionLink/TransactionLinkInterface.ts @@ -3,5 +3,8 @@ export interface TransactionLinkInterface { amount: number memo: string createdAt?: Date + // TODO: for testing + // redeemedAt?: Date + // redeemedBy?: number deletedAt?: boolean } diff --git a/backend/src/seeds/transactionLink/index.ts b/backend/src/seeds/transactionLink/index.ts index 25755c0f2..1db3d4828 100644 --- a/backend/src/seeds/transactionLink/index.ts +++ b/backend/src/seeds/transactionLink/index.ts @@ -5,7 +5,7 @@ export const transactionLinks: TransactionLinkInterface[] = [ email: 'bibi@bloxberg.de', amount: 19.99, memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', - createdAt: new Date(2022, 0, 1), + createdAt: new Date(2022, 1, 1), }, { email: 'bibi@bloxberg.de', @@ -30,6 +30,10 @@ bei Gradidio sei dabei!`, amount: 19.99, memo: `Kein Trick, keine Zauberrei, bei Gradidio sei dabei!`, + // TODO: for testing + // memo: `Yeah, eingelöst!`, + // redeemedAt: new Date(2022, 2, 2), + // redeemedBy: not null, }, { email: 'bibi@bloxberg.de', From 514a38ea3868140ab87210ce4692ec122f5235bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 31 May 2022 11:00:56 +0200 Subject: [PATCH 13/51] Make transaction link filter object nullable --- backend/src/graphql/arg/SearchUsersArgs.ts | 2 +- .../graphql/resolver/AdminResolver.test.ts | 20 ++++++++++--------- backend/src/graphql/resolver/AdminResolver.ts | 11 +++++----- backend/src/seeds/graphql/mutations.ts | 2 +- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/backend/src/graphql/arg/SearchUsersArgs.ts b/backend/src/graphql/arg/SearchUsersArgs.ts index 8db6bfc06..38057762d 100644 --- a/backend/src/graphql/arg/SearchUsersArgs.ts +++ b/backend/src/graphql/arg/SearchUsersArgs.ts @@ -12,6 +12,6 @@ export default class SearchUsersArgs { @Field(() => Int, { nullable: true }) pageSize?: number - @Field(() => SearchUsersFilters, { nullable: true }) + @Field(() => SearchUsersFilters, { nullable: true, defaultValue: null }) filters: SearchUsersFilters } diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index c923e46ad..3b5908908 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1332,11 +1332,7 @@ describe('AdminResolver', () => { describe('transaction links list', () => { const variables = { userId: 1, // dummy, may be replaced - filters: { - withDeleted: null, - withExpired: null, - withRedeemed: null, - }, + filters: null, currentPage: 1, pageSize: 5, } @@ -1434,13 +1430,12 @@ describe('AdminResolver', () => { resetToken() }) - // Todo: make filters argument nullable? - describe.skip('without any filters', () => { + describe('without any filters', () => { it('finds 6 open transaction links and no deleted or redeemed', async () => { await expect( query({ query: listTransactionLinksAdmin, - variables: { ...variables, filters: null }, + variables, }), ).resolves.toEqual(expectNoDeletedOrRedeemed) }) @@ -1451,7 +1446,14 @@ describe('AdminResolver', () => { await expect( query({ query: listTransactionLinksAdmin, - variables, + variables: { + ...variables, + filters: { + withDeleted: null, + withExpired: null, + withRedeemed: null, + }, + }, }), ).resolves.toEqual(expectNoDeletedOrRedeemed) }) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 012bdde30..54207b17c 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -426,9 +426,10 @@ export class AdminResolver { async listTransactionLinksAdmin( @Args() { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, - @Arg('filters') + @Arg('filters', () => TransactionLinkFilters, { nullable: true, defaultValue: null }) filters: TransactionLinkFilters, - @Arg('userId', () => Int) userId: number, + @Arg('userId', () => Int) + userId: number, ): Promise { const user = await dbUser.findOneOrFail({ id: userId }) const where: { @@ -438,11 +439,11 @@ export class AdminResolver { } = { userId, } - if (!filters.withRedeemed) where.redeemedBy = null - if (!filters.withExpired) where.validUntil = MoreThan(new Date()) + if (!filters || !filters.withRedeemed) where.redeemedBy = null + if (!filters || !filters.withExpired) where.validUntil = MoreThan(new Date()) const [transactionLinks, count] = await dbTransactionLink.findAndCount({ where, - withDeleted: filters.withDeleted, + withDeleted: !filters ? false : filters.withDeleted, order: { createdAt: order, }, diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 269901e94..d5dc99b99 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -165,7 +165,7 @@ export const deletePendingCreation = gql` export const listTransactionLinksAdmin = gql` query ( $userId: Int! - $filters: TransactionLinkFilters! + $filters: TransactionLinkFilters $currentPage: Int = 1 $pageSize: Int = 5 ) { From 2444c94af9f6d3869e65721317ffd58a29a408a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 1 Jun 2022 01:19:44 +0200 Subject: [PATCH 14/51] create migration and entity for new contribution_links table --- .../ContributionLinks.ts | 2 +- database/entity/ContributionLinks.ts | 2 +- .../0037-add_contribution_links_table.ts | 35 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) rename database/entity/{0038-add_contribution_links_table => 0037-add_contribution_links_table}/ContributionLinks.ts (97%) create mode 100644 database/migrations/0037-add_contribution_links_table.ts diff --git a/database/entity/0038-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts similarity index 97% rename from database/entity/0038-add_contribution_links_table/ContributionLinks.ts rename to database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 5f78a7450..2fb4e2801 100644 --- a/database/entity/0038-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -100,7 +100,7 @@ export class ContributionLinks extends BaseEntity { @Column({ name: 'deleted_at', type: 'datetime', nullable: true, default: null }) deletedAt: Date | null - @Column({ length: 24, nullable: false, collation: 'utf8mb4_unicode_ci' }) + @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) code: string @Column({ name: 'link_enabled', type: 'boolean', nullable: true, default: null }) diff --git a/database/entity/ContributionLinks.ts b/database/entity/ContributionLinks.ts index 721dfd2b3..de26c1c4a 100644 --- a/database/entity/ContributionLinks.ts +++ b/database/entity/ContributionLinks.ts @@ -1 +1 @@ -export { ContributionLinks } from './0038-add_contribution_links_table/ContributionLinks' +export { ContributionLinks } from './0037-add_contribution_links_table/ContributionLinks' diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts new file mode 100644 index 000000000..79bcdf5ce --- /dev/null +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -0,0 +1,35 @@ +/* MIGRATION TO ADD CONTRIBUTION_LINKS + * + * This migration adds the table `contribution_links` in order to store all sorts of contribution_links data + */ + +/* 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>) { + await queryFn(` + CREATE TABLE IF NOT EXISTS \`contribution_links\` ( + \`id\` int(10) unsigned NOT NULL AUTO_INCREMENT, + \`name\` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, + \`decsription\` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + \`valid_from\` datetime NULL, + \`valid_to\` datetime NULL, + \`amount\` bigint(20) NOT NULL, + \`cycle\` int(10) unsigned NOT NULL DEFAULT '1', + \`max_per_cycle\` int(10) unsigned NOT NULL DEFAULT '1', + \`max_amount_per_month\` bigint(20) NULL DEFAULT NULL, + \`total_max_count_of_contribution\` int(10) unsigned NULL DEFAULT NULL, + \`max_account_balance\` bigint(20) NULL DEFAULT NULL, + \`min_gap_hours\` int(10) unsigned NULL DEFAULT NULL, + \`created_at\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + \`deleted_at\` datetime NULL DEFAULT NULL, + \`code\` varchar(24) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, + \`link_enabled\` tinyint(4) NOT NULL DEFAULT '0', + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // write downgrade logic as parameter of queryFn + await queryFn(`DROP TABLE IF EXISTS \`contribution_links\`;`) +} From d6556cd02c8195a698fc01b7373fc6a7cec4c01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 1 Jun 2022 10:01:20 +0200 Subject: [PATCH 15/51] Update backend/src/graphql/resolver/AdminResolver.ts Co-authored-by: Moriz Wahl --- backend/src/graphql/resolver/AdminResolver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 54207b17c..13d725bac 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -443,7 +443,7 @@ export class AdminResolver { if (!filters || !filters.withExpired) where.validUntil = MoreThan(new Date()) const [transactionLinks, count] = await dbTransactionLink.findAndCount({ where, - withDeleted: !filters ? false : filters.withDeleted, + withDeleted: filters ? filters.withDeleted : false, order: { createdAt: order, }, From 517034dcabe8234b626d4d54e0ba7bf1df970ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 1 Jun 2022 10:02:38 +0200 Subject: [PATCH 16/51] Update backend/src/graphql/resolver/AdminResolver.ts Co-authored-by: Moriz Wahl --- backend/src/graphql/resolver/AdminResolver.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 13d725bac..f267dbe3d 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -439,8 +439,10 @@ export class AdminResolver { } = { userId, } - if (!filters || !filters.withRedeemed) where.redeemedBy = null - if (!filters || !filters.withExpired) where.validUntil = MoreThan(new Date()) + if (filters) { + if (filters.withRedeemed) delete where.redeemedBy + if (filters.withExpired) delete where.validUntil + } const [transactionLinks, count] = await dbTransactionLink.findAndCount({ where, withDeleted: filters ? filters.withDeleted : false, From 06b5aaaa1cca254936702f6626bd8e1c41d496cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 1 Jun 2022 10:05:02 +0200 Subject: [PATCH 17/51] Update backend/src/graphql/resolver/AdminResolver.ts Co-authored-by: Moriz Wahl --- backend/src/graphql/resolver/AdminResolver.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index f267dbe3d..8e2d21893 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -438,6 +438,8 @@ export class AdminResolver { validUntil?: FindOperator | null } = { userId, + redeemedBy: null, + validUntil: MoreThan(new Date()), } if (filters) { if (filters.withRedeemed) delete where.redeemedBy From 3f8c1169ba9d7377dfaec58c55a07596a235d410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 1 Jun 2022 10:19:46 +0200 Subject: [PATCH 18/51] Fix wrongly changed month on transaction links data --- backend/src/seeds/transactionLink/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/seeds/transactionLink/index.ts b/backend/src/seeds/transactionLink/index.ts index 1db3d4828..c3245c2b6 100644 --- a/backend/src/seeds/transactionLink/index.ts +++ b/backend/src/seeds/transactionLink/index.ts @@ -5,7 +5,7 @@ export const transactionLinks: TransactionLinkInterface[] = [ email: 'bibi@bloxberg.de', amount: 19.99, memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', - createdAt: new Date(2022, 1, 1), + createdAt: new Date(2022, 0, 1), }, { email: 'bibi@bloxberg.de', From 8650f86a7deca060f7969dfc4751cf83ad79242a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 1 Jun 2022 10:26:53 +0200 Subject: [PATCH 19/51] Put expected directly into the test after Moriz suggestion to get it better to debug --- .../graphql/resolver/AdminResolver.test.ts | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 3b5908908..a755b0da6 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1382,24 +1382,6 @@ describe('AdminResolver', () => { }) describe('with admin rights', () => { - const expectNoDeletedOrRedeemed = expect.objectContaining({ - data: { - listTransactionLinksAdmin: { - linkCount: 6, - linkList: expect.not.arrayContaining([ - expect.objectContaining({ - memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', - createdAt: expect.any(String), - }), - expect.objectContaining({ - memo: 'Da habe ich mich wohl etwas übernommen.', - deletedAt: expect.any(String), - }), - ]), - }, - }, - }) - beforeAll(async () => { // admin 'peter@lustig.de' has to exists for 'creationFactory' admin = await userFactory(testEnv, peterLustig) @@ -1437,7 +1419,25 @@ describe('AdminResolver', () => { query: listTransactionLinksAdmin, variables, }), - ).resolves.toEqual(expectNoDeletedOrRedeemed) + ).resolves.toEqual( + expect.objectContaining({ + data: { + listTransactionLinksAdmin: { + linkCount: 6, + linkList: expect.not.arrayContaining([ + expect.objectContaining({ + memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', + createdAt: expect.any(String), + }), + expect.objectContaining({ + memo: 'Da habe ich mich wohl etwas übernommen.', + deletedAt: expect.any(String), + }), + ]), + }, + }, + }), + ) }) }) @@ -1455,7 +1455,25 @@ describe('AdminResolver', () => { }, }, }), - ).resolves.toEqual(expectNoDeletedOrRedeemed) + ).resolves.toEqual( + expect.objectContaining({ + data: { + listTransactionLinksAdmin: { + linkCount: 6, + linkList: expect.not.arrayContaining([ + expect.objectContaining({ + memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', + createdAt: expect.any(String), + }), + expect.objectContaining({ + memo: 'Da habe ich mich wohl etwas übernommen.', + deletedAt: expect.any(String), + }), + ]), + }, + }, + }), + ) }) }) From 772bf82000630bb9d9ac22fa3436e9197c0ecad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 1 Jun 2022 11:09:21 +0200 Subject: [PATCH 20/51] Fix linting in database README.md --- database/README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/database/README.md b/database/README.md index d6cf84518..e951f4530 100644 --- a/database/README.md +++ b/database/README.md @@ -1,32 +1,39 @@ # database ## Project setup -``` + +```bash yarn install ``` ## Upgrade migrations production -``` + +```bash yarn up ``` ## Upgrade migrations development -``` + +```bash yarn dev_up ``` ## Downgrade migrations production -``` + +```bash yarn down ``` ## Downgrade migrations development -``` + +```bash yarn dev_down ``` ## Reset database -``` + +```bash yarn dev_reset ``` + Runs all down migrations and after this all up migrations. From dbc98e8490daf9fc11c38cb8e931912e0fe028b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 1 Jun 2022 12:03:42 +0200 Subject: [PATCH 21/51] Remove 'user_setting' table from db - Add migration 0037-drop_server_user_table.ts --- .../migrations/0037-drop_server_user_table.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 database/migrations/0037-drop_server_user_table.ts diff --git a/database/migrations/0037-drop_server_user_table.ts b/database/migrations/0037-drop_server_user_table.ts new file mode 100644 index 000000000..50a78e104 --- /dev/null +++ b/database/migrations/0037-drop_server_user_table.ts @@ -0,0 +1,19 @@ +/* MIGRATION DROP user_setting TABLE */ + +/* 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>) { + await queryFn('DROP TABLE `user_setting`;') +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn(` + CREATE TABLE IF NOT EXISTS \`user_setting\` ( + \`id\` int(10) unsigned NOT NULL AUTO_INCREMENT, + \`userId\` int(11) NOT NULL, + \`key\` varchar(255) NOT NULL, + \`value\` varchar(255) NOT NULL, + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`) +} From 71595428b3567f6e71fbfccfa343113efb8d2400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 1 Jun 2022 12:39:57 +0200 Subject: [PATCH 22/51] Set DB_VERSION to '0037-drop_server_user_table.ts' --- 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 28318ed6b..2015eb6cc 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0036-unique_previous_in_transactions', + DB_VERSION: '0037-drop_server_user_table.ts', 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 70b1119840c0ff895be8f5326eb60308aab57cfe Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 1 Jun 2022 14:10:37 +0200 Subject: [PATCH 23/51] queries in queries file instead of mutations --- backend/src/seeds/graphql/mutations.ts | 29 -------------------------- backend/src/seeds/graphql/queries.ts | 29 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index d5dc99b99..44a9499bf 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -161,32 +161,3 @@ export const deletePendingCreation = gql` deletePendingCreation(id: $id) } ` - -export const listTransactionLinksAdmin = gql` - query ( - $userId: Int! - $filters: TransactionLinkFilters - $currentPage: Int = 1 - $pageSize: Int = 5 - ) { - listTransactionLinksAdmin( - userId: $userId - filters: $filters - currentPage: $currentPage - pageSize: $pageSize - ) { - linkCount - linkList { - id - amount - holdAvailableAmount - memo - code - createdAt - validUntil - redeemedAt - deletedAt - } - } - } -` diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index 16b2b71ae..f3b9f03c2 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -164,3 +164,32 @@ export const getPendingCreations = gql` } } ` + +export const listTransactionLinksAdmin = gql` + query ( + $userId: Int! + $filters: TransactionLinkFilters + $currentPage: Int = 1 + $pageSize: Int = 5 + ) { + listTransactionLinksAdmin( + userId: $userId + filters: $filters + currentPage: $currentPage + pageSize: $pageSize + ) { + linkCount + linkList { + id + amount + holdAvailableAmount + memo + code + createdAt + validUntil + redeemedAt + deletedAt + } + } + } +` From 2c67d5f5fef123d14c4a169718129272396880bf Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 1 Jun 2022 14:11:50 +0200 Subject: [PATCH 24/51] filter args optional, now default values --- backend/src/graphql/arg/TransactionLinkFilters.ts | 6 +++--- backend/src/graphql/resolver/AdminResolver.test.ts | 11 +++-------- backend/src/graphql/resolver/AdminResolver.ts | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/backend/src/graphql/arg/TransactionLinkFilters.ts b/backend/src/graphql/arg/TransactionLinkFilters.ts index a335f6a28..291d244c3 100644 --- a/backend/src/graphql/arg/TransactionLinkFilters.ts +++ b/backend/src/graphql/arg/TransactionLinkFilters.ts @@ -2,12 +2,12 @@ import { Field, InputType } from 'type-graphql' @InputType() export default class TransactionLinkFilters { - @Field(() => Boolean, { nullable: true, defaultValue: true }) + @Field(() => Boolean, { nullable: true }) withDeleted: boolean - @Field(() => Boolean, { nullable: true, defaultValue: true }) + @Field(() => Boolean, { nullable: true }) withExpired: boolean - @Field(() => Boolean, { nullable: true, defaultValue: true }) + @Field(() => Boolean, { nullable: true }) withRedeemed: boolean } diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index a755b0da6..eee013e84 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -21,9 +21,8 @@ import { updatePendingCreation, deletePendingCreation, confirmPendingCreation, - listTransactionLinksAdmin, } from '@/seeds/graphql/mutations' -import { getPendingCreations, login } from '@/seeds/graphql/queries' +import { getPendingCreations, login, listTransactionLinksAdmin } from '@/seeds/graphql/queries' import { GraphQLError } from 'graphql' import { User } from '@entity/User' /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ @@ -1388,6 +1387,7 @@ describe('AdminResolver', () => { user = await userFactory(testEnv, bibiBloxberg) variables.userId = user.id + variables.pageSize = 25 // bibi needs GDDs const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de') // eslint-disable-next-line @typescript-eslint/no-non-null-assertion @@ -1486,8 +1486,6 @@ describe('AdminResolver', () => { ...variables, filters: { withDeleted: true, - withExpired: null, - withRedeemed: null, }, }, }), @@ -1513,8 +1511,7 @@ describe('AdminResolver', () => { }) }) - // TODO: works not as expected, because the expired link is not in the result eventhogh a link has 'createdAt' at the very first of 2022 and should be expired - describe.skip('filter by expired', () => { + describe('filter by expired', () => { it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { await expect( query({ @@ -1522,9 +1519,7 @@ describe('AdminResolver', () => { variables: { ...variables, filters: { - withDeleted: null, withExpired: true, - withRedeemed: null, }, }, }), diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 8e2d21893..4c94e48c8 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -426,7 +426,7 @@ export class AdminResolver { async listTransactionLinksAdmin( @Args() { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, - @Arg('filters', () => TransactionLinkFilters, { nullable: true, defaultValue: null }) + @Arg('filters', () => TransactionLinkFilters, { nullable: true }) filters: TransactionLinkFilters, @Arg('userId', () => Int) userId: number, From 7ee664b8c87df5e4dbb9206341cabfa65b4ec2f3 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 1 Jun 2022 14:12:41 +0200 Subject: [PATCH 25/51] set defaults for transcation link list filters in query --- admin/src/graphql/listTransactionLinksAdmin.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/admin/src/graphql/listTransactionLinksAdmin.js b/admin/src/graphql/listTransactionLinksAdmin.js index 3c9eae100..2e4171f02 100644 --- a/admin/src/graphql/listTransactionLinksAdmin.js +++ b/admin/src/graphql/listTransactionLinksAdmin.js @@ -2,7 +2,12 @@ import gql from 'graphql-tag' export const listTransactionLinksAdmin = gql` query ($currentPage: Int = 1, $pageSize: Int = 5, $userId: Int!) { - listTransactionLinksAdmin(currentPage: $currentPage, pageSize: $pageSize, userId: $userId) { + listTransactionLinksAdmin( + currentPage: $currentPage + pageSize: $pageSize + userId: $userId + filters: { withRedeemed: true, withExpired: true, withDeleted: true } + ) { linkCount linkList { id From de7a41516a7b3c721dc38863ae677ba38635d95d Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 2 Jun 2022 08:04:21 +0200 Subject: [PATCH 26/51] refactor register button position --- frontend/src/pages/Register.vue | 42 +++++++++++++++------------------ 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/frontend/src/pages/Register.vue b/frontend/src/pages/Register.vue index 3d99ca605..f1bfad6d9 100755 --- a/frontend/src/pages/Register.vue +++ b/frontend/src/pages/Register.vue @@ -63,29 +63,25 @@ - - - - - - - - - - - - {{ $t('signup') }} - - - +
+ + + + +
+
+ + {{ $t('signup') }} + +
From ca8ce34f68baca58bb7a39f8608514cb89242a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 2 Jun 2022 11:20:58 +0200 Subject: [PATCH 27/51] Move 'searchUsers' query from mutations to queries, correct and refine test descriptions --- .../graphql/resolver/AdminResolver.test.ts | 14 +++++++---- backend/src/seeds/graphql/mutations.ts | 24 ------------------- backend/src/seeds/graphql/queries.ts | 24 +++++++++++++++++++ 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index eee013e84..acf880efb 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -15,14 +15,18 @@ import { garrickOllivander } from '@/seeds/users/garrick-ollivander' import { deleteUser, unDeleteUser, - searchUsers, createPendingCreation, createPendingCreations, updatePendingCreation, deletePendingCreation, confirmPendingCreation, } from '@/seeds/graphql/mutations' -import { getPendingCreations, login, listTransactionLinksAdmin } from '@/seeds/graphql/queries' +import { + getPendingCreations, + login, + searchUsers, + listTransactionLinksAdmin, +} from '@/seeds/graphql/queries' import { GraphQLError } from 'graphql' import { User } from '@entity/User' /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ @@ -1478,7 +1482,7 @@ describe('AdminResolver', () => { }) describe('filter with deleted', () => { - it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { + it('finds 6 open transaction links, 1 deleted, and no redeemed', async () => { await expect( query({ query: listTransactionLinksAdmin, @@ -1512,7 +1516,7 @@ describe('AdminResolver', () => { }) describe('filter by expired', () => { - it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { + it('finds 5 open transaction links, 1 expired, and no redeemed', async () => { await expect( query({ query: listTransactionLinksAdmin, @@ -1547,7 +1551,7 @@ describe('AdminResolver', () => { // TODO: works not as expected, because 'redeemedAt' and 'redeemedBy' have to be added to the transaktion link factory describe.skip('filter by redeemed', () => { - it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { + it('finds 6 open transaction links, 1 deleted, and no redeemed', async () => { await expect( query({ query: listTransactionLinksAdmin, diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 44a9499bf..e66827566 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -105,30 +105,6 @@ export const unDeleteUser = gql` } ` -export const searchUsers = gql` - query ($searchText: String!, $currentPage: Int, $pageSize: Int, $filters: SearchUsersFilters) { - searchUsers( - searchText: $searchText - currentPage: $currentPage - pageSize: $pageSize - filters: $filters - ) { - userCount - userList { - userId - firstName - lastName - email - creation - emailChecked - hasElopage - emailConfirmationSend - deletedAt - } - } - } -` - export const createPendingCreations = gql` mutation ($pendingCreations: [CreatePendingCreationArgs!]!) { createPendingCreations(pendingCreations: $pendingCreations) { diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index f3b9f03c2..03ee3b53e 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -91,6 +91,30 @@ export const sendResetPasswordEmail = gql` } ` +export const searchUsers = gql` + query ($searchText: String!, $currentPage: Int, $pageSize: Int, $filters: SearchUsersFilters) { + searchUsers( + searchText: $searchText + currentPage: $currentPage + pageSize: $pageSize + filters: $filters + ) { + userCount + userList { + userId + firstName + lastName + email + creation + emailChecked + hasElopage + emailConfirmationSend + deletedAt + } + } + } +` + export const listGDTEntriesQuery = gql` query ($currentPage: Int!, $pageSize: Int!) { listGDTEntries(currentPage: $currentPage, pageSize: $pageSize) { From 9f9c6aed79e931d58a0e4097982f354618b6e754 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 2 Jun 2022 14:28:27 +0200 Subject: [PATCH 28/51] devops: Release Version 1.9.0 --- CHANGELOG.md | 40 ++++++++++++++++++++++++++++++++++++++++ admin/package.json | 2 +- backend/package.json | 2 +- database/package.json | 2 +- frontend/package.json | 2 +- package.json | 2 +- 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48eeff9a9..53aa4a9e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,48 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.9.0](https://github.com/gradido/gradido/compare/1.8.3...1.9.0) + +- refactor: 🍰 Refactor To `filters` Object And Rename Filters Properties [`#1914`](https://github.com/gradido/gradido/pull/1914) +- refactor register button position [`#1964`](https://github.com/gradido/gradido/pull/1964) +- fixed redeem link is mobile start false [`#1958`](https://github.com/gradido/gradido/pull/1958) +- 1951 remove back link and remove gray box [`#1959`](https://github.com/gradido/gradido/pull/1959) +- 1952 change footer icons color an remove save login [`#1955`](https://github.com/gradido/gradido/pull/1955) +- fix: License should be a valid SPDX license expression [`#1954`](https://github.com/gradido/gradido/pull/1954) +- refactor: 🍰 Refactor THX Page – 2. Step [`#1858`](https://github.com/gradido/gradido/pull/1858) +- fix: Add Timezone to Decay Start Block [`#1931`](https://github.com/gradido/gradido/pull/1931) +- devops: Update License in all package.json [`#1925`](https://github.com/gradido/gradido/pull/1925) +- docu: Creation Flowchart [`#1918`](https://github.com/gradido/gradido/pull/1918) +- refactor: Use Logger Categories [`#1912`](https://github.com/gradido/gradido/pull/1912) +- 1883 remove the animated coins in the profile settings [`#1946`](https://github.com/gradido/gradido/pull/1946) +- 1942 replace pictures for carousel [`#1943`](https://github.com/gradido/gradido/pull/1943) +- 1933 auth footer is not on one level [`#1941`](https://github.com/gradido/gradido/pull/1941) +- 1929 styling new template for password component [`#1935`](https://github.com/gradido/gradido/pull/1935) +- 1926 button concept for gradido template [`#1927`](https://github.com/gradido/gradido/pull/1927) +- 1916 remove select language from register form [`#1930`](https://github.com/gradido/gradido/pull/1930) +- rename files from auth folder, rule vue name = name files [`#1937`](https://github.com/gradido/gradido/pull/1937) +- Add files Bild_1_2400.jpg [`#1945`](https://github.com/gradido/gradido/pull/1945) +- Bilder für Slider [`#1940`](https://github.com/gradido/gradido/pull/1940) +- contribution analysis of elopage and concept proposal [`#1917`](https://github.com/gradido/gradido/pull/1917) +- 1676 feature federation technical concept [`#1711`](https://github.com/gradido/gradido/pull/1711) +- more details about Windows installation [`#1842`](https://github.com/gradido/gradido/pull/1842) +- Concept to Introduce Gradido ID [`#1797`](https://github.com/gradido/gradido/pull/1797) +- first draft of concept event protocol [`#1796`](https://github.com/gradido/gradido/pull/1796) +- 1682 new design for the login and registration area [`#1693`](https://github.com/gradido/gradido/pull/1693) +- fix: Database Connection Charset to utf8mb4_unicode_ci [`#1915`](https://github.com/gradido/gradido/pull/1915) +- refactor: 🍰 Create Filter Object in GQL And Rename Args [`#1860`](https://github.com/gradido/gradido/pull/1860) +- feat: 🍰 Improve Apollo Logging [`#1859`](https://github.com/gradido/gradido/pull/1859) +- Add files via upload [`#1903`](https://github.com/gradido/gradido/pull/1903) +- 🍰 Hide Pagenation On Short Transactionlist [`#1875`](https://github.com/gradido/gradido/pull/1875) +- 🍰 Ignore macOS .DS_Store Files [`#1902`](https://github.com/gradido/gradido/pull/1902) +- pre I from #1682, add images, svg for new styling [`#1900`](https://github.com/gradido/gradido/pull/1900) +- add browserstack logo image [`#1888`](https://github.com/gradido/gradido/pull/1888) + #### [1.8.3](https://github.com/gradido/gradido/compare/1.8.2...1.8.3) +> 13 May 2022 + +- Release 1.8.3 [`#1899`](https://github.com/gradido/gradido/pull/1899) - Checkbox [`#1894`](https://github.com/gradido/gradido/pull/1894) - fix: Count Deprecated Links as Well [`#1892`](https://github.com/gradido/gradido/pull/1892) diff --git a/admin/package.json b/admin/package.json index c649ca752..e36308fd9 100644 --- a/admin/package.json +++ b/admin/package.json @@ -3,7 +3,7 @@ "description": "Administraion Interface for Gradido", "main": "index.js", "author": "Moriz Wahl", - "version": "1.8.3", + "version": "1.9.0", "license": "Apache-2.0", "private": false, "scripts": { diff --git a/backend/package.json b/backend/package.json index ff483a0c6..bd5388632 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "gradido-backend", - "version": "1.8.3", + "version": "1.9.0", "description": "Gradido unified backend providing an API-Service for Gradido Transactions", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/backend", diff --git a/database/package.json b/database/package.json index 7a960994c..50e3bdd78 100644 --- a/database/package.json +++ b/database/package.json @@ -1,6 +1,6 @@ { "name": "gradido-database", - "version": "1.8.3", + "version": "1.9.0", "description": "Gradido Database Tool to execute database migrations", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/database", diff --git a/frontend/package.json b/frontend/package.json index ae5dca33c..e59ec8140 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-vue-gradido-wallet", - "version": "1.8.3", + "version": "1.9.0", "private": true, "scripts": { "start": "node run/server.js", diff --git a/package.json b/package.json index b607c476d..3d5bc51b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gradido", - "version": "1.8.3", + "version": "1.9.0", "description": "Gradido", "main": "index.js", "repository": "git@github.com:gradido/gradido.git", From 1e0e6e24b97c7929b52d40496b13d2458aa79a3e Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 2 Jun 2022 21:46:18 +0200 Subject: [PATCH 29/51] locales link german, english navbar --- frontend/src/components/Auth/AuthNavbar.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Auth/AuthNavbar.vue b/frontend/src/components/Auth/AuthNavbar.vue index 7b3eed0e3..8063dd330 100644 --- a/frontend/src/components/Auth/AuthNavbar.vue +++ b/frontend/src/components/Auth/AuthNavbar.vue @@ -20,7 +20,7 @@ - + {{ $t('auth.navbar.aboutGradido') }} {{ $t('signup') }} From 74bcdaf8c4f11e3f2746c8d2f33e0b1bbd1d0a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Fri, 3 Jun 2022 00:06:14 +0200 Subject: [PATCH 30/51] add .project and correct .gitignore --- .gitignore | 2 -- .project | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .project diff --git a/.gitignore b/.gitignore index 08ccd2b30..6ac3a32c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -.dbeaver -.project *.log /node_modules/* messages.pot diff --git a/.project b/.project new file mode 100644 index 000000000..5d9663f32 --- /dev/null +++ b/.project @@ -0,0 +1,18 @@ + + + Gradido + + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.jkiss.dbeaver.DBeaverNature + org.eclipse.wst.jsdt.core.jsNature + + From d958cfdfde0d045e1d8e92b1753c8e70455bcfd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 7 Jun 2022 10:33:46 +0200 Subject: [PATCH 31/51] Fix DB_VERSION --- 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 2015eb6cc..1adc68981 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0037-drop_server_user_table.ts', + DB_VERSION: '0037-drop_server_user_table', 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 6abb399ab9398e441b196d97de499701ee41e674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 7 Jun 2022 11:33:47 +0200 Subject: [PATCH 32/51] Removed UserSetting from backend --- .../repository/UserSettingRepository.ts | 25 ------- backend/src/util/communityUser.ts | 1 - database/entity/0002-add_settings/User.ts | 2 +- .../entity/0002-add_settings/UserSetting.ts | 2 +- .../entity/0017-combine_user_tables/User.ts | 2 +- .../User.ts | 2 +- .../User.ts | 2 +- .../0020-rename_and_clean_state_users/User.ts | 2 +- .../0023-users_disabled_soft_delete/User.ts | 2 +- database/entity/0033-add_referrer_id/User.ts | 2 +- .../0034-drop_server_user_table/User.ts | 2 +- .../0037-drop_server_user_table/User.ts | 70 +++++++++++++++++++ database/entity/User.ts | 2 +- database/entity/UserSetting.ts | 1 - database/entity/index.ts | 2 - 15 files changed, 80 insertions(+), 39 deletions(-) delete mode 100644 backend/src/typeorm/repository/UserSettingRepository.ts create mode 100644 database/entity/0037-drop_server_user_table/User.ts delete mode 100644 database/entity/UserSetting.ts diff --git a/backend/src/typeorm/repository/UserSettingRepository.ts b/backend/src/typeorm/repository/UserSettingRepository.ts deleted file mode 100644 index f911cfd1a..000000000 --- a/backend/src/typeorm/repository/UserSettingRepository.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { EntityRepository, Repository } from '@dbTools/typeorm' -import { UserSetting } from '@entity/UserSetting' -import { isStringBoolean } from '@/util/validate' - -@EntityRepository(UserSetting) -export class UserSettingRepository extends Repository { - async setOrUpdate(userId: number, value: string): Promise { - let entity = await this.findOne({ userId: userId }) - - if (!entity) { - entity = new UserSetting() - entity.userId = userId - } - entity.value = value - return this.save(entity) - } - - async readBoolean(userId: number): Promise { - const entity = await this.findOne({ userId: userId }) - if (!entity || !isStringBoolean(entity.value)) { - return true - } - return entity.value.toLowerCase() === 'true' - } -} diff --git a/backend/src/util/communityUser.ts b/backend/src/util/communityUser.ts index 0d0d12f6c..1a84c2cdf 100644 --- a/backend/src/util/communityUser.ts +++ b/backend/src/util/communityUser.ts @@ -20,7 +20,6 @@ const communityDbUser: dbUser = { isAdmin: null, publisherId: 0, passphrase: '', - settings: [], hasId: function (): boolean { throw new Error('Function not implemented.') }, diff --git a/database/entity/0002-add_settings/User.ts b/database/entity/0002-add_settings/User.ts index a756cbbd5..4f333fd50 100644 --- a/database/entity/0002-add_settings/User.ts +++ b/database/entity/0002-add_settings/User.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' // Moriz: I do not like the idea of having two user tables @Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) diff --git a/database/entity/0002-add_settings/UserSetting.ts b/database/entity/0002-add_settings/UserSetting.ts index 006d63e3e..6103f67b5 100644 --- a/database/entity/0002-add_settings/UserSetting.ts +++ b/database/entity/0002-add_settings/UserSetting.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm' -import { User } from '../User' +import { User } from '../0034-drop_server_user_table/User' // Wolle: last fitting one or old was correct? @Entity() export class UserSetting extends BaseEntity { diff --git a/database/entity/0017-combine_user_tables/User.ts b/database/entity/0017-combine_user_tables/User.ts index a9bf29d24..7281c4773 100644 --- a/database/entity/0017-combine_user_tables/User.ts +++ b/database/entity/0017-combine_user_tables/User.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0018-combine_login_user_backups_and_user_table/User.ts b/database/entity/0018-combine_login_user_backups_and_user_table/User.ts index 2ae351e47..347f51a8d 100644 --- a/database/entity/0018-combine_login_user_backups_and_user_table/User.ts +++ b/database/entity/0018-combine_login_user_backups_and_user_table/User.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0019-replace_login_user_id_with_state_user_id/User.ts b/database/entity/0019-replace_login_user_id_with_state_user_id/User.ts index b469a55a7..8c00ec5c3 100644 --- a/database/entity/0019-replace_login_user_id_with_state_user_id/User.ts +++ b/database/entity/0019-replace_login_user_id_with_state_user_id/User.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('state_users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0020-rename_and_clean_state_users/User.ts b/database/entity/0020-rename_and_clean_state_users/User.ts index 3d3b4d7b1..5501bccba 100644 --- a/database/entity/0020-rename_and_clean_state_users/User.ts +++ b/database/entity/0020-rename_and_clean_state_users/User.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0023-users_disabled_soft_delete/User.ts b/database/entity/0023-users_disabled_soft_delete/User.ts index 95fe1b3f7..950e74aeb 100644 --- a/database/entity/0023-users_disabled_soft_delete/User.ts +++ b/database/entity/0023-users_disabled_soft_delete/User.ts @@ -6,7 +6,7 @@ import { OneToMany, DeleteDateColumn, } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0033-add_referrer_id/User.ts b/database/entity/0033-add_referrer_id/User.ts index 48c804b63..353c6a830 100644 --- a/database/entity/0033-add_referrer_id/User.ts +++ b/database/entity/0033-add_referrer_id/User.ts @@ -6,7 +6,7 @@ import { OneToMany, DeleteDateColumn, } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0034-drop_server_user_table/User.ts b/database/entity/0034-drop_server_user_table/User.ts index 1f56d13d2..82fd72009 100644 --- a/database/entity/0034-drop_server_user_table/User.ts +++ b/database/entity/0034-drop_server_user_table/User.ts @@ -6,7 +6,7 @@ import { OneToMany, DeleteDateColumn, } from 'typeorm' -import { UserSetting } from '../UserSetting' +import { UserSetting } from '../0002-add_settings/UserSetting' @Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) export class User extends BaseEntity { diff --git a/database/entity/0037-drop_server_user_table/User.ts b/database/entity/0037-drop_server_user_table/User.ts new file mode 100644 index 000000000..528cef32b --- /dev/null +++ b/database/entity/0037-drop_server_user_table/User.ts @@ -0,0 +1,70 @@ +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } from 'typeorm' + +@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) +export class User extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ name: 'public_key', type: 'binary', length: 32, default: null, nullable: true }) + pubKey: Buffer + + @Column({ name: 'privkey', type: 'binary', length: 80, default: null, nullable: true }) + privKey: Buffer + + @Column({ length: 255, unique: true, nullable: false, collation: 'utf8mb4_unicode_ci' }) + email: string + + @Column({ + name: 'first_name', + length: 255, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + firstName: string + + @Column({ + name: 'last_name', + length: 255, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + lastName: string + + @DeleteDateColumn() + deletedAt: Date | null + + @Column({ type: 'bigint', default: 0, unsigned: true }) + password: BigInt + + @Column({ name: 'email_hash', type: 'binary', length: 32, default: null, nullable: true }) + emailHash: Buffer + + @Column({ name: 'created', default: () => 'CURRENT_TIMESTAMP', nullable: false }) + createdAt: Date + + @Column({ name: 'email_checked', type: 'bool', nullable: false, default: false }) + emailChecked: boolean + + @Column({ length: 4, default: 'de', collation: 'utf8mb4_unicode_ci', nullable: false }) + language: string + + @Column({ name: 'is_admin', type: 'datetime', nullable: true, default: null }) + isAdmin: Date | null + + @Column({ name: 'referrer_id', type: 'int', unsigned: true, nullable: true, default: null }) + referrerId?: number | null + + @Column({ name: 'publisher_id', default: 0 }) + publisherId: number + + @Column({ + type: 'text', + name: 'passphrase', + collation: 'utf8mb4_unicode_ci', + nullable: true, + default: null, + }) + passphrase: string +} diff --git a/database/entity/User.ts b/database/entity/User.ts index 4cd68174c..6983f293b 100644 --- a/database/entity/User.ts +++ b/database/entity/User.ts @@ -1 +1 @@ -export { User } from './0034-drop_server_user_table/User' +export { User } from './0037-drop_server_user_table/User' diff --git a/database/entity/UserSetting.ts b/database/entity/UserSetting.ts deleted file mode 100644 index 38da380f9..000000000 --- a/database/entity/UserSetting.ts +++ /dev/null @@ -1 +0,0 @@ -export { UserSetting } from './0002-add_settings/UserSetting' diff --git a/database/entity/index.ts b/database/entity/index.ts index 542333755..46d9ef31a 100644 --- a/database/entity/index.ts +++ b/database/entity/index.ts @@ -4,7 +4,6 @@ import { Migration } from './Migration' import { Transaction } from './Transaction' import { TransactionLink } from './TransactionLink' import { User } from './User' -import { UserSetting } from './UserSetting' import { AdminPendingCreation } from './AdminPendingCreation' export const entities = [ @@ -15,5 +14,4 @@ export const entities = [ Transaction, TransactionLink, User, - UserSetting, ] From 338c1591cb1cd5954e5665ac45d25fd8384dbb16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 7 Jun 2022 11:45:07 +0200 Subject: [PATCH 33/51] Cleanup --- database/entity/0002-add_settings/UserSetting.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/entity/0002-add_settings/UserSetting.ts b/database/entity/0002-add_settings/UserSetting.ts index 6103f67b5..9da036954 100644 --- a/database/entity/0002-add_settings/UserSetting.ts +++ b/database/entity/0002-add_settings/UserSetting.ts @@ -1,5 +1,5 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm' -import { User } from '../0034-drop_server_user_table/User' // Wolle: last fitting one or old was correct? +import { User } from '../0034-drop_server_user_table/User' @Entity() export class UserSetting extends BaseEntity { From bb35332e2ed6c0bf66b3cd4ec29b82a679c97db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Jun 2022 22:13:27 +0200 Subject: [PATCH 34/51] change Cycle Type in tabel ContributionLinks --- .dbeaver/.credentials-config.json.bak | 2 ++ .dbeaver/.data-sources.json.bak | 33 +++++++++++++++++++ .dbeaver/credentials-config.json | 3 ++ .dbeaver/data-sources.json | 32 ++++++++++++++++++ .../ContributionLinks.ts | 26 ++------------- .../0037-add_contribution_links_table.ts | 2 +- 6 files changed, 73 insertions(+), 25 deletions(-) create mode 100644 .dbeaver/.credentials-config.json.bak create mode 100644 .dbeaver/.data-sources.json.bak create mode 100644 .dbeaver/credentials-config.json create mode 100644 .dbeaver/data-sources.json diff --git a/.dbeaver/.credentials-config.json.bak b/.dbeaver/.credentials-config.json.bak new file mode 100644 index 000000000..2eca1988d --- /dev/null +++ b/.dbeaver/.credentials-config.json.bak @@ -0,0 +1,2 @@ +'U[V$8%kQN, +`W-T3NvU{ɆHK~,DXpX.g/:?B9|GZn>/ \ No newline at end of file diff --git a/.dbeaver/.data-sources.json.bak b/.dbeaver/.data-sources.json.bak new file mode 100644 index 000000000..7d9528f01 --- /dev/null +++ b/.dbeaver/.data-sources.json.bak @@ -0,0 +1,33 @@ +{ + "folders": {}, + "connections": { + "mariaDB-1813fbbc7bc-107c0b3aeaeb91ab": { + "provider": "mysql", + "driver": "mariaDB", + "name": "gradido", + "save-password": true, + "read-only": false, + "configuration": { + "host": "localhost", + "port": "3306", + "database": "gradido", + "url": "jdbc:mariadb://localhost:3306/gradido", + "home": "mysql_client", + "type": "dev", + "auth-model": "native", + "handlers": {} + } + } + }, + "connection-types": { + "dev": { + "name": "Development", + "color": "255,255,255", + "description": "Regular development database", + "auto-commit": true, + "confirm-execute": false, + "confirm-data-change": false, + "auto-close-transactions": false + } + } +} \ No newline at end of file diff --git a/.dbeaver/credentials-config.json b/.dbeaver/credentials-config.json new file mode 100644 index 000000000..d814bdfcf --- /dev/null +++ b/.dbeaver/credentials-config.json @@ -0,0 +1,3 @@ +4k1,fbAqĬc##s8-1&;"7djM?bljfBq= +my +vV \ No newline at end of file diff --git a/.dbeaver/data-sources.json b/.dbeaver/data-sources.json new file mode 100644 index 000000000..096f0d57e --- /dev/null +++ b/.dbeaver/data-sources.json @@ -0,0 +1,32 @@ +{ + "folders": {}, + "connections": { + "mariaDB-1813fbbc7bc-107c0b3aeaeb91ab": { + "provider": "mysql", + "driver": "mariaDB", + "name": "gradido", + "save-password": true, + "read-only": false, + "configuration": { + "host": "localhost", + "port": "3306", + "url": "jdbc:mariadb://localhost:3306/", + "home": "mysql_client", + "type": "dev", + "auth-model": "native", + "handlers": {} + } + } + }, + "connection-types": { + "dev": { + "name": "Development", + "color": "255,255,255", + "description": "Regular development database", + "auto-commit": true, + "confirm-execute": false, + "confirm-data-change": false, + "auto-close-transactions": false + } + } +} \ No newline at end of file diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 2fb4e2801..0626a5067 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -2,28 +2,6 @@ import Decimal from 'decimal.js-light' import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm' import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' -export enum CycleTypes { - ONCE = 1, - HOUR = 2, - TWOHOURS = 3, - FOURHOURS = 4, - EIGHTHOURS = 5, - HALFDAY = 6, - DAY = 7, - TWODAYS = 8, - THREEDAYS = 9, - FOURDAYS = 10, - FIVEDAYS = 11, - SIXDAYS = 12, - WEEK = 13, - TWOWEEKS = 14, - MONTH = 15, - TWOMONTH = 16, - QUARTER = 17, - HALFYEAR = 18, - YEAR = 19, -} - @Entity('contribution_links') export class ContributionLinks extends BaseEntity { @PrimaryGeneratedColumn('increment', { unsigned: true }) @@ -50,8 +28,8 @@ export class ContributionLinks extends BaseEntity { }) amount: Decimal - @Column({ name: 'cycle', unsigned: true, nullable: false }) - cycle: number + @Column({ length: 12, nullable: false, collation: 'utf8mb4_unicode_ci' }) + cycle: string @Column({ name: 'max_per_cycle', unsigned: true, nullable: false, default: 1 }) maxPerCycle: number diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts index 79bcdf5ce..42f03184b 100644 --- a/database/migrations/0037-add_contribution_links_table.ts +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -15,7 +15,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`valid_from\` datetime NULL, \`valid_to\` datetime NULL, \`amount\` bigint(20) NOT NULL, - \`cycle\` int(10) unsigned NOT NULL DEFAULT '1', + \`cycle\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'NONE', \`max_per_cycle\` int(10) unsigned NOT NULL DEFAULT '1', \`max_amount_per_month\` bigint(20) NULL DEFAULT NULL, \`total_max_count_of_contribution\` int(10) unsigned NULL DEFAULT NULL, From 698f13078e73472186f15651094674e3fef4ff58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Jun 2022 22:14:02 +0200 Subject: [PATCH 35/51] define enum for ContributionLinks cycles --- .../src/graphql/enum/ContributionCycleType.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 backend/src/graphql/enum/ContributionCycleType.ts diff --git a/backend/src/graphql/enum/ContributionCycleType.ts b/backend/src/graphql/enum/ContributionCycleType.ts new file mode 100644 index 000000000..05084a669 --- /dev/null +++ b/backend/src/graphql/enum/ContributionCycleType.ts @@ -0,0 +1,29 @@ +import { registerEnumType } from 'type-graphql' + +export enum ContributionCycleType { + NONE = 'none', + ONCE = 'once', + HOUR = 'hour', + TWO_HOURS = 'two_hours', + FOUR_HOURS = 'four_hours', + EIGHT_HOURS = 'eight_hours', + HALF_DAY = 'half_day', + DAY = 'day', + TWO_DAYS = 'two_days', + THREE_DAYS = 'three_days', + FOUR_DAYS = 'four_days', + FIVE_DAYS = 'five_days', + SIX_DAYS = 'six_days', + WEEK = 'week', + TWO_WEEKS = 'two_weeks', + MONTH = 'month', + TWO_MONTH = 'two_month', + QUARTER = 'quarter', + HALF_YEAR = 'half_year', + YEAR = 'year', +} + +registerEnumType(ContributionCycleType, { + name: 'ContributionCycleType', // this one is mandatory + description: 'Name of the Type of the ContributionCycle', // this one is optional +}) From e71725686c03c2e459081ef90ecd90db5205ffb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Jun 2022 22:21:40 +0200 Subject: [PATCH 36/51] change backend config for db-version 0037 --- 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 28318ed6b..ec469c183 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0036-unique_previous_in_transactions', + DB_VERSION: '0037-add_contribution_links_table/ContributionLinks', 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 a881103c5f70f0e67c394e447436085808309f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 7 Jun 2022 22:52:08 +0200 Subject: [PATCH 37/51] add softdelete feature to contributionlinks --- .../0037-add_contribution_links_table/ContributionLinks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 0626a5067..6539716c6 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -1,5 +1,5 @@ import Decimal from 'decimal.js-light' -import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm' +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } from 'typeorm' import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' @Entity('contribution_links') @@ -75,7 +75,7 @@ export class ContributionLinks extends BaseEntity { @Column({ name: 'created_at', type: 'datetime', nullable: true, default: null }) createdAt: Date | null - @Column({ name: 'deleted_at', type: 'datetime', nullable: true, default: null }) + @DeleteDateColumn() deletedAt: Date | null @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) From 605a6757a35f8600c7df8b311e075ea4a4b750ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 8 Jun 2022 21:32:42 +0200 Subject: [PATCH 38/51] change default cycle-value to ONCE --- database/migrations/0037-add_contribution_links_table.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts index 42f03184b..5e55f4ff1 100644 --- a/database/migrations/0037-add_contribution_links_table.ts +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -15,7 +15,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`valid_from\` datetime NULL, \`valid_to\` datetime NULL, \`amount\` bigint(20) NOT NULL, - \`cycle\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'NONE', + \`cycle\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'ONCE', \`max_per_cycle\` int(10) unsigned NOT NULL DEFAULT '1', \`max_amount_per_month\` bigint(20) NULL DEFAULT NULL, \`total_max_count_of_contribution\` int(10) unsigned NULL DEFAULT NULL, From fd352602ec3ecbed5dcb15bbe9811a519df669fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 8 Jun 2022 21:33:26 +0200 Subject: [PATCH 39/51] delete value NONE from enum --- backend/src/graphql/enum/ContributionCycleType.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/graphql/enum/ContributionCycleType.ts b/backend/src/graphql/enum/ContributionCycleType.ts index 05084a669..5fe494a02 100644 --- a/backend/src/graphql/enum/ContributionCycleType.ts +++ b/backend/src/graphql/enum/ContributionCycleType.ts @@ -1,7 +1,6 @@ import { registerEnumType } from 'type-graphql' export enum ContributionCycleType { - NONE = 'none', ONCE = 'once', HOUR = 'hour', TWO_HOURS = 'two_hours', From 114465c23490b985848f359d0f86e4f4935b8cc3 Mon Sep 17 00:00:00 2001 From: clauspeterhuebner <86960882+clauspeterhuebner@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:24:22 +0200 Subject: [PATCH 40/51] Update backend/src/config/index.ts Co-authored-by: Moriz Wahl --- 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 ec469c183..f4999c4a8 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0037-add_contribution_links_table/ContributionLinks', + DB_VERSION: '0037-add_contribution_links_table', 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 b65aa5cefccbf315844c4820fd03f7b869362933 Mon Sep 17 00:00:00 2001 From: clauspeterhuebner <86960882+clauspeterhuebner@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:26:30 +0200 Subject: [PATCH 41/51] Update database/entity/0037-add_contribution_links_table/ContributionLinks.ts Co-authored-by: Moriz Wahl --- .../0037-add_contribution_links_table/ContributionLinks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 6539716c6..fde67eef3 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -72,8 +72,8 @@ export class ContributionLinks extends BaseEntity { }) minGapHours: number | null - @Column({ name: 'created_at', type: 'datetime', nullable: true, default: null }) - createdAt: Date | null + @Column({ name: 'created_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) + createdAt: Date @DeleteDateColumn() deletedAt: Date | null From 83c66d052a969cab0c1af0a7ecc2823adf8ab8ec Mon Sep 17 00:00:00 2001 From: clauspeterhuebner <86960882+clauspeterhuebner@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:27:54 +0200 Subject: [PATCH 42/51] Update database/entity/0037-add_contribution_links_table/ContributionLinks.ts Co-authored-by: Moriz Wahl --- .../0037-add_contribution_links_table/ContributionLinks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index fde67eef3..16500b06b 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -81,6 +81,6 @@ export class ContributionLinks extends BaseEntity { @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) code: string - @Column({ name: 'link_enabled', type: 'boolean', nullable: true, default: null }) - linkEnabled: boolean | null + @Column({ name: 'link_enabled', type: 'boolean', default: true }) + linkEnabled: boolean } From 3328c200d8d067d2e727495e6a727f65a6c791ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 22:28:56 +0200 Subject: [PATCH 43/51] rework PR comments --- .gitignore | 1 + database/migrations/0037-add_contribution_links_table.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6ac3a32c2..ced6746aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.log +*.bak /node_modules/* messages.pot nbproject diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts index 5e55f4ff1..4d3527ef5 100644 --- a/database/migrations/0037-add_contribution_links_table.ts +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -24,7 +24,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`created_at\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, \`deleted_at\` datetime NULL DEFAULT NULL, \`code\` varchar(24) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, - \`link_enabled\` tinyint(4) NOT NULL DEFAULT '0', + \`link_enabled\` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (\`id\`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`) } From e76817ebdbde036eaad068743d1edff60d704819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 22:55:52 +0200 Subject: [PATCH 44/51] column validFrom NOT NULL --- database/migrations/0037-add_contribution_links_table.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/0037-add_contribution_links_table.ts b/database/migrations/0037-add_contribution_links_table.ts index 4d3527ef5..e05bfd5e7 100644 --- a/database/migrations/0037-add_contribution_links_table.ts +++ b/database/migrations/0037-add_contribution_links_table.ts @@ -12,7 +12,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`id\` int(10) unsigned NOT NULL AUTO_INCREMENT, \`name\` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, \`decsription\` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - \`valid_from\` datetime NULL, + \`valid_from\` datetime NOT NULL, \`valid_to\` datetime NULL, \`amount\` bigint(20) NOT NULL, \`cycle\` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'ONCE', From 94a48173e0f023b5b1f371678572ef293e5ae52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 23:20:05 +0200 Subject: [PATCH 45/51] remove *.bak files from repo Merge remote-tracking branch 'origin/1920-feature-create-contribution-link-table' into 1920-feature-create-contribution-link-table --- .dbeaver/.credentials-config.json.bak | 2 -- .dbeaver/.data-sources.json.bak | 33 --------------------------- 2 files changed, 35 deletions(-) delete mode 100644 .dbeaver/.credentials-config.json.bak delete mode 100644 .dbeaver/.data-sources.json.bak diff --git a/.dbeaver/.credentials-config.json.bak b/.dbeaver/.credentials-config.json.bak deleted file mode 100644 index 2eca1988d..000000000 --- a/.dbeaver/.credentials-config.json.bak +++ /dev/null @@ -1,2 +0,0 @@ -'U[V$8%kQN, -`W-T3NvU{ɆHK~,DXpX.g/:?B9|GZn>/ \ No newline at end of file diff --git a/.dbeaver/.data-sources.json.bak b/.dbeaver/.data-sources.json.bak deleted file mode 100644 index 7d9528f01..000000000 --- a/.dbeaver/.data-sources.json.bak +++ /dev/null @@ -1,33 +0,0 @@ -{ - "folders": {}, - "connections": { - "mariaDB-1813fbbc7bc-107c0b3aeaeb91ab": { - "provider": "mysql", - "driver": "mariaDB", - "name": "gradido", - "save-password": true, - "read-only": false, - "configuration": { - "host": "localhost", - "port": "3306", - "database": "gradido", - "url": "jdbc:mariadb://localhost:3306/gradido", - "home": "mysql_client", - "type": "dev", - "auth-model": "native", - "handlers": {} - } - } - }, - "connection-types": { - "dev": { - "name": "Development", - "color": "255,255,255", - "description": "Regular development database", - "auto-commit": true, - "confirm-execute": false, - "confirm-data-change": false, - "auto-close-transactions": false - } - } -} \ No newline at end of file From d7ff6446d994735e1468b18979943099fd4ecc00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 23:52:40 +0200 Subject: [PATCH 46/51] evaluate nullable columns vs entity --- .../ContributionLinks.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts index 16500b06b..7b391606f 100644 --- a/database/entity/0037-add_contribution_links_table/ContributionLinks.ts +++ b/database/entity/0037-add_contribution_links_table/ContributionLinks.ts @@ -11,10 +11,10 @@ export class ContributionLinks extends BaseEntity { name: string @Column({ length: 255, nullable: false, collation: 'utf8mb4_unicode_ci' }) - description: string + memo: string - @Column({ name: 'valid_from', type: 'datetime', nullable: true, default: null }) - validFrom: Date | null + @Column({ name: 'valid_from', type: 'datetime', nullable: false }) + validFrom: Date @Column({ name: 'valid_to', type: 'datetime', nullable: true, default: null }) validTo: Date | null @@ -43,7 +43,7 @@ export class ContributionLinks extends BaseEntity { default: null, transformer: DecimalTransformer, }) - maxAmountPerMonth: Decimal + maxAmountPerMonth: Decimal | null @Column({ name: 'total_max_count_of_contribution', @@ -62,7 +62,7 @@ export class ContributionLinks extends BaseEntity { default: null, transformer: DecimalTransformer, }) - maxAccountBalance: Decimal + maxAccountBalance: Decimal | null @Column({ name: 'min_gap_hours', @@ -79,7 +79,7 @@ export class ContributionLinks extends BaseEntity { deletedAt: Date | null @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) - code: string + code: string | null @Column({ name: 'link_enabled', type: 'boolean', default: true }) linkEnabled: boolean From 8a0147c8117f38d23f3c02b29ff0bf81858370b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 9 Jun 2022 23:54:06 +0200 Subject: [PATCH 47/51] shift enum in ticket #1921 --- .../src/graphql/enum/ContributionCycleType.ts | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 backend/src/graphql/enum/ContributionCycleType.ts diff --git a/backend/src/graphql/enum/ContributionCycleType.ts b/backend/src/graphql/enum/ContributionCycleType.ts deleted file mode 100644 index 5fe494a02..000000000 --- a/backend/src/graphql/enum/ContributionCycleType.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { registerEnumType } from 'type-graphql' - -export enum ContributionCycleType { - ONCE = 'once', - HOUR = 'hour', - TWO_HOURS = 'two_hours', - FOUR_HOURS = 'four_hours', - EIGHT_HOURS = 'eight_hours', - HALF_DAY = 'half_day', - DAY = 'day', - TWO_DAYS = 'two_days', - THREE_DAYS = 'three_days', - FOUR_DAYS = 'four_days', - FIVE_DAYS = 'five_days', - SIX_DAYS = 'six_days', - WEEK = 'week', - TWO_WEEKS = 'two_weeks', - MONTH = 'month', - TWO_MONTH = 'two_month', - QUARTER = 'quarter', - HALF_YEAR = 'half_year', - YEAR = 'year', -} - -registerEnumType(ContributionCycleType, { - name: 'ContributionCycleType', // this one is mandatory - description: 'Name of the Type of the ContributionCycle', // this one is optional -}) From 5121910c836dfe975a93487d1eaf181a43401245 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 12:03:15 +0200 Subject: [PATCH 48/51] rename ContributionLinks to ContributionLink, add CL entity to index --- .../0038-add_contribution_links_table/ContributionLink.ts | 2 +- database/entity/ContributionLink.ts | 2 +- database/entity/ContributionLinks.ts | 1 + database/entity/index.ts | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 database/entity/ContributionLinks.ts diff --git a/database/entity/0038-add_contribution_links_table/ContributionLink.ts b/database/entity/0038-add_contribution_links_table/ContributionLink.ts index 7b391606f..490ca3868 100644 --- a/database/entity/0038-add_contribution_links_table/ContributionLink.ts +++ b/database/entity/0038-add_contribution_links_table/ContributionLink.ts @@ -3,7 +3,7 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' @Entity('contribution_links') -export class ContributionLinks extends BaseEntity { +export class ContributionLink extends BaseEntity { @PrimaryGeneratedColumn('increment', { unsigned: true }) id: number diff --git a/database/entity/ContributionLink.ts b/database/entity/ContributionLink.ts index de26c1c4a..721dfd2b3 100644 --- a/database/entity/ContributionLink.ts +++ b/database/entity/ContributionLink.ts @@ -1 +1 @@ -export { ContributionLinks } from './0037-add_contribution_links_table/ContributionLinks' +export { ContributionLinks } from './0038-add_contribution_links_table/ContributionLinks' diff --git a/database/entity/ContributionLinks.ts b/database/entity/ContributionLinks.ts new file mode 100644 index 000000000..c7e4e2b7e --- /dev/null +++ b/database/entity/ContributionLinks.ts @@ -0,0 +1 @@ +export { ContributionLink } from './0038-add_contribution_links_table/ContributionLink' diff --git a/database/entity/index.ts b/database/entity/index.ts index 46d9ef31a..991e482e9 100644 --- a/database/entity/index.ts +++ b/database/entity/index.ts @@ -1,3 +1,4 @@ +import { ContributionLink } from './ContributionLink' import { LoginElopageBuys } from './LoginElopageBuys' import { LoginEmailOptIn } from './LoginEmailOptIn' import { Migration } from './Migration' @@ -8,6 +9,7 @@ import { AdminPendingCreation } from './AdminPendingCreation' export const entities = [ AdminPendingCreation, + ContributionLink, LoginElopageBuys, LoginEmailOptIn, Migration, From 83c8f9731e87749de795968905b45287f3bb2981 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 12:05:13 +0200 Subject: [PATCH 49/51] remove duplicate file --- database/entity/ContributionLink.ts | 2 +- database/entity/ContributionLinks.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 database/entity/ContributionLinks.ts diff --git a/database/entity/ContributionLink.ts b/database/entity/ContributionLink.ts index 721dfd2b3..c7e4e2b7e 100644 --- a/database/entity/ContributionLink.ts +++ b/database/entity/ContributionLink.ts @@ -1 +1 @@ -export { ContributionLinks } from './0038-add_contribution_links_table/ContributionLinks' +export { ContributionLink } from './0038-add_contribution_links_table/ContributionLink' diff --git a/database/entity/ContributionLinks.ts b/database/entity/ContributionLinks.ts deleted file mode 100644 index c7e4e2b7e..000000000 --- a/database/entity/ContributionLinks.ts +++ /dev/null @@ -1 +0,0 @@ -export { ContributionLink } from './0038-add_contribution_links_table/ContributionLink' From 795d3393981ccead3ab0b4645f0b6266e5e4dbee Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 12:23:57 +0200 Subject: [PATCH 50/51] add type definitions, make code required (not null) --- .../0038-add_contribution_links_table/ContributionLink.ts | 8 +++++--- database/migrations/0038-add_contribution_links_table.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/database/entity/0038-add_contribution_links_table/ContributionLink.ts b/database/entity/0038-add_contribution_links_table/ContributionLink.ts index 490ca3868..496f57d71 100644 --- a/database/entity/0038-add_contribution_links_table/ContributionLink.ts +++ b/database/entity/0038-add_contribution_links_table/ContributionLink.ts @@ -47,6 +47,7 @@ export class ContributionLink extends BaseEntity { @Column({ name: 'total_max_count_of_contribution', + type: 'int', unsigned: true, nullable: true, default: null, @@ -66,6 +67,7 @@ export class ContributionLink extends BaseEntity { @Column({ name: 'min_gap_hours', + type: 'int', unsigned: true, nullable: true, default: null, @@ -75,11 +77,11 @@ export class ContributionLink extends BaseEntity { @Column({ name: 'created_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) createdAt: Date - @DeleteDateColumn() + @DeleteDateColumn({ name: 'deleted_at' }) deletedAt: Date | null - @Column({ length: 24, nullable: true, collation: 'utf8mb4_unicode_ci' }) - code: string | null + @Column({ length: 24, nullable: false, collation: 'utf8mb4_unicode_ci' }) + code: string @Column({ name: 'link_enabled', type: 'boolean', default: true }) linkEnabled: boolean diff --git a/database/migrations/0038-add_contribution_links_table.ts b/database/migrations/0038-add_contribution_links_table.ts index 3ac6821d6..f983644cc 100644 --- a/database/migrations/0038-add_contribution_links_table.ts +++ b/database/migrations/0038-add_contribution_links_table.ts @@ -23,7 +23,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`min_gap_hours\` int(10) unsigned NULL DEFAULT NULL, \`created_at\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, \`deleted_at\` datetime NULL DEFAULT NULL, - \`code\` varchar(24) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, + \`code\` varchar(24) COLLATE utf8mb4_unicode_ci NOT NULL, \`link_enabled\` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (\`id\`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`) From a84f11880f3108d5cb2496a44b5576d78e51cdee Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Jun 2022 12:31:40 +0200 Subject: [PATCH 51/51] rename migration 0037 to what it acutally does --- .../User.ts | 0 database/entity/User.ts | 2 +- ...rop_server_user_table.ts => 0037-drop_user_setting_table.ts} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename database/entity/{0037-drop_server_user_table => 0037-drop_user_setting_table}/User.ts (100%) rename database/migrations/{0037-drop_server_user_table.ts => 0037-drop_user_setting_table.ts} (100%) diff --git a/database/entity/0037-drop_server_user_table/User.ts b/database/entity/0037-drop_user_setting_table/User.ts similarity index 100% rename from database/entity/0037-drop_server_user_table/User.ts rename to database/entity/0037-drop_user_setting_table/User.ts diff --git a/database/entity/User.ts b/database/entity/User.ts index 6983f293b..2d434799e 100644 --- a/database/entity/User.ts +++ b/database/entity/User.ts @@ -1 +1 @@ -export { User } from './0037-drop_server_user_table/User' +export { User } from './0037-drop_user_setting_table/User' diff --git a/database/migrations/0037-drop_server_user_table.ts b/database/migrations/0037-drop_user_setting_table.ts similarity index 100% rename from database/migrations/0037-drop_server_user_table.ts rename to database/migrations/0037-drop_user_setting_table.ts