@riocrypto/common-server 1.0.1443 → 1.0.1444
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { User } from "@riocrypto/common";
|
|
2
2
|
import { Mongoose } from "mongoose";
|
|
3
|
-
export declare const calculateVolumeAndRevenue: (mongoose: Mongoose, startDate: Date, user?: User) => Promise<{
|
|
3
|
+
export declare const calculateVolumeAndRevenue: (mongoose: Mongoose, startDate: Date, endDate: Date, user?: User) => Promise<{
|
|
4
4
|
volume: number;
|
|
5
5
|
revenue: number;
|
|
6
6
|
}>;
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.calculateVolumeAndRevenue = void 0;
|
|
13
13
|
const common_1 = require("@riocrypto/common");
|
|
14
14
|
const order_1 = require("../models/order");
|
|
15
|
-
const calculateVolumeAndRevenue = (mongoose, startDate, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const calculateVolumeAndRevenue = (mongoose, startDate, endDate, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
var _a;
|
|
17
17
|
const Order = (0, order_1.buildOrder)(mongoose);
|
|
18
18
|
let orders;
|
|
@@ -21,21 +21,21 @@ const calculateVolumeAndRevenue = (mongoose, startDate, user) => __awaiter(void
|
|
|
21
21
|
orders = yield Order.find({
|
|
22
22
|
$or: [{ userId: user.id }, { brokerId: user.id }],
|
|
23
23
|
status: common_1.OrderStatus.Complete,
|
|
24
|
-
createdAt: { $gte: startDate },
|
|
24
|
+
createdAt: { $gte: startDate, $lte: endDate },
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
28
|
orders = yield Order.find({
|
|
29
29
|
userId: user.id,
|
|
30
30
|
status: common_1.OrderStatus.Complete,
|
|
31
|
-
createdAt: { $gte: startDate },
|
|
31
|
+
createdAt: { $gte: startDate, $lte: endDate },
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
orders = yield Order.find({
|
|
37
37
|
status: common_1.OrderStatus.Complete,
|
|
38
|
-
createdAt: { $gte: startDate },
|
|
38
|
+
createdAt: { $gte: startDate, $lte: endDate },
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
let volume = 0;
|