@stamhoofd/backend 2.109.0 → 2.110.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stamhoofd/backend",
3
- "version": "2.109.0",
3
+ "version": "2.110.0",
4
4
  "main": "./dist/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -51,14 +51,14 @@
51
51
  "@simonbackx/simple-encoding": "2.22.0",
52
52
  "@simonbackx/simple-endpoints": "1.20.1",
53
53
  "@simonbackx/simple-logging": "^1.0.1",
54
- "@stamhoofd/backend-i18n": "2.109.0",
55
- "@stamhoofd/backend-middleware": "2.109.0",
56
- "@stamhoofd/email": "2.109.0",
57
- "@stamhoofd/models": "2.109.0",
58
- "@stamhoofd/queues": "2.109.0",
59
- "@stamhoofd/sql": "2.109.0",
60
- "@stamhoofd/structures": "2.109.0",
61
- "@stamhoofd/utility": "2.109.0",
54
+ "@stamhoofd/backend-i18n": "2.110.0",
55
+ "@stamhoofd/backend-middleware": "2.110.0",
56
+ "@stamhoofd/email": "2.110.0",
57
+ "@stamhoofd/models": "2.110.0",
58
+ "@stamhoofd/queues": "2.110.0",
59
+ "@stamhoofd/sql": "2.110.0",
60
+ "@stamhoofd/structures": "2.110.0",
61
+ "@stamhoofd/utility": "2.110.0",
62
62
  "archiver": "^7.0.1",
63
63
  "axios": "^1.13.2",
64
64
  "cookie": "^0.7.0",
@@ -76,5 +76,5 @@
76
76
  "publishConfig": {
77
77
  "access": "public"
78
78
  },
79
- "gitHead": "9a987df4a751f24aabd56e1480dfb9239fb8e019"
79
+ "gitHead": "b43604081c29f7d909dac1b47a2d1633b66670e5"
80
80
  }
@@ -150,10 +150,10 @@ describe('migration.document-update-year', () => {
150
150
  const updatedDocument3 = await DocumentTemplate.getByID(document3.id);
151
151
 
152
152
  // take most frequent year and prefer date of document creation
153
- expect(updatedDocument1?.year).toBe(2021);
153
+ expect(updatedDocument1?.year).toBe(2020);
154
154
  // should take 2020 because document was created in 2020
155
155
  expect(updatedDocument2?.year).toBe(2020);
156
- expect(updatedDocument3?.year).toBe(2021);
156
+ expect(updatedDocument3?.year).toBe(2020);
157
157
  });
158
158
  });
159
159
 
@@ -28,27 +28,18 @@ export async function migrateDocumentYears() {
28
28
  const yearMap = new Map<number, number>();
29
29
 
30
30
  for (const group of groupModels) {
31
- const startYear = group.settings.startDate.getFullYear();
32
- const endYear = group.settings.endDate.getFullYear();
31
+ const y = group.settings.startDate.getFullYear();
33
32
 
34
- for (let y = startYear; y <= endYear; y++) {
35
- const count = yearMap.get(y) ?? 0;
36
- yearMap.set(y, count + 1);
37
- }
33
+ const count = yearMap.get(y) ?? 0;
34
+ yearMap.set(y, count + 1);
38
35
  }
39
36
 
40
37
  // find the year with the highest count
41
38
  let topYear = 0;
42
39
  let topCount = 0;
43
- const yearBeforeCreation = document.createdAt.getFullYear() - 1;
44
40
 
45
41
  for (const [year, count] of yearMap) {
46
- if (count > topCount
47
- // prefer the year before creation
48
- || (count === topCount && year === yearBeforeCreation)
49
- // next prefer the most recent year
50
- || (topYear !== yearBeforeCreation && year > topYear)
51
- ) {
42
+ if (count > topCount) {
52
43
  topYear = year;
53
44
  topCount = count;
54
45
  }