@stamhoofd/backend 2.7.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.template.json +3 -1
- package/package.json +3 -3
- package/src/crons.ts +3 -3
- package/src/decoders/StringArrayDecoder.ts +24 -0
- package/src/decoders/StringNullableDecoder.ts +18 -0
- package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +14 -0
- package/src/endpoints/global/email/PatchEmailEndpoint.ts +1 -0
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +21 -1
- package/src/endpoints/global/groups/GetGroupsEndpoint.ts +79 -0
- package/src/endpoints/global/members/GetMembersEndpoint.ts +0 -31
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +34 -367
- package/src/endpoints/global/registration/GetUserBalanceEndpoint.ts +3 -3
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +8 -11
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +205 -110
- package/src/endpoints/global/registration-periods/PatchRegistrationPeriodsEndpoint.ts +2 -3
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.ts +20 -23
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.ts +22 -1
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/organization/SetOrganizationDomainEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/payments/GetMemberBalanceEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +3 -40
- package/src/endpoints/organization/dashboard/payments/PatchBalanceItemsEndpoint.ts +22 -37
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +1 -0
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +14 -4
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.ts +12 -2
- package/src/helpers/AdminPermissionChecker.ts +35 -24
- package/src/helpers/AuthenticatedStructures.ts +16 -7
- package/src/helpers/Context.ts +21 -0
- package/src/helpers/EmailResumer.ts +22 -2
- package/src/helpers/MemberUserSyncer.ts +42 -14
- package/src/seeds/1722344160-update-membership.ts +19 -22
- package/src/seeds/1722344161-sync-member-users.ts +60 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Migration } from '@simonbackx/simple-database';
|
|
2
|
+
import { Member } from '@stamhoofd/models';
|
|
3
|
+
import { MemberUserSyncer } from '../helpers/MemberUserSyncer';
|
|
4
|
+
import { logger } from '@simonbackx/simple-logging';
|
|
5
|
+
|
|
6
|
+
export default new Migration(async () => {
|
|
7
|
+
if (STAMHOOFD.environment == "test") {
|
|
8
|
+
console.log("skipped in tests")
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if(STAMHOOFD.userMode !== "platform") {
|
|
13
|
+
console.log("skipped seed update-membership because usermode not platform")
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
process.stdout.write('\n');
|
|
18
|
+
let c = 0;
|
|
19
|
+
let id: string = '';
|
|
20
|
+
|
|
21
|
+
await logger.setContext({tags: ['silent-seed', 'seed']}, async () => {
|
|
22
|
+
while(true) {
|
|
23
|
+
const rawMembers = await Member.where({
|
|
24
|
+
id: {
|
|
25
|
+
value: id,
|
|
26
|
+
sign: '>'
|
|
27
|
+
}
|
|
28
|
+
}, {limit: 500, sort: ['id']});
|
|
29
|
+
|
|
30
|
+
if (rawMembers.length === 0) {
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const membersWithRegistrations = await Member.getBlobByIds(...rawMembers.map(m => m.id));
|
|
35
|
+
|
|
36
|
+
const promises: Promise<any>[] = [];
|
|
37
|
+
|
|
38
|
+
for (const memberWithRegistrations of membersWithRegistrations) {
|
|
39
|
+
promises.push((async () => {
|
|
40
|
+
await MemberUserSyncer.onChangeMember(memberWithRegistrations);
|
|
41
|
+
c++;
|
|
42
|
+
|
|
43
|
+
if (c%1000 === 0) {
|
|
44
|
+
process.stdout.write('.');
|
|
45
|
+
}
|
|
46
|
+
if (c%10000 === 0) {
|
|
47
|
+
process.stdout.write('\n');
|
|
48
|
+
}
|
|
49
|
+
})());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
await Promise.all(promises);
|
|
53
|
+
id = rawMembers[rawMembers.length - 1].id;
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
// Do something here
|
|
59
|
+
return Promise.resolve()
|
|
60
|
+
})
|