mirror of
https://github.com/outline/outline.git
synced 2026-11-30 09:00:18 +03:00
fixes
This commit is contained in:
1 parent
49a09a2840
commit
a760b951d5
2 files changed
+21
-10
No files matched your search
@@ -289,6 +289,7 @@ class Model<
|
||||
},
|
||||
callback: (results: Array<T>, query: FindOptions<T>) => Promise<void>
|
||||
): Promise<number> {
|
||||
let total = 0;
|
||||
const mappedQuery = {
|
||||
...query,
|
||||
offset: query.offset ?? 0,
|
||||
@@ -300,6 +301,7 @@ class Model<
|
||||
do {
|
||||
// @ts-expect-error this T
|
||||
results = await this.findAll<T>(mappedQuery);
|
||||
total += results.length;
|
||||
await callback(results, mappedQuery);
|
||||
mappedQuery.offset += mappedQuery.limit;
|
||||
} while (
|
||||
@@ -307,7 +309,7 @@ class Model<
|
||||
(mappedQuery.totalLimit ?? Infinity) > mappedQuery.offset
|
||||
);
|
||||
|
||||
return mappedQuery.offset;
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Router from "koa-router";
|
||||
import isEmpty from "lodash/isEmpty";
|
||||
import isNil from "lodash/isNil";
|
||||
import isNull from "lodash/isNull";
|
||||
import isUndefined from "lodash/isUndefined";
|
||||
@@ -180,7 +181,10 @@ router.post(
|
||||
const { transaction } = ctx.state;
|
||||
|
||||
const notification = await Notification.findByPk(id, {
|
||||
lock: transaction.LOCK.UPDATE,
|
||||
lock: {
|
||||
level: transaction.LOCK.UPDATE,
|
||||
of: Notification,
|
||||
},
|
||||
rejectOnEmpty: true,
|
||||
transaction,
|
||||
});
|
||||
@@ -229,14 +233,19 @@ router.post(
|
||||
};
|
||||
}
|
||||
|
||||
const total = await Notification.findAllInBatches(
|
||||
{ where },
|
||||
async (results) => {
|
||||
await Promise.all(
|
||||
results.map((notification) => notification.updateWithCtx(ctx, values))
|
||||
);
|
||||
}
|
||||
);
|
||||
let total = 0;
|
||||
if (!isEmpty(values)) {
|
||||
total = await Notification.findAllInBatches(
|
||||
{ where },
|
||||
async (results) => {
|
||||
await Promise.all(
|
||||
results.map((notification) =>
|
||||
notification.updateWithCtx(ctx, values)
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ctx.body = {
|
||||
success: true,
|
||||
|
||||
Reference in new issue
Block a user