@timardex/cluemart-server-shared 1.0.208 → 1.0.210
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.
- package/dist/{chunk-3BUXU7KR.mjs → chunk-7C3KPJ33.mjs} +39 -9
- package/dist/chunk-7C3KPJ33.mjs.map +1 -0
- package/dist/index.cjs +145 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.mjs +142 -42
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +38 -8
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +143 -43
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +9 -10
- package/dist/service/index.d.ts +9 -10
- package/dist/service/index.mjs +105 -35
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-3BUXU7KR.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -711,6 +711,11 @@ declare function updateVendorBasedOnUserLicense(userId: ObjectId, licenceType: E
|
|
|
711
711
|
*/
|
|
712
712
|
declare function convertObjectIdsToStrings(obj: any): any;
|
|
713
713
|
|
|
714
|
+
/**
|
|
715
|
+
* Recomputes dateStatus for every dateTime slot on events and google imported markets.
|
|
716
|
+
*/
|
|
717
|
+
declare function updateAllEventDateTimeStatuses(): Promise<void>;
|
|
718
|
+
|
|
714
719
|
type EventOrMarket = Pick<EventListItemType, "_id" | "name"> | null;
|
|
715
720
|
/**
|
|
716
721
|
* This function attempts to find an Event or a Google Imported Market by the given resource ID.
|
|
@@ -721,12 +726,6 @@ type EventOrMarket = Pick<EventListItemType, "_id" | "name"> | null;
|
|
|
721
726
|
* @returns A promise that resolves to either an Event or a Google Imported Market object containing _id and name, or null if not found.
|
|
722
727
|
*/
|
|
723
728
|
declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
|
|
724
|
-
/**
|
|
725
|
-
* Updates the dateStatus field for a single DateTimeType object based on the current date/time
|
|
726
|
-
* @param dateTime The date-time object to update
|
|
727
|
-
* @returns A new object with updated dateStatus value
|
|
728
|
-
*/
|
|
729
|
-
declare function updateSingleDateTimeStatus<T extends DateTimeType>(dateTime: T): T;
|
|
730
729
|
|
|
731
730
|
type EventDateSlot = Pick<DateTimeType$1, "startDate" | "startTime">;
|
|
732
731
|
/**
|
|
@@ -740,4 +739,4 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
|
|
|
740
739
|
*/
|
|
741
740
|
declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
|
|
742
741
|
|
|
743
|
-
export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelationType, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, didRemoveAnyEventDates, findEventOrImportedMarketById, locationGeoSchema, locationsSchema, refundPolicySchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses,
|
|
742
|
+
export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelationType, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, didRemoveAnyEventDates, findEventOrImportedMarketById, locationGeoSchema, locationsSchema, refundPolicySchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateVendorBasedOnUserLicense, userLicenseSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -711,6 +711,11 @@ declare function updateVendorBasedOnUserLicense(userId: ObjectId, licenceType: E
|
|
|
711
711
|
*/
|
|
712
712
|
declare function convertObjectIdsToStrings(obj: any): any;
|
|
713
713
|
|
|
714
|
+
/**
|
|
715
|
+
* Recomputes dateStatus for every dateTime slot on events and google imported markets.
|
|
716
|
+
*/
|
|
717
|
+
declare function updateAllEventDateTimeStatuses(): Promise<void>;
|
|
718
|
+
|
|
714
719
|
type EventOrMarket = Pick<EventListItemType, "_id" | "name"> | null;
|
|
715
720
|
/**
|
|
716
721
|
* This function attempts to find an Event or a Google Imported Market by the given resource ID.
|
|
@@ -721,12 +726,6 @@ type EventOrMarket = Pick<EventListItemType, "_id" | "name"> | null;
|
|
|
721
726
|
* @returns A promise that resolves to either an Event or a Google Imported Market object containing _id and name, or null if not found.
|
|
722
727
|
*/
|
|
723
728
|
declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
|
|
724
|
-
/**
|
|
725
|
-
* Updates the dateStatus field for a single DateTimeType object based on the current date/time
|
|
726
|
-
* @param dateTime The date-time object to update
|
|
727
|
-
* @returns A new object with updated dateStatus value
|
|
728
|
-
*/
|
|
729
|
-
declare function updateSingleDateTimeStatus<T extends DateTimeType>(dateTime: T): T;
|
|
730
729
|
|
|
731
730
|
type EventDateSlot = Pick<DateTimeType$1, "startDate" | "startTime">;
|
|
732
731
|
/**
|
|
@@ -740,4 +739,4 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
|
|
|
740
739
|
*/
|
|
741
740
|
declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
|
|
742
741
|
|
|
743
|
-
export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelationType, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, didRemoveAnyEventDates, findEventOrImportedMarketById, locationGeoSchema, locationsSchema, refundPolicySchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses,
|
|
742
|
+
export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelationType, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, didRemoveAnyEventDates, findEventOrImportedMarketById, locationGeoSchema, locationsSchema, refundPolicySchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateVendorBasedOnUserLicense, userLicenseSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -3361,6 +3361,7 @@ var EnumEventDateStatus = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
|
3361
3361
|
EnumEventDateStatus22["ENDED"] = "Ended";
|
|
3362
3362
|
EnumEventDateStatus22["RE_SCHEDULED"] = "Rescheduled";
|
|
3363
3363
|
EnumEventDateStatus22["CANCELED"] = "Canceled";
|
|
3364
|
+
EnumEventDateStatus22["INVALID"] = "Invalid";
|
|
3364
3365
|
return EnumEventDateStatus22;
|
|
3365
3366
|
})(EnumEventDateStatus || {});
|
|
3366
3367
|
var EnumSubscriptionStatus = /* @__PURE__ */ ((EnumSubscriptionStatus22) => {
|
|
@@ -5144,8 +5145,8 @@ var EVENT = gql`
|
|
|
5144
5145
|
${RELATION_DATES_FRAGMENT}
|
|
5145
5146
|
`;
|
|
5146
5147
|
var GET_EVENTS = gql`
|
|
5147
|
-
query getEvents {
|
|
5148
|
-
events {
|
|
5148
|
+
query getEvents($dateStatus: EnumEventDateStatus) {
|
|
5149
|
+
events(dateStatus: $dateStatus) {
|
|
5149
5150
|
...EventListItemFields
|
|
5150
5151
|
}
|
|
5151
5152
|
}
|
|
@@ -5171,24 +5172,49 @@ var GET_EVENTS_BY_REGION = gql`
|
|
|
5171
5172
|
query getEventsByRegion(
|
|
5172
5173
|
$region: String!
|
|
5173
5174
|
$options: ResourcesByRegionOptions
|
|
5175
|
+
$dateStatus: EnumEventDateStatus
|
|
5174
5176
|
) {
|
|
5175
|
-
eventsByRegion(
|
|
5177
|
+
eventsByRegion(
|
|
5178
|
+
region: $region
|
|
5179
|
+
options: $options
|
|
5180
|
+
dateStatus: $dateStatus
|
|
5181
|
+
) {
|
|
5176
5182
|
...EventListItemFields
|
|
5177
5183
|
}
|
|
5178
5184
|
}
|
|
5179
5185
|
${EVENT_LIST_ITEM}
|
|
5180
5186
|
`;
|
|
5181
5187
|
var SEARCH_EVENTS = gql`
|
|
5182
|
-
query searchEvents(
|
|
5183
|
-
|
|
5188
|
+
query searchEvents(
|
|
5189
|
+
$region: String
|
|
5190
|
+
$search: String
|
|
5191
|
+
$tags: [String]
|
|
5192
|
+
$dateStatus: EnumEventDateStatus
|
|
5193
|
+
) {
|
|
5194
|
+
eventsSearch(
|
|
5195
|
+
region: $region
|
|
5196
|
+
search: $search
|
|
5197
|
+
tags: $tags
|
|
5198
|
+
dateStatus: $dateStatus
|
|
5199
|
+
) {
|
|
5184
5200
|
...EventListItemFields
|
|
5185
5201
|
}
|
|
5186
5202
|
}
|
|
5187
5203
|
${EVENT_LIST_ITEM}
|
|
5188
5204
|
`;
|
|
5189
5205
|
var GET_EVENTS_NEAR_ME = gql`
|
|
5190
|
-
query getEventsNearMe(
|
|
5191
|
-
|
|
5206
|
+
query getEventsNearMe(
|
|
5207
|
+
$latitude: Float!
|
|
5208
|
+
$longitude: Float!
|
|
5209
|
+
$radius: Int
|
|
5210
|
+
$dateStatus: EnumEventDateStatus
|
|
5211
|
+
) {
|
|
5212
|
+
eventsNearMe(
|
|
5213
|
+
latitude: $latitude
|
|
5214
|
+
longitude: $longitude
|
|
5215
|
+
radius: $radius
|
|
5216
|
+
dateStatus: $dateStatus
|
|
5217
|
+
) {
|
|
5192
5218
|
...EventListItemFields
|
|
5193
5219
|
}
|
|
5194
5220
|
}
|
|
@@ -7861,6 +7887,8 @@ var schema3 = new MongooseSchema7(
|
|
|
7861
7887
|
schema3.index({ "location.geo": "2dsphere" });
|
|
7862
7888
|
schema3.index({ name: 1 });
|
|
7863
7889
|
schema3.index({ region: 1 });
|
|
7890
|
+
schema3.index({ deletedAt: 1 });
|
|
7891
|
+
schema3.index({ "dateTime.dateStatus": 1 });
|
|
7864
7892
|
var GoogleImportedMarketModel = mongoose7.models.GoogleImportedMarket || mongoose7.model("GoogleImportedMarket", schema3);
|
|
7865
7893
|
|
|
7866
7894
|
// src/mongoose/Notification.ts
|
|
@@ -7898,7 +7926,7 @@ schema4.index({ isRead: 1, userId: 1 });
|
|
|
7898
7926
|
schema4.index({ createdAt: -1, userId: 1 });
|
|
7899
7927
|
var NotificationModel = mongoose8.models.Notification || mongoose8.model("Notification", schema4);
|
|
7900
7928
|
|
|
7901
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
7929
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-4SNW63TJ.mjs
|
|
7902
7930
|
var EnumOSPlatform2 = /* @__PURE__ */ ((EnumOSPlatform22) => {
|
|
7903
7931
|
EnumOSPlatform22["ANDROID"] = "android";
|
|
7904
7932
|
EnumOSPlatform22["IOS"] = "ios";
|
|
@@ -8407,6 +8435,8 @@ schema12.index({ region: 1 });
|
|
|
8407
8435
|
schema12.index({ "location.geo": "2dsphere" });
|
|
8408
8436
|
schema12.index({ tags: 1 });
|
|
8409
8437
|
schema12.index({ "associates.email": 1 });
|
|
8438
|
+
schema12.index({ deletedAt: 1 });
|
|
8439
|
+
schema12.index({ "dateTime.dateStatus": 1 });
|
|
8410
8440
|
var EventModel = mongoose16.models.Event || mongoose16.model("Event", schema12);
|
|
8411
8441
|
|
|
8412
8442
|
// src/mongoose/Partner.ts
|
|
@@ -9087,32 +9117,21 @@ function convertObjectIdsToStrings(obj) {
|
|
|
9087
9117
|
return obj;
|
|
9088
9118
|
}
|
|
9089
9119
|
|
|
9090
|
-
// src/service/event.ts
|
|
9120
|
+
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
9091
9121
|
import dayjs2 from "dayjs";
|
|
9092
9122
|
import customParseFormat2 from "dayjs/plugin/customParseFormat";
|
|
9093
9123
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
9094
|
-
import isToday from "dayjs/plugin/isToday";
|
|
9095
|
-
import isTomorrow from "dayjs/plugin/isTomorrow";
|
|
9096
9124
|
dayjs2.extend(customParseFormat2);
|
|
9097
|
-
dayjs2.extend(isToday);
|
|
9098
|
-
dayjs2.extend(isTomorrow);
|
|
9099
9125
|
dayjs2.extend(isoWeek);
|
|
9100
|
-
async function findEventOrImportedMarketById(resourceId) {
|
|
9101
|
-
if (!resourceId) {
|
|
9102
|
-
return null;
|
|
9103
|
-
}
|
|
9104
|
-
const normalizedId = convertObjectIdsToStrings(resourceId);
|
|
9105
|
-
const [eventDoc, googleImportedDoc] = await Promise.all([
|
|
9106
|
-
EventModel.findById(normalizedId).select("_id name").lean().exec(),
|
|
9107
|
-
GoogleImportedMarketModel.findById(normalizedId).select("_id name").lean().exec()
|
|
9108
|
-
]);
|
|
9109
|
-
return eventDoc ?? googleImportedDoc;
|
|
9110
|
-
}
|
|
9111
9126
|
function getFutureEventStatus(startDateTime, now) {
|
|
9112
|
-
|
|
9127
|
+
const hoursUntilStart = startDateTime.diff(now, "hour", true);
|
|
9128
|
+
if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
|
|
9129
|
+
return EnumEventDateStatus.STARTING_SOON;
|
|
9130
|
+
}
|
|
9131
|
+
if (startDateTime.isSame(now, "day")) {
|
|
9113
9132
|
return EnumEventDateStatus.TODAY;
|
|
9114
9133
|
}
|
|
9115
|
-
if (startDateTime.
|
|
9134
|
+
if (startDateTime.isSame(now.add(1, "day"), "day")) {
|
|
9116
9135
|
return EnumEventDateStatus.TOMORROW;
|
|
9117
9136
|
}
|
|
9118
9137
|
if (startDateTime.isSame(now, "isoWeek")) {
|
|
@@ -9121,41 +9140,122 @@ function getFutureEventStatus(startDateTime, now) {
|
|
|
9121
9140
|
if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
|
|
9122
9141
|
return EnumEventDateStatus.NEXT_WEEK;
|
|
9123
9142
|
}
|
|
9124
|
-
const hoursUntilStart = startDateTime.diff(now, "hour", true);
|
|
9125
|
-
if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
|
|
9126
|
-
return EnumEventDateStatus.STARTING_SOON;
|
|
9127
|
-
}
|
|
9128
9143
|
return EnumEventDateStatus.UPCOMING;
|
|
9129
9144
|
}
|
|
9130
|
-
function updateSingleDateTimeStatus(dateTime) {
|
|
9131
|
-
const
|
|
9145
|
+
function updateSingleDateTimeStatus(dateTime, now = dayjs2()) {
|
|
9146
|
+
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
|
|
9132
9147
|
const startDateTime = dayjs2(
|
|
9133
9148
|
`${dateTime.startDate} ${dateTime.startTime}`,
|
|
9134
|
-
|
|
9149
|
+
dateTimeFormat,
|
|
9150
|
+
true
|
|
9135
9151
|
);
|
|
9136
9152
|
const endDateTime = dayjs2(
|
|
9137
9153
|
`${dateTime.endDate} ${dateTime.endTime}`,
|
|
9138
|
-
|
|
9154
|
+
dateTimeFormat,
|
|
9155
|
+
true
|
|
9139
9156
|
);
|
|
9140
9157
|
if (!startDateTime.isValid() || !endDateTime.isValid()) {
|
|
9141
9158
|
return {
|
|
9142
9159
|
...dateTime,
|
|
9143
|
-
dateStatus:
|
|
9160
|
+
dateStatus: EnumEventDateStatus.INVALID
|
|
9144
9161
|
};
|
|
9145
9162
|
}
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9163
|
+
if (endDateTime.isBefore(startDateTime)) {
|
|
9164
|
+
return {
|
|
9165
|
+
...dateTime,
|
|
9166
|
+
dateStatus: EnumEventDateStatus.INVALID
|
|
9167
|
+
};
|
|
9168
|
+
}
|
|
9169
|
+
let dateStatus;
|
|
9170
|
+
if (endDateTime.isAfter(now)) {
|
|
9171
|
+
if (startDateTime.isAfter(now)) {
|
|
9172
|
+
dateStatus = getFutureEventStatus(startDateTime, now);
|
|
9173
|
+
} else {
|
|
9174
|
+
dateStatus = EnumEventDateStatus.STARTED;
|
|
9175
|
+
}
|
|
9151
9176
|
} else {
|
|
9152
|
-
dateStatus =
|
|
9177
|
+
dateStatus = EnumEventDateStatus.ENDED;
|
|
9153
9178
|
}
|
|
9154
9179
|
return {
|
|
9155
9180
|
...dateTime,
|
|
9156
9181
|
dateStatus
|
|
9157
9182
|
};
|
|
9158
9183
|
}
|
|
9184
|
+
var dateTimeStatusFilter = {
|
|
9185
|
+
dateTime: { $ne: [], $type: "array" },
|
|
9186
|
+
deletedAt: null
|
|
9187
|
+
};
|
|
9188
|
+
var CURSOR_BATCH_SIZE = 50;
|
|
9189
|
+
function hasDateTimeStatusChanges(stored, updated) {
|
|
9190
|
+
if (stored.length !== updated.length) {
|
|
9191
|
+
return true;
|
|
9192
|
+
}
|
|
9193
|
+
return stored.some(
|
|
9194
|
+
(slot, index) => slot.dateStatus !== updated[index].dateStatus
|
|
9195
|
+
);
|
|
9196
|
+
}
|
|
9197
|
+
async function updateModelDateTimeStatuses(model, now) {
|
|
9198
|
+
let updated = 0;
|
|
9199
|
+
const cursor = model.find(dateTimeStatusFilter).select({ _id: 1, dateTime: 1 }).lean().cursor({ batchSize: CURSOR_BATCH_SIZE });
|
|
9200
|
+
let bulkOps = [];
|
|
9201
|
+
const flushBulkWrites = async () => {
|
|
9202
|
+
if (!bulkOps.length) {
|
|
9203
|
+
return;
|
|
9204
|
+
}
|
|
9205
|
+
await model.bulkWrite(bulkOps);
|
|
9206
|
+
updated += bulkOps.length;
|
|
9207
|
+
bulkOps = [];
|
|
9208
|
+
};
|
|
9209
|
+
try {
|
|
9210
|
+
for await (const doc of cursor) {
|
|
9211
|
+
const dateTime = doc.dateTime.map(
|
|
9212
|
+
(slot) => updateSingleDateTimeStatus(slot, now)
|
|
9213
|
+
);
|
|
9214
|
+
if (!hasDateTimeStatusChanges(doc.dateTime, dateTime)) {
|
|
9215
|
+
continue;
|
|
9216
|
+
}
|
|
9217
|
+
bulkOps.push({
|
|
9218
|
+
updateOne: {
|
|
9219
|
+
filter: { _id: doc._id },
|
|
9220
|
+
update: { $set: { dateTime } }
|
|
9221
|
+
}
|
|
9222
|
+
});
|
|
9223
|
+
if (bulkOps.length >= CURSOR_BATCH_SIZE) {
|
|
9224
|
+
await flushBulkWrites();
|
|
9225
|
+
}
|
|
9226
|
+
}
|
|
9227
|
+
await flushBulkWrites();
|
|
9228
|
+
} finally {
|
|
9229
|
+
await cursor.close().catch(() => void 0);
|
|
9230
|
+
}
|
|
9231
|
+
return updated;
|
|
9232
|
+
}
|
|
9233
|
+
async function updateAllEventDateTimeStatuses() {
|
|
9234
|
+
const now = dayjs2();
|
|
9235
|
+
const [eventCount, marketCount] = await Promise.all([
|
|
9236
|
+
updateModelDateTimeStatuses(EventModel, now),
|
|
9237
|
+
updateModelDateTimeStatuses(
|
|
9238
|
+
GoogleImportedMarketModel,
|
|
9239
|
+
now
|
|
9240
|
+
)
|
|
9241
|
+
]);
|
|
9242
|
+
console.log(
|
|
9243
|
+
`\u2705 Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed`
|
|
9244
|
+
);
|
|
9245
|
+
}
|
|
9246
|
+
|
|
9247
|
+
// src/service/event/findEventOrImportedMarketById.ts
|
|
9248
|
+
async function findEventOrImportedMarketById(resourceId) {
|
|
9249
|
+
if (!resourceId) {
|
|
9250
|
+
return null;
|
|
9251
|
+
}
|
|
9252
|
+
const normalizedId = convertObjectIdsToStrings(resourceId);
|
|
9253
|
+
const [eventDoc, googleImportedDoc] = await Promise.all([
|
|
9254
|
+
EventModel.findById(normalizedId).select("_id name").lean().exec(),
|
|
9255
|
+
GoogleImportedMarketModel.findById(normalizedId).select("_id name").lean().exec()
|
|
9256
|
+
]);
|
|
9257
|
+
return eventDoc ?? googleImportedDoc;
|
|
9258
|
+
}
|
|
9159
9259
|
|
|
9160
9260
|
// src/service/relations.ts
|
|
9161
9261
|
function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
|
|
@@ -9238,8 +9338,8 @@ export {
|
|
|
9238
9338
|
sendPushNotifications,
|
|
9239
9339
|
termsAgreementSchema,
|
|
9240
9340
|
updateAdStatuses,
|
|
9341
|
+
updateAllEventDateTimeStatuses,
|
|
9241
9342
|
updateRelationDatesToUnavailable,
|
|
9242
|
-
updateSingleDateTimeStatus,
|
|
9243
9343
|
updateVendorBasedOnUserLicense,
|
|
9244
9344
|
userLicenseSchema
|
|
9245
9345
|
};
|