@rmdes/indiekit-endpoint-blogroll 1.0.7 → 1.0.8

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.
@@ -136,8 +136,12 @@ export async function getItemsForBlog(application, blogId, limit = 20, blog = nu
136
136
  .toArray();
137
137
  }
138
138
 
139
+ // Retention period for item counts (match Microsub retention)
140
+ const ITEM_RETENTION_DAYS = 30;
141
+
139
142
  /**
140
143
  * Count items (including Microsub items)
144
+ * Only counts items within the retention period
141
145
  * @param {object} application - Application instance
142
146
  * @param {object} options - Query options
143
147
  * @returns {Promise<number>} Count
@@ -145,14 +149,18 @@ export async function getItemsForBlog(application, blogId, limit = 20, blog = nu
145
149
  export async function countItems(application, options = {}) {
146
150
  const db = application.getBlogrollDb();
147
151
 
148
- // Count regular items
149
- const regularQuery = {};
152
+ // Calculate cutoff date for counting
153
+ const cutoffDate = new Date();
154
+ cutoffDate.setDate(cutoffDate.getDate() - ITEM_RETENTION_DAYS);
155
+
156
+ // Count regular items (within retention period)
157
+ const regularQuery = { published: { $gte: cutoffDate } };
150
158
  if (options.blogId) {
151
159
  regularQuery.blogId = new ObjectId(options.blogId);
152
160
  }
153
161
  const regularCount = await db.collection("blogrollItems").countDocuments(regularQuery);
154
162
 
155
- // Count Microsub items for microsub-sourced blogs
163
+ // Count Microsub items for microsub-sourced blogs (within retention period)
156
164
  let microsubCount = 0;
157
165
  const itemsCollection = application.collections?.get("microsub_items");
158
166
 
@@ -163,6 +171,7 @@ export async function countItems(application, options = {}) {
163
171
  if (blog?.source === "microsub" && blog.microsubFeedId) {
164
172
  microsubCount = await itemsCollection.countDocuments({
165
173
  feedId: new ObjectId(blog.microsubFeedId),
174
+ published: { $gte: cutoffDate },
166
175
  });
167
176
  }
168
177
  } else {
@@ -180,6 +189,7 @@ export async function countItems(application, options = {}) {
180
189
  if (feedIds.length > 0) {
181
190
  microsubCount = await itemsCollection.countDocuments({
182
191
  feedId: { $in: feedIds },
192
+ published: { $gte: cutoffDate },
183
193
  });
184
194
  }
185
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-blogroll",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Blogroll endpoint for Indiekit. Aggregates blog feeds from OPML, JSON feeds, or manual entry.",
5
5
  "keywords": [
6
6
  "indiekit",