aboutsummaryrefslogtreecommitdiffstats
path: root/lib/utils.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-06-08 13:04:02 -0700
committerAdam Soltys <[email protected]>2020-06-08 13:04:02 -0700
commit7a3a07bc711ea57fd8a84e809e7ecd0d6e64b5c2 (patch)
treeb31a06affa4b932990744997c271f6d65502d60c /lib/utils.js
parent298672d3f50938ba06a16f8e04d607b7033703b8 (diff)
downloadcoinos-server-7a3a07bc711ea57fd8a84e809e7ecd0d6e64b5c2.tar.gz
coinos-server-7a3a07bc711ea57fd8a84e809e7ecd0d6e64b5c2.zip
reduce network traffic
Diffstat (limited to 'lib/utils.js')
-rw-r--r--lib/utils.js65
1 files changed, 1 insertions, 64 deletions
diff --git a/lib/utils.js b/lib/utils.js
index 5674f2fc..17b5d134 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -6,10 +6,6 @@ getUser = async (username, transaction) => {
include: [
{
model: db.Account,
- as: "accounts"
- },
- {
- model: db.Account,
as: "account"
}
],
@@ -24,34 +20,6 @@ getUser = async (username, transaction) => {
let user = await db.User.findOne(params);
if (!user) throw new Error("User not found");
- user = user.get({ plain: true });
-
- params = {
- order: [["id", "DESC"]],
- where: {
- user_id: user.id,
- account_id: user.account_id,
- [Op.or]: {
- received: true,
- amount: {
- [Op.lt]: 0
- }
- }
- },
- limit: 12,
- include: {
- model: db.Account,
- as: "account"
- }
- };
-
- if (transaction) {
- params.lock = transaction.LOCK.UPDATE;
- params.transaction = transaction;
- }
-
- user.payments = await db.Payment.findAll(params);
-
return user;
};
@@ -60,10 +28,6 @@ getUserById = async (id, transaction) => {
include: [
{
model: db.Account,
- as: "accounts"
- },
- {
- model: db.Account,
as: "account"
}
],
@@ -76,34 +40,7 @@ getUserById = async (id, transaction) => {
}
let user = await db.User.findOne(params);
-
- user = user.get({ plain: true });
-
- params = {
- order: [["id", "DESC"]],
- where: {
- user_id: user.id,
- account_id: user.account_id,
- [Op.or]: {
- received: true,
- amount: {
- [Op.lt]: 0
- }
- }
- },
- limit: 12,
- include: {
- model: db.Account,
- as: "account"
- }
- };
-
- if (transaction) {
- params.lock = transaction.LOCK.UPDATE;
- params.transaction = transaction;
- }
-
- user.payments = await db.Payment.findAll(params);
+ if (!user) throw new Error("User not found");
return user;
};