@stamhoofd/backend 2.122.4 → 2.122.5
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend",
|
|
3
|
-
"version": "2.122.
|
|
3
|
+
"version": "2.122.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -57,20 +57,20 @@
|
|
|
57
57
|
"@simonbackx/simple-endpoints": "1.21.1",
|
|
58
58
|
"@simonbackx/simple-errors": "1.5.0",
|
|
59
59
|
"@simonbackx/simple-logging": "1.0.1",
|
|
60
|
-
"@stamhoofd/backend-env": "2.122.
|
|
61
|
-
"@stamhoofd/backend-i18n": "2.122.
|
|
62
|
-
"@stamhoofd/backend-middleware": "2.122.
|
|
63
|
-
"@stamhoofd/crons": "2.122.
|
|
64
|
-
"@stamhoofd/email": "2.122.
|
|
65
|
-
"@stamhoofd/excel-writer": "2.122.
|
|
66
|
-
"@stamhoofd/logging": "2.122.
|
|
67
|
-
"@stamhoofd/models": "2.122.
|
|
68
|
-
"@stamhoofd/object-differ": "2.122.
|
|
69
|
-
"@stamhoofd/queues": "2.122.
|
|
70
|
-
"@stamhoofd/sql": "2.122.
|
|
71
|
-
"@stamhoofd/structures": "2.122.
|
|
72
|
-
"@stamhoofd/types": "2.122.
|
|
73
|
-
"@stamhoofd/utility": "2.122.
|
|
60
|
+
"@stamhoofd/backend-env": "2.122.5",
|
|
61
|
+
"@stamhoofd/backend-i18n": "2.122.5",
|
|
62
|
+
"@stamhoofd/backend-middleware": "2.122.5",
|
|
63
|
+
"@stamhoofd/crons": "2.122.5",
|
|
64
|
+
"@stamhoofd/email": "2.122.5",
|
|
65
|
+
"@stamhoofd/excel-writer": "2.122.5",
|
|
66
|
+
"@stamhoofd/logging": "2.122.5",
|
|
67
|
+
"@stamhoofd/models": "2.122.5",
|
|
68
|
+
"@stamhoofd/object-differ": "2.122.5",
|
|
69
|
+
"@stamhoofd/queues": "2.122.5",
|
|
70
|
+
"@stamhoofd/sql": "2.122.5",
|
|
71
|
+
"@stamhoofd/structures": "2.122.5",
|
|
72
|
+
"@stamhoofd/types": "2.122.5",
|
|
73
|
+
"@stamhoofd/utility": "2.122.5",
|
|
74
74
|
"archiver": "7.0.1",
|
|
75
75
|
"axios": "1.16.0",
|
|
76
76
|
"base-x": "3.0.11",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"stripe": "16.12.0"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
|
-
"@stamhoofd/test-utils": "2.122.
|
|
94
|
+
"@stamhoofd/test-utils": "2.122.5",
|
|
95
95
|
"@types/cookie": "0.6.0",
|
|
96
96
|
"@types/luxon": "3.7.1",
|
|
97
97
|
"@types/mailparser": "3.4.6",
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
"publishConfig": {
|
|
108
108
|
"access": "public"
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "40acfe8ac1f49010b416f0a9c264531281f0d93a"
|
|
111
111
|
}
|
package/src/seeds/{1780665428-group-update-occupancy.ts → 1782218615-group-update-occupancy.ts}
RENAMED
|
@@ -3,13 +3,18 @@ import { Group } from '@stamhoofd/models';
|
|
|
3
3
|
import { SeedTools } from '../helpers/SeedTools.js';
|
|
4
4
|
|
|
5
5
|
export default new Migration(async () => {
|
|
6
|
-
if (STAMHOOFD.environment
|
|
6
|
+
if (STAMHOOFD.environment === 'test') {
|
|
7
7
|
console.log('skipped in tests');
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
if (STAMHOOFD.userMode
|
|
12
|
-
console.log('skipped seed group-update-occupancy because usermode
|
|
11
|
+
if (STAMHOOFD.userMode === 'platform') {
|
|
12
|
+
console.log('skipped seed group-update-occupancy because usermode is platform');
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (STAMHOOFD.platformName.toLowerCase() !== 'stamhoofd') {
|
|
17
|
+
console.log('skipped for platform (only runs for Stamhoofd): ' + STAMHOOFD.platformName);
|
|
13
18
|
return;
|
|
14
19
|
}
|
|
15
20
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Migration } from '@simonbackx/simple-database';
|
|
2
|
+
import { Group, Organization, RegistrationPeriod } from '@stamhoofd/models';
|
|
3
|
+
import { GroupSettings, GroupType, TranslatedString, WaitingListType } from '@stamhoofd/structures';
|
|
4
|
+
import { SeedTools } from '../helpers/SeedTools.js';
|
|
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.platformName.toLowerCase() !== 'stamhoofd') {
|
|
13
|
+
console.log('skipped for platform (only runs for Stamhoofd): ' + STAMHOOFD.platformName);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const dryRun = false;
|
|
18
|
+
await start(dryRun);
|
|
19
|
+
|
|
20
|
+
if (dryRun) {
|
|
21
|
+
throw new Error('Migration did not finish because of dryRun');
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
async function start(dryRun: boolean) {
|
|
26
|
+
await SeedTools.loop({
|
|
27
|
+
query: Organization.select(),
|
|
28
|
+
batchSize: 50,
|
|
29
|
+
useTransactionPerBatch: true,
|
|
30
|
+
action: async (organization: Organization) => {
|
|
31
|
+
const groups: Group[] = await Group.select()
|
|
32
|
+
.where('organizationId', organization.id)
|
|
33
|
+
// only for current period
|
|
34
|
+
.where('periodId', organization.periodId)
|
|
35
|
+
.where('type', GroupType.Membership)
|
|
36
|
+
.fetch();
|
|
37
|
+
|
|
38
|
+
if (groups.length === 0) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// const period = await OrganizationRegistrationPeriod.select().where('organizationId', organization.id).where('periodId', organization.periodId).first(true);
|
|
43
|
+
const period = await RegistrationPeriod.getByID(organization.periodId, true);
|
|
44
|
+
|
|
45
|
+
// handle group permissions
|
|
46
|
+
for (const group of groups) {
|
|
47
|
+
if (group.settings.waitingListType === WaitingListType.None) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (group.waitingListId) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const newWaitingList = await createWaitingList(group, period, dryRun);
|
|
56
|
+
group.waitingListId = newWaitingList.id;
|
|
57
|
+
|
|
58
|
+
if (!dryRun) {
|
|
59
|
+
await group.save();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const cycleIfMigrated = -99;
|
|
68
|
+
|
|
69
|
+
async function createWaitingList(originalGroup: Group, period: RegistrationPeriod, dryRun: boolean) {
|
|
70
|
+
const newWaitingList = new Group();
|
|
71
|
+
newWaitingList.cycle = cycleIfMigrated;
|
|
72
|
+
newWaitingList.type = GroupType.WaitingList;
|
|
73
|
+
newWaitingList.organizationId = originalGroup.organizationId;
|
|
74
|
+
newWaitingList.periodId = period.id;
|
|
75
|
+
newWaitingList.settings = GroupSettings.create({
|
|
76
|
+
name: TranslatedString.create($t(`%yh`) + ' ' + originalGroup.settings.name.toString()),
|
|
77
|
+
period: period.getBaseStructure(),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (!dryRun) {
|
|
81
|
+
await newWaitingList.save();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return newWaitingList;
|
|
85
|
+
}
|