chore: Synchronizing refactor and small fixes from enterprise codebase (#3634)

* chore: Syncronizing refactor and small fixes from enterprise codebase

* fix
This commit is contained in:
Tom Moor
2022-06-05 00:59:41 -07:00
committed by GitHub
parent 28439d315d
commit ac07724f21
24 changed files with 93 additions and 101 deletions

View File

@@ -1,7 +1,7 @@
import crypto from "crypto";
import { addMinutes, subMinutes } from "date-fns";
import JWT from "jsonwebtoken";
import { Transaction, QueryTypes, FindOptions, Op } from "sequelize";
import { Transaction, QueryTypes, Op } from "sequelize";
import {
Table,
Column,
@@ -536,25 +536,6 @@ class User extends ParanoidModel {
suspended: parseInt(counts.suspendedCount),
};
};
static async findAllInBatches(
query: FindOptions<User>,
callback: (users: Array<User>, query: FindOptions<User>) => Promise<void>
) {
if (!query.offset) {
query.offset = 0;
}
if (!query.limit) {
query.limit = 10;
}
let results;
do {
results = await this.findAll(query);
await callback(results, query);
query.offset += query.limit;
} while (results.length >= query.limit);
}
}
export default User;