mirror of
https://github.com/towfiqi/serpbear
synced 2025-06-26 18:15:54 +00:00
feat: Displays keyword's best position in email notification.
closes 202
This commit is contained in:
parent
040dab1517
commit
4c2f900d85
@ -442,6 +442,7 @@
|
|||||||
<tr align="left">
|
<tr align="left">
|
||||||
<th>Keyword</th>
|
<th>Keyword</th>
|
||||||
<th>Position</th>
|
<th>Position</th>
|
||||||
|
<th>Best</th>
|
||||||
<th>Updated</th>
|
<th>Updated</th>
|
||||||
</tr>
|
</tr>
|
||||||
{{keywordsTable}}
|
{{keywordsTable}}
|
||||||
|
@ -68,6 +68,19 @@ const getPositionChange = (history:KeywordHistory, position:number) : number =>
|
|||||||
return status;
|
return status;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getBestKeywordPosition = (history: KeywordHistory) => {
|
||||||
|
let bestPos;
|
||||||
|
if (Object.keys(history).length > 0) {
|
||||||
|
const historyArray = Object.keys(history).map((itemID) => ({ date: itemID, position: history[itemID] }))
|
||||||
|
.sort((a, b) => a.position - b.position).filter((el) => (el.position > 0));
|
||||||
|
if (historyArray[0]) {
|
||||||
|
bestPos = { ...historyArray[0] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bestPos?.position || '-';
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the Email HTML based on given domain name and its keywords
|
* Generate the Email HTML based on given domain name and its keywords
|
||||||
* @param {string} domainName - Keywords to scrape
|
* @param {string} domainName - Keywords to scrape
|
||||||
@ -97,6 +110,7 @@ const generateEmail = async (domainName:string, keywords:KeywordType[], settings
|
|||||||
keywordsTable += `<tr class="keyword">
|
keywordsTable += `<tr class="keyword">
|
||||||
<td>${countryFlag} ${deviceIcon} ${keyword.keyword}</td>
|
<td>${countryFlag} ${deviceIcon} ${keyword.keyword}</td>
|
||||||
<td>${keyword.position}${posChangeIcon}</td>
|
<td>${keyword.position}${posChangeIcon}</td>
|
||||||
|
<td>${getBestKeywordPosition(keyword.history)}</td>
|
||||||
<td>${timeSince(new Date(keyword.lastUpdated).getTime() / 1000)}</td>
|
<td>${timeSince(new Date(keyword.lastUpdated).getTime() / 1000)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user