@stamhoofd/backend 2.17.3 → 2.17.4

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.17.3",
3
+ "version": "2.17.4",
4
4
  "main": "./dist/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -60,5 +60,5 @@
60
60
  "postmark": "4.0.2",
61
61
  "stripe": "^16.6.0"
62
62
  },
63
- "gitHead": "9aa2fbb9c268c4c5c45efd68a9dc55f5d48eb621"
63
+ "gitHead": "56f46d516a4a18cffb011caf177b5de9a14607b6"
64
64
  }
@@ -160,7 +160,7 @@ export class ExportToExcelEndpoint extends Endpoint<Params, Query, Body, Respons
160
160
  const writer = new XlsxWriter(zipWriterAdapter);
161
161
 
162
162
  // Limit to pages of 100
163
- request.filter.limit = 100;
163
+ request.filter.limit = STAMHOOFD.environment === 'development' ? 1 : 100; // in development, we need to check if total count matches and pagination is working correctly
164
164
 
165
165
  await exportToExcel({
166
166
  definitions: loader.sheets,
@@ -9,6 +9,8 @@ import { registrationFilterCompilers } from "./registrations";
9
9
  export const memberFilterCompilers: SQLFilterDefinitions = {
10
10
  ...baseSQLFilterCompilers,
11
11
  id: createSQLColumnFilterCompiler('id'),
12
+ firstName: createSQLColumnFilterCompiler('firstName'),
13
+ lastName: createSQLColumnFilterCompiler('lastName'),
12
14
  name: createSQLExpressionFilterCompiler(
13
15
  new SQLConcat(
14
16
  SQL.column('firstName'),
@@ -3,6 +3,14 @@ import { SQL, SQLOrderBy, SQLOrderByDirection, SQLSortDefinitions } from "@stamh
3
3
  import { Formatter } from "@stamhoofd/utility"
4
4
 
5
5
  export const memberSorters: SQLSortDefinitions<MemberWithRegistrations> = {
6
+ // WARNING! TEST NEW SORTERS THOROUGHLY!
7
+ // Try to avoid creating sorters on fields that er not 1:1 with the database, that often causes pagination issues if not thought through
8
+ // An example: sorting on 'name' is not a good idea, because it is a concatenation of two fields.
9
+ // You might be tempted to use ORDER BY firstName, lastName, but that will not work as expected and it needs to be ORDER BY CONCAT(firstName, ' ', lastName)
10
+ // Why? Because ORDER BY firstName, lastName produces a different order dan ORDER BY CONCAT(firstName, ' ', lastName) if there are multiple people with spaces in the first name
11
+ // And that again causes issues with pagination because the next query will append a filter of name > 'John Doe' - causing duplicate and/or skipped results
12
+ // What if you need mapping? simply map the sorters in the frontend: name -> firstname, lastname, age -> birthDay, etc.
13
+
6
14
  'id': {
7
15
  getValue(a) {
8
16
  return a.id
@@ -14,22 +22,26 @@ export const memberSorters: SQLSortDefinitions<MemberWithRegistrations> = {
14
22
  })
15
23
  }
16
24
  },
17
- 'name': {
25
+ 'firstName': {
26
+ getValue(a) {
27
+ return a.firstName
28
+ },
29
+ toSQL: (direction: SQLOrderByDirection): SQLOrderBy => {
30
+ return new SQLOrderBy({
31
+ column: SQL.column('firstName'),
32
+ direction
33
+ })
34
+ }
35
+ },
36
+ 'lastName': {
18
37
  getValue(a) {
19
- // Note: we should not use 'name' here (that will remove the in between space if one is missing), because we need to use Exactly the same value as the filter will use
20
- return a.firstName + ' ' + a.lastName
38
+ return a.lastName
21
39
  },
22
40
  toSQL: (direction: SQLOrderByDirection): SQLOrderBy => {
23
- return SQLOrderBy.combine([
24
- new SQLOrderBy({
25
- column: SQL.column('firstName'),
26
- direction
27
- }),
28
- new SQLOrderBy({
29
- column: SQL.column('lastName'),
30
- direction
31
- })
32
- ])
41
+ return new SQLOrderBy({
42
+ column: SQL.column('lastName'),
43
+ direction
44
+ })
33
45
  }
34
46
  },
35
47
  'birthDay': {
@@ -43,5 +55,4 @@ export const memberSorters: SQLSortDefinitions<MemberWithRegistrations> = {
43
55
  })
44
56
  }
45
57
  }
46
- // Note: never add mapped sortings, that should happen in the frontend -> e.g. map age to birthDay
47
58
  }
@@ -2,6 +2,14 @@ import { Organization } from "@stamhoofd/models"
2
2
  import { SQL, SQLOrderBy, SQLOrderByDirection, SQLSortDefinitions } from "@stamhoofd/sql"
3
3
 
4
4
  export const organizationSorters: SQLSortDefinitions<Organization> = {
5
+ // WARNING! TEST NEW SORTERS THOROUGHLY!
6
+ // Try to avoid creating sorters on fields that er not 1:1 with the database, that often causes pagination issues if not thought through
7
+ // An example: sorting on 'name' is not a good idea, because it is a concatenation of two fields.
8
+ // You might be tempted to use ORDER BY firstName, lastName, but that will not work as expected and it needs to be ORDER BY CONCAT(firstName, ' ', lastName)
9
+ // Why? Because ORDER BY firstName, lastName produces a different order dan ORDER BY CONCAT(firstName, ' ', lastName) if there are multiple people with spaces in the first name
10
+ // And that again causes issues with pagination because the next query will append a filter of name > 'John Doe' - causing duplicate and/or skipped results
11
+ // What if you need mapping? simply map the sorters in the frontend: name -> firstname, lastname, age -> birthDay, etc.
12
+
5
13
  'id': {
6
14
  getValue(a) {
7
15
  return a.id
@@ -3,6 +3,14 @@ import { SQL, SQLOrderBy, SQLOrderByDirection, SQLSortDefinitions } from "@stamh
3
3
  import { Formatter } from "@stamhoofd/utility"
4
4
 
5
5
  export const paymentSorters: SQLSortDefinitions<Payment> = {
6
+ // WARNING! TEST NEW SORTERS THOROUGHLY!
7
+ // Try to avoid creating sorters on fields that er not 1:1 with the database, that often causes pagination issues if not thought through
8
+ // An example: sorting on 'name' is not a good idea, because it is a concatenation of two fields.
9
+ // You might be tempted to use ORDER BY firstName, lastName, but that will not work as expected and it needs to be ORDER BY CONCAT(firstName, ' ', lastName)
10
+ // Why? Because ORDER BY firstName, lastName produces a different order dan ORDER BY CONCAT(firstName, ' ', lastName) if there are multiple people with spaces in the first name
11
+ // And that again causes issues with pagination because the next query will append a filter of name > 'John Doe' - causing duplicate and/or skipped results
12
+ // What if you need mapping? simply map the sorters in the frontend: name -> firstname, lastname, age -> birthDay, etc.
13
+
6
14
  'id': {
7
15
  getValue(a) {
8
16
  return a.id