@7365admin1/core 3.32.2-staging.4 → 3.32.2-staging.5

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/index.d.ts CHANGED
@@ -7261,6 +7261,7 @@ declare function usePostPrelovedRepo(): {
7261
7261
  updateById: (_id: string | ObjectId, value: Partial<TPost>, session?: any) => Promise<mongodb.UpdateResult<bson.Document>>;
7262
7262
  deleteById: (_id: string | ObjectId, session?: any) => Promise<number>;
7263
7263
  updateStatus: (_id: string | ObjectId, status: PostStatus, session?: any) => Promise<mongodb.UpdateResult<bson.Document>>;
7264
+ createIndexes: () => Promise<string>;
7264
7265
  };
7265
7266
 
7266
7267
  declare function usePostPrelovedController(): {
@@ -7648,7 +7649,7 @@ declare function useFormEntryRepo(): {
7648
7649
  items: any[];
7649
7650
  pages: number;
7650
7651
  pageRange: string;
7651
- } | TFormEntry>;
7652
+ }>;
7652
7653
  };
7653
7654
 
7654
7655
  declare function useFormEntryController(): {
package/dist/index.js CHANGED
@@ -67073,6 +67073,26 @@ function usePostPrelovedRepo() {
67073
67073
  }
67074
67074
  };
67075
67075
  const collection = db.collection(POST_COLLECTION);
67076
+ async function createIndexes() {
67077
+ try {
67078
+ await collection.createIndexes([
67079
+ // getAll: site browse filtered by status, sorted by recency (default sort)
67080
+ { key: { site: 1, status: 1, createdAt: -1 } },
67081
+ // getAll: global browse (no site) sorted by recency
67082
+ { key: { status: 1, createdAt: -1 } },
67083
+ // getByOwnerId: a user's own posts, sorted by recency
67084
+ { key: { createdBy: 1, status: 1, createdAt: -1 } },
67085
+ // category / subcategory faceted filtering
67086
+ { key: { category: 1, status: 1 } },
67087
+ { key: { subcategory: 1, status: 1 } }
67088
+ ]);
67089
+ return `Successfully created indexes for ${POST_COLLECTION}.`;
67090
+ } catch (error) {
67091
+ throw new import_node_server_utils237.InternalServerError(
67092
+ "Failed to create indexes on post-preloved."
67093
+ );
67094
+ }
67095
+ }
67076
67096
  function buildSortObj(filter) {
67077
67097
  switch (filter) {
67078
67098
  case "price-low-high":
@@ -67405,7 +67425,8 @@ function usePostPrelovedRepo() {
67405
67425
  getByOwnerId,
67406
67426
  updateById,
67407
67427
  deleteById,
67408
- updateStatus
67428
+ updateStatus,
67429
+ createIndexes
67409
67430
  };
67410
67431
  }
67411
67432
 
@@ -69812,15 +69833,6 @@ function useFormEntryRepo() {
69812
69833
  const user = new import_mongodb153.ObjectId(userId);
69813
69834
  const siteId = new import_mongodb153.ObjectId(site);
69814
69835
  const orgId = new import_mongodb153.ObjectId(org);
69815
- const cacheOptions = {
69816
- page,
69817
- limit,
69818
- sort: JSON.stringify(sort),
69819
- userId: user,
69820
- site: siteId,
69821
- org: orgId,
69822
- ...search && { search }
69823
- };
69824
69836
  const query = {
69825
69837
  userId: user,
69826
69838
  site: siteId,
@@ -69832,15 +69844,6 @@ function useFormEntryRepo() {
69832
69844
  { unitNumber: { $regex: search, $options: "i" } }
69833
69845
  ];
69834
69846
  }
69835
- const cacheKey = (0, import_node_server_utils256.makeCacheKey)(
69836
- online_forms_namespace_collection,
69837
- cacheOptions
69838
- );
69839
- const cachedData = await getCache(cacheKey);
69840
- if (cachedData) {
69841
- import_node_server_utils256.logger.info(`Cache hit for key: ${cacheKey}`);
69842
- return cachedData;
69843
- }
69844
69847
  try {
69845
69848
  const items = await collection.aggregate([
69846
69849
  { $match: query },
@@ -69850,11 +69853,6 @@ function useFormEntryRepo() {
69850
69853
  ]).toArray();
69851
69854
  const length = await collection.countDocuments(query);
69852
69855
  const data = (0, import_node_server_utils256.paginate)(items, page, limit, length);
69853
- setCache(cacheKey, data, 15 * 60).then(() => {
69854
- import_node_server_utils256.logger.info(`Cache set for key: ${cacheKey}`);
69855
- }).catch((err) => {
69856
- import_node_server_utils256.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
69857
- });
69858
69856
  return data;
69859
69857
  } catch (error) {
69860
69858
  throw error;