@waline/vercel 1.15.1 → 1.15.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waline/vercel",
3
- "version": "1.15.1",
3
+ "version": "1.15.2",
4
4
  "description": "vercel server for waline comment system",
5
5
  "keywords": [
6
6
  "waline",
@@ -264,6 +264,13 @@ module.exports = class extends BaseRest {
264
264
  ...comments.filter(({ rid, sticky }) => !rid && sticky),
265
265
  ...comments.filter(({ rid, sticky }) => !rid && !sticky),
266
266
  ].slice(pageOffset, pageOffset + pageSize);
267
+ const rootIds = {};
268
+ rootComments.forEach(({ objectId }) => {
269
+ rootIds[objectId] = true;
270
+ });
271
+ comments = comments.filter(
272
+ (cmt) => rootIds[cmt.objectId] || rootIds[cmt.rid]
273
+ );
267
274
  } else {
268
275
  rootComments = await this.modelInstance.select(
269
276
  { ...where, rid: undefined },
@@ -139,6 +139,7 @@ module.exports = class extends Base {
139
139
 
140
140
  // todo: query optimize
141
141
  const counts = [];
142
+ const countsPromise = [];
142
143
  for (let i = 0; i < options.group.length; i++) {
143
144
  const groupName = options.group[i];
144
145
  if (!where._complex || !Array.isArray(where._complex[groupName])) {
@@ -157,17 +158,21 @@ module.exports = class extends Base {
157
158
  _complex: undefined,
158
159
  [groupName]: where._complex[groupName][1][j],
159
160
  };
160
- const num = await this.count(groupWhere, {
161
+ const countPromise = this.count(groupWhere, {
161
162
  ...options,
162
163
  group: undefined,
164
+ }).then((num) => {
165
+ counts.push({
166
+ ...groupFlatValue,
167
+ [groupName]: where._complex[groupName][1][j],
168
+ count: num,
169
+ });
163
170
  });
164
- counts.push({
165
- ...groupFlatValue,
166
- [groupName]: where._complex[groupName][1][j],
167
- count: num,
168
- });
171
+ countsPromise.push(countPromise);
169
172
  }
170
173
  }
174
+
175
+ await Promise.all(countsPromise);
171
176
  return counts;
172
177
  }
173
178