@rxdrag/website-lib-core 0.1.2 → 0.1.3

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": "@rxdrag/website-lib-core",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.ts"
@@ -12,14 +12,24 @@ import { ListResult } from "@rxdrag/entify-lib";
12
12
  import { TProduct } from "../view-model";
13
13
  import { queryEntityList } from "./queryEntityList";
14
14
 
15
+ const PAGE_SIZE = 500;
16
+
15
17
  export async function queryAllProducts(envVariables: EnvVariables, langAbbr: string) {
16
- const queryOptions = new ProductQueryOptions(
17
- [ProductFields.id, ProductFields.slug],
18
- {
18
+ const items: TProduct[] = [];
19
+ let offset = 0;
20
+
21
+ while (true) {
22
+ const queryOptions = new ProductQueryOptions([ProductFields.id, ProductFields.slug], {
23
+ offset,
24
+ limit: PAGE_SIZE,
19
25
  where: {
20
26
  [ProductFields.status]: {
21
27
  _eq: PublishableStatus.published,
22
28
  },
29
+ _or: [
30
+ { [ProductFields.isDeleted]: { _eq: false } },
31
+ { [ProductFields.isDeleted]: { _isNull: true } },
32
+ ],
23
33
  lang: {
24
34
  abbr: {
25
35
  _eq: langAbbr,
@@ -27,14 +37,25 @@ export async function queryAllProducts(envVariables: EnvVariables, langAbbr: str
27
37
  },
28
38
  },
29
39
  orderBy: [{ [ProductFields.seqValue]: "asc" }],
40
+ });
41
+
42
+ const result = await queryEntityList<
43
+ Product,
44
+ ProductBoolExp,
45
+ ProductOrderBy,
46
+ ProductDistinctExp
47
+ >(queryOptions, envVariables) as ListResult<TProduct> | undefined;
48
+
49
+ const pageItems = result?.items || [];
50
+ items.push(...pageItems);
51
+
52
+ if (pageItems.length < PAGE_SIZE) {
53
+ return {
54
+ ...result,
55
+ items,
56
+ } as ListResult<TProduct>;
30
57
  }
31
- );
32
58
 
33
- const result = await queryEntityList<
34
- Product,
35
- ProductBoolExp,
36
- ProductOrderBy,
37
- ProductDistinctExp
38
- >(queryOptions, envVariables);
39
- return result as ListResult<TProduct> | undefined;
59
+ offset += PAGE_SIZE;
60
+ }
40
61
  }