Skip to content

Commit

Permalink
fix: Fixes missing keyword city value in exported csv file.
Browse files Browse the repository at this point in the history
closes #194
  • Loading branch information
towfiqi committed Nov 8, 2024
1 parent 01b1b7b commit f482884
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions utils/client/exportcsv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import countries from '../countries';
const exportCSV = (keywords: KeywordType[] | SCKeywordType[], domain:string, scDataDuration = 'lastThreeDays') => {
if (!keywords || (keywords && Array.isArray(keywords) && keywords.length === 0)) { return; }
const isSCKeywords = !!(keywords && keywords[0] && keywords[0].uid);
let csvHeader = 'ID,Keyword,Position,URL,Country,Device,Updated,Added,Tags\r\n';
let csvHeader = 'ID,Keyword,Position,URL,Country,City,Device,Updated,Added,Tags\r\n';
let csvBody = '';
let fileName = `${domain}-keywords_serp.csv`;

Expand All @@ -26,9 +26,9 @@ const exportCSV = (keywords: KeywordType[] | SCKeywordType[], domain:string, scD
});
} else {
keywords.forEach((keywordData) => {
const { ID, keyword, position, url, country, device, lastUpdated, added, tags } = keywordData as KeywordType;
const { ID, keyword, position, url, country, city, device, lastUpdated, added, tags } = keywordData as KeywordType;
// eslint-disable-next-line max-len
csvBody += `${ID}, ${keyword}, ${position === 0 ? '-' : position}, ${url || '-'}, ${countries[country][0]}, ${device}, ${lastUpdated}, ${added}, ${tags.join(',')}\r\n`;
csvBody += `${ID}, ${keyword}, ${position === 0 ? '-' : position}, ${url || '-'}, ${countries[country][0]}, ${city || '-'}, ${device}, ${lastUpdated}, ${added}, ${tags.join(',')}\r\n`;
});
}

Expand Down

0 comments on commit f482884

Please sign in to comment.