upto phase 4 completed
This commit is contained in:
@@ -104,31 +104,38 @@ export default function ContentCalendar() {
|
||||
const thirtyDaysAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
|
||||
const thirtyDaysFromNow = new Date(now.getTime() + 30 * 24 * 60 * 60 * 1000);
|
||||
|
||||
// Published in last 30 days (items with external_id)
|
||||
// Published in last 30 days - check EITHER external_id OR site_status='published'
|
||||
const publishedLast30Days = allContent.filter((c: Content) => {
|
||||
if (!c.external_id || c.external_id === '') return false;
|
||||
const isPublished = (c.external_id && c.external_id !== '') || c.site_status === 'published';
|
||||
if (!isPublished) return false;
|
||||
// Use updated_at as publish date since site_status_updated_at may not be set
|
||||
const publishDate = c.updated_at ? new Date(c.updated_at) : null;
|
||||
return publishDate && publishDate >= thirtyDaysAgo;
|
||||
}).length;
|
||||
|
||||
// Scheduled in next 30 days (exclude already published items with external_id)
|
||||
// Scheduled in next 30 days (exclude already published items)
|
||||
const scheduledNext30Days = allContent.filter((c: Content) => {
|
||||
if (c.site_status !== 'scheduled') return false;
|
||||
if (c.external_id && c.external_id !== '') return false; // Exclude already published
|
||||
// Exclude already published (either has external_id OR site_status='published')
|
||||
if ((c.external_id && c.external_id !== '') || c.site_status === 'published') return false;
|
||||
const schedDate = c.scheduled_publish_at ? new Date(c.scheduled_publish_at) : null;
|
||||
return schedDate && schedDate >= now && schedDate <= thirtyDaysFromNow;
|
||||
}).length;
|
||||
|
||||
return {
|
||||
// Scheduled count excludes items that are already published (have external_id)
|
||||
// Scheduled count excludes items that are already published
|
||||
scheduled: allContent.filter((c: Content) =>
|
||||
c.site_status === 'scheduled' && (!c.external_id || c.external_id === '')
|
||||
c.site_status === 'scheduled' && (!c.external_id || c.external_id === '') && c.site_status !== 'published'
|
||||
).length,
|
||||
publishing: allContent.filter((c: Content) => c.site_status === 'publishing').length,
|
||||
published: allContent.filter((c: Content) => c.external_id && c.external_id !== '').length,
|
||||
// Published: check EITHER external_id OR site_status='published'
|
||||
published: allContent.filter((c: Content) =>
|
||||
(c.external_id && c.external_id !== '') || c.site_status === 'published'
|
||||
).length,
|
||||
review: allContent.filter((c: Content) => c.status === 'review').length,
|
||||
approved: allContent.filter((c: Content) => c.status === 'approved' && (!c.external_id || c.external_id === '')).length,
|
||||
approved: allContent.filter((c: Content) =>
|
||||
c.status === 'approved' && (!c.external_id || c.external_id === '') && c.site_status !== 'published'
|
||||
).length,
|
||||
publishedLast30Days,
|
||||
scheduledNext30Days,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user