@coopenomics/parser 2.2.9 → 2025.5.2

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/dist/index.cjs CHANGED
@@ -105,20 +105,19 @@ class Database {
105
105
  const pipeline = [
106
106
  { $match: filter },
107
107
  { $sort: { block_num: -1 } },
108
- // Сортировка по primary_key и block_num
109
108
  { $group: { _id: "$primary_key", doc: { $first: "$$ROOT" } } },
110
109
  { $replaceRoot: { newRoot: "$doc" } },
111
110
  { $sort: { block_num: -1 } },
112
111
  { $skip: (page - 1) * limit },
113
- // Применяется внутри пайплайна
114
112
  { $limit: limit }
115
- // Применяется внутри пайплайна
116
113
  ];
117
114
  const result = await this.deltas.aggregate(pipeline).toArray();
115
+ const total = await this.deltas.distinct("primary_key", filter || {}).then((arr) => arr.length);
118
116
  return {
119
117
  results: result,
120
118
  page,
121
- limit
119
+ limit,
120
+ total
122
121
  };
123
122
  }
124
123
  async getActions(filter, page = 1, limit = 10) {
@@ -128,17 +127,18 @@ class Database {
128
127
  const result = await this.actions.aggregate([
129
128
  { $match: query },
130
129
  { $sort: { block_num: -1 } },
131
- // Сортировка по primary_key и block_num
132
130
  { $group: { _id: "$global_sequence", doc: { $first: "$$ROOT" } } },
133
131
  { $replaceRoot: { newRoot: "$doc" } },
134
132
  { $sort: { block_num: -1 } },
135
133
  { $skip: (page - 1) * limit },
136
134
  { $limit: limit }
137
135
  ]).toArray();
136
+ const total = await this.actions.distinct("global_sequence", query).then((arr) => arr.length);
138
137
  return {
139
138
  results: result,
140
139
  page,
141
- limit
140
+ limit,
141
+ total
142
142
  };
143
143
  }
144
144
  async getAction(filter) {
package/dist/index.mjs CHANGED
@@ -96,20 +96,19 @@ class Database {
96
96
  const pipeline = [
97
97
  { $match: filter },
98
98
  { $sort: { block_num: -1 } },
99
- // Сортировка по primary_key и block_num
100
99
  { $group: { _id: "$primary_key", doc: { $first: "$$ROOT" } } },
101
100
  { $replaceRoot: { newRoot: "$doc" } },
102
101
  { $sort: { block_num: -1 } },
103
102
  { $skip: (page - 1) * limit },
104
- // Применяется внутри пайплайна
105
103
  { $limit: limit }
106
- // Применяется внутри пайплайна
107
104
  ];
108
105
  const result = await this.deltas.aggregate(pipeline).toArray();
106
+ const total = await this.deltas.distinct("primary_key", filter || {}).then((arr) => arr.length);
109
107
  return {
110
108
  results: result,
111
109
  page,
112
- limit
110
+ limit,
111
+ total
113
112
  };
114
113
  }
115
114
  async getActions(filter, page = 1, limit = 10) {
@@ -119,17 +118,18 @@ class Database {
119
118
  const result = await this.actions.aggregate([
120
119
  { $match: query },
121
120
  { $sort: { block_num: -1 } },
122
- // Сортировка по primary_key и block_num
123
121
  { $group: { _id: "$global_sequence", doc: { $first: "$$ROOT" } } },
124
122
  { $replaceRoot: { newRoot: "$doc" } },
125
123
  { $sort: { block_num: -1 } },
126
124
  { $skip: (page - 1) * limit },
127
125
  { $limit: limit }
128
126
  ]).toArray();
127
+ const total = await this.actions.distinct("global_sequence", query).then((arr) => arr.length);
129
128
  return {
130
129
  results: result,
131
130
  page,
132
- limit
131
+ limit,
132
+ total
133
133
  };
134
134
  }
135
135
  async getAction(filter) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coopenomics/parser",
3
3
  "type": "module",
4
- "version": "2.2.9",
4
+ "version": "2025.5.2",
5
5
  "private": false,
6
6
  "packageManager": "pnpm@9.0.6",
7
7
  "description": "",
@@ -85,5 +85,5 @@
85
85
  "vite": "^5.2.10",
86
86
  "vitest": "^1.5.2"
87
87
  },
88
- "gitHead": "51d736eba49ce8aaea6e58c40772254c0c194f46"
88
+ "gitHead": "b930543c2bd9a67214210dd1909d535816f1ec8f"
89
89
  }