Skip to content
Snippets Groups Projects
Commit 325d2c1a authored by MahiFaiyaz's avatar MahiFaiyaz
Browse files

Updated formatData method to clip long author name

parent bcd1a0e3
No related branches found
No related tags found
1 merge request!4Subreddit feature
const formatData = (data, dataKey, dataValue) => {
let result = []
console.log(dataKey)
const ignoredAuthors = ['AutoModerator', '[deleted]']
const ignoredWords = ['t', 'moderators', 'r', 'subreddit', 'comment', 'moderation', 'bot', 'submission']
const dataArr = Object.entries(data)
for (const [key, value] of dataArr) {
if (dataKey === "author" && ignoredAuthors.includes(key)) {
console.log(key)
continue;
}
if (dataKey === "text" && ignoredWords.includes(key)) {
console.log(key)
continue;
}
var obj = {}
obj[dataKey] = key
obj[dataValue] = value
if (dataKey === "author") {
obj['label'] = key
if (key.length > 10) {
console.log(key.length)
obj['label'] = key.slice(0,8) + ".."
}
}
result.push(obj)
}
result.sort((a,b) => b.comments - a.comments)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment