fix: resolves newly added Domain's Update time rendering issue

This commit is contained in:
towfiqi 2024-01-13 10:25:10 +06:00
parent 4a47cedad8
commit df3a738788

View File

@ -15,7 +15,8 @@ const getdomainStats = async (domains:DomainType[]): Promise<DomainType[]> => {
domainWithStat.keywordCount = keywords.length;
const keywordPositions = keywords.reduce((acc, itm) => (acc + itm.position), 0);
const KeywordsUpdateDates: number[] = keywords.reduce((acc: number[], itm) => [...acc, new Date(itm.lastUpdated).getTime()], [0]);
domainWithStat.keywordsUpdated = new Date(Math.max(...KeywordsUpdateDates)).toJSON();
const lastKeywordUpdateDate = Math.max(...KeywordsUpdateDates);
domainWithStat.keywordsUpdated = new Date(lastKeywordUpdateDate || new Date(domain.lastUpdated).getTime()).toJSON();
domainWithStat.avgPosition = Math.round(keywordPositions / keywords.length);
// Then Load the SC File and read the stats and calculate the Last 7 days stats