chore: cache charts
This commit is contained in:
parent
8320c4cf24
commit
a2d50cee46
4 changed files with 33 additions and 31 deletions
|
@ -1,22 +1,23 @@
|
|||
// const chartData = require('./json/weekly-artist-charts.json')
|
||||
//
|
||||
// module.exports = async function () {
|
||||
// const artists = chartData['weeklyartistchart']['artist'].splice(0, 8)
|
||||
// const date = parseInt(chartData['weeklyartistchart']['@attr']['to']) * 1000
|
||||
// let content = 'My top artists for the week: '
|
||||
// artists.forEach((artist, index) => {
|
||||
// content += `${artist['name']} @ ${artist['playcount']} play${
|
||||
// parseInt(artist['playcount']) > 1 ? 's' : ''
|
||||
// }`
|
||||
// if (index !== artists.length - 1) content += ', '
|
||||
// })
|
||||
// content += ' #Music #LastFM'
|
||||
// return [
|
||||
// {
|
||||
// title: content,
|
||||
// url: `https://coryd.dev/now?ts=${date}`,
|
||||
// date: new Date(date),
|
||||
// description: 'My top artists for the week as a feed item.<br/><br/>',
|
||||
// },
|
||||
// ]
|
||||
// }
|
||||
const chartData = require('./json/weekly-artist-charts.json')
|
||||
const charts = chartData['charts']
|
||||
|
||||
module.exports = async function () {
|
||||
return charts.map((chart) => {
|
||||
const artists = chart['weeklyartistchart']['artist'].splice(0, 8)
|
||||
const date = parseInt(chart['weeklyartistchart']['@attr']['to']) * 1000
|
||||
let content = 'My top artists for the week: '
|
||||
artists.forEach((artist, index) => {
|
||||
content += `${artist['name']} @ ${artist['playcount']} play${
|
||||
parseInt(artist['playcount']) > 1 ? 's' : ''
|
||||
}`
|
||||
if (index !== artists.length - 1) content += ', '
|
||||
})
|
||||
content += ' #Music #LastFM'
|
||||
return {
|
||||
title: content,
|
||||
url: `https://coryd.dev/now?ts=${date}`,
|
||||
date: new Date(date),
|
||||
description: 'My top artists for the week as a feed item.<br/><br/>',
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Reference in a new issue