@chevre/domain 22.11.0-alpha.2 → 22.11.0-alpha.3
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.
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const formatter = new Intl.NumberFormat('ja-JP');
|
|
7
|
+
|
|
8
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
let startTime: [number, number] = process.hrtime();
|
|
12
|
+
let diff: [number, number] = process.hrtime(startTime);
|
|
13
|
+
|
|
14
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
15
|
+
|
|
16
|
+
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
17
|
+
|
|
18
|
+
startTime = process.hrtime();
|
|
19
|
+
const result = await acceptedOfferRepo.searchWithUnwoundAcceptedOffers(
|
|
20
|
+
{
|
|
21
|
+
project: { id: { $eq: project.id } },
|
|
22
|
+
limit: 20,
|
|
23
|
+
page: 12,
|
|
24
|
+
sort: {
|
|
25
|
+
orderDate: chevre.factory.sortType.Descending
|
|
26
|
+
},
|
|
27
|
+
orderStatuses: [chevre.factory.orderStatus.OrderDelivered],
|
|
28
|
+
orderDate: {
|
|
29
|
+
$gte: new Date('2025-06-07T15:00:00.000Z'),
|
|
30
|
+
$lte: new Date('2025-07-08T01:42:34.654Z')
|
|
31
|
+
},
|
|
32
|
+
acceptedOffers: {
|
|
33
|
+
itemOffered: {
|
|
34
|
+
issuedThrough: { typeOf: { $eq: chevre.factory.product.ProductType.EventService } },
|
|
35
|
+
reservationFor: {
|
|
36
|
+
inSessionFrom: new Date('2025-07-07T15:00:00.000Z'),
|
|
37
|
+
inSessionThrough: new Date('2025-07-08T15:00:00.000Z'),
|
|
38
|
+
superEvent: {
|
|
39
|
+
location: { branchCodes: ['p006'] }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
seller: { ids: ['62568df4138ef5000b18c8c0'] },
|
|
45
|
+
provider: { id: { $eq: '62568df4138ef5000b18c8c0' } }
|
|
46
|
+
// // req.seller.idを考慮(2023-07-19~)
|
|
47
|
+
// ...(typeof req.seller?.id === 'string') ? { provider: { id: { $eq: req.seller.id } } } : undefined
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
confirmationNumber: 1,
|
|
51
|
+
customer: 1,
|
|
52
|
+
dateReturned: 1,
|
|
53
|
+
orderDate: 1,
|
|
54
|
+
orderNumber: 1,
|
|
55
|
+
orderStatus: 1,
|
|
56
|
+
paymentMethods: 1,
|
|
57
|
+
price: 1,
|
|
58
|
+
priceCurrency: 1,
|
|
59
|
+
project: 1,
|
|
60
|
+
seller: 1
|
|
61
|
+
},
|
|
62
|
+
{ useLimitAfterSkip: false }
|
|
63
|
+
// { useLimitAfterSkip: true }
|
|
64
|
+
);
|
|
65
|
+
diff = process.hrtime(startTime);
|
|
66
|
+
console.log(result.map(({ orderNumber, orderDate }) => `${orderDate} ${orderNumber}`));
|
|
67
|
+
console.log(result.length);
|
|
68
|
+
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
main()
|
|
72
|
+
.then(console.log)
|
|
73
|
+
.catch(console.error);
|
|
@@ -20,7 +20,9 @@ export declare class AcceptedOfferRepo {
|
|
|
20
20
|
/**
|
|
21
21
|
* オファー展開の注文検索
|
|
22
22
|
*/
|
|
23
|
-
searchWithUnwoundAcceptedOffers(params: factory.order.ISearchConditions, projection
|
|
23
|
+
searchWithUnwoundAcceptedOffers(params: factory.order.ISearchConditions, projection: IProjection4searchWithUnwoundAcceptedOffers, options: {
|
|
24
|
+
useLimitAfterSkip: boolean;
|
|
25
|
+
}): Promise<factory.order.IOrder[]>;
|
|
24
26
|
aggreateOwnershipInfosByOrder(filter: {
|
|
25
27
|
orderNumber: {
|
|
26
28
|
$eq: string;
|
|
@@ -24,9 +24,10 @@ class AcceptedOfferRepo {
|
|
|
24
24
|
/**
|
|
25
25
|
* オファー展開の注文検索
|
|
26
26
|
*/
|
|
27
|
-
searchWithUnwoundAcceptedOffers(params, projection) {
|
|
27
|
+
searchWithUnwoundAcceptedOffers(params, projection, options) {
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
var _a;
|
|
30
|
+
const { useLimitAfterSkip } = options;
|
|
30
31
|
const conditions = order_2.OrderRepo.CREATE_MONGO_CONDITIONS(params);
|
|
31
32
|
const aggregate = this.orderModel.aggregate();
|
|
32
33
|
// pipelineの順序に注意
|
|
@@ -43,8 +44,15 @@ class AcceptedOfferRepo {
|
|
|
43
44
|
aggregate.project(Object.assign(Object.assign({}, projection), { acceptedOffers: ['$acceptedOffers'] }));
|
|
44
45
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
45
46
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
// support skip -> limit(2025-07-09~)
|
|
48
|
+
if (useLimitAfterSkip) {
|
|
49
|
+
aggregate.skip(params.limit * (page - 1))
|
|
50
|
+
.limit(params.limit);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
aggregate.limit(params.limit * page)
|
|
54
|
+
.skip(params.limit * (page - 1));
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
57
|
return aggregate
|
|
50
58
|
// .allowDiskUse(true) // false化(2023-11-30~)
|
package/package.json
CHANGED