chore: debug
This commit is contained in:
parent
96a098b0ef
commit
8890af06b2
7 changed files with 35 additions and 80 deletions
|
@ -1,30 +0,0 @@
|
|||
import { getStore, setEnvironmentContext } from '@netlify/blobs'
|
||||
import { DateTime } from 'luxon'
|
||||
import fs from 'fs'
|
||||
|
||||
const getKeys = () => {
|
||||
const currentDate = DateTime.now()
|
||||
return [
|
||||
`${currentDate.year}-${currentDate.weekNumber}`
|
||||
`${currentDate.minus({ weeks: 1 }).year}-${currentDate.minus({ weeks: 1 }).weekNumber}`,
|
||||
`${currentDate.minus({ weeks: 2 }).year}-${currentDate.minus({ weeks: 2 }).weekNumber}`,
|
||||
`${currentDate.minus({ weeks: 3 }).year}-${currentDate.minus({ weeks: 3 }).weekNumber}`,
|
||||
`${currentDate.minus({ weeks: 4 }).year}-${currentDate.minus({ weeks: 4 }).weekNumber}`,
|
||||
]
|
||||
}
|
||||
|
||||
export const onPreBuild = async ({ constants }) => {
|
||||
const keys = getKeys()
|
||||
const data = []
|
||||
setEnvironmentContext({
|
||||
siteID: constants.SITE_ID,
|
||||
token: constants.NETLIFY_API_TOKEN,
|
||||
})
|
||||
const scrobbles = getStore('scrobbles')
|
||||
keys.forEach(async key => {
|
||||
const scrobbleData = await scrobbles.get(key, { type: 'json'})
|
||||
data.push(scrobbleData['data'])
|
||||
})
|
||||
console.log(data)
|
||||
fs.writeFileSync('./src/_data/json/scrobbles-month-chart.json', JSON.stringify(data))
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
name: netlify-plugin-fetch-charts
|
34
plugins/fetch-charts/package-lock.json
generated
34
plugins/fetch-charts/package-lock.json
generated
|
@ -1,34 +0,0 @@
|
|||
{
|
||||
"name": "netlify-plugin-fetch-charts",
|
||||
"version": "0.0.8",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "netlify-plugin-fetch-charts",
|
||||
"version": "0.0.8",
|
||||
"devDependencies": {
|
||||
"@netlify/blobs": "^7.3.0",
|
||||
"luxon": "^3.4.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@netlify/blobs": {
|
||||
"version": "7.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@netlify/blobs/-/blobs-7.3.0.tgz",
|
||||
"integrity": "sha512-wN/kNTZo4xjlUM/C0WILOkJbe8p4AFquSGkZEIoIcgnsx5ikp2GyqGiq1WMLee7QdbnqeIV2g2hn/PjT324E5w==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^14.16.0 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/luxon": {
|
||||
"version": "3.4.4",
|
||||
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.4.4.tgz",
|
||||
"integrity": "sha512-zobTr7akeGHnv7eBOXcRgMeCP6+uyYsczwmeRCauvpvaAltgNyTbLH/+VaEAPUeWBT+1GuNmz4wC/6jtQzbbVA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"name": "netlify-plugin-fetch-charts",
|
||||
"version": "0.0.8",
|
||||
"description": "netlify-plugin-fetch-charts",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@netlify/blobs": "^7.3.0",
|
||||
"luxon": "^3.4.4"
|
||||
}
|
||||
}
|
|
@ -1,11 +1,25 @@
|
|||
import { getStore, setEnvironmentContext } from '@netlify/blobs'
|
||||
import { DateTime } from 'luxon'
|
||||
import fs from 'fs'
|
||||
|
||||
const getKeys = () => {
|
||||
const currentDate = DateTime.now()
|
||||
return [
|
||||
`${currentDate.year}-${currentDate.weekNumber}`
|
||||
`${currentDate.minus({ weeks: 1 }).year}-${currentDate.minus({ weeks: 1 }).weekNumber}`,
|
||||
`${currentDate.minus({ weeks: 2 }).year}-${currentDate.minus({ weeks: 2 }).weekNumber}`,
|
||||
`${currentDate.minus({ weeks: 3 }).year}-${currentDate.minus({ weeks: 3 }).weekNumber}`,
|
||||
`${currentDate.minus({ weeks: 4 }).year}-${currentDate.minus({ weeks: 4 }).weekNumber}`,
|
||||
]
|
||||
}
|
||||
|
||||
export const onPreBuild = async ({ constants }) => {
|
||||
setEnvironmentContext({
|
||||
siteID: constants.SITE_ID,
|
||||
token: constants.NETLIFY_API_TOKEN,
|
||||
})
|
||||
const keys = getKeys()
|
||||
const chartData = []
|
||||
const scrobbles = getStore('scrobbles')
|
||||
const artists = getStore('artists')
|
||||
const albums = getStore('albums')
|
||||
|
@ -13,8 +27,14 @@ export const onPreBuild = async ({ constants }) => {
|
|||
const artistsMap = await artists.get('artists-map', { type: 'json' })
|
||||
const albumsMap = await albums.get('albums-map', { type: 'json' })
|
||||
const nowPlaying = await scrobbles.get('now-playing', { type: 'json'})
|
||||
keys.forEach(async key => {
|
||||
const scrobbleData = await scrobbles.get(key, { type: 'json'})
|
||||
data.push(scrobbleData['data'])
|
||||
})
|
||||
console.log(chartData)
|
||||
fs.writeFileSync('./src/_data/json/scrobbles-window.json', JSON.stringify(windowData))
|
||||
fs.writeFileSync('./src/_data/json/artists-map.json', JSON.stringify(artistsMap))
|
||||
fs.writeFileSync('./src/_data/json/albums-map.json', JSON.stringify(albumsMap))
|
||||
fs.writeFileSync('./src/_data/json/now-playing.json', JSON.stringify(nowPlaying))
|
||||
fs.writeFileSync('./src/_data/json/scrobbles-month-chart.json', JSON.stringify(chartData))
|
||||
}
|
16
plugins/fetch-scrobbles/package-lock.json
generated
16
plugins/fetch-scrobbles/package-lock.json
generated
|
@ -1,14 +1,15 @@
|
|||
{
|
||||
"name": "netlify-plugin-rss",
|
||||
"name": "netlify-plugin-fetch-scrobbles",
|
||||
"version": "0.0.8",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "netlify-plugin-rss",
|
||||
"name": "netlify-plugin-fetch-scrobbles",
|
||||
"version": "0.0.8",
|
||||
"devDependencies": {
|
||||
"@netlify/blobs": "^7.3.0"
|
||||
"@netlify/blobs": "^7.3.0",
|
||||
"luxon": "^3.4.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@netlify/blobs": {
|
||||
|
@ -19,6 +20,15 @@
|
|||
"engines": {
|
||||
"node": "^14.16.0 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/luxon": {
|
||||
"version": "3.4.4",
|
||||
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.4.4.tgz",
|
||||
"integrity": "sha512-zobTr7akeGHnv7eBOXcRgMeCP6+uyYsczwmeRCauvpvaAltgNyTbLH/+VaEAPUeWBT+1GuNmz4wC/6jtQzbbVA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"main": "index.js",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@netlify/blobs": "^7.3.0"
|
||||
"@netlify/blobs": "^7.3.0",
|
||||
"luxon": "^3.4.4"
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue