diff --git a/src/_data/json/read.json b/src/_data/json/read.json index 4e3a2588..f2f8e114 100644 --- a/src/_data/json/read.json +++ b/src/_data/json/read.json @@ -10790,7 +10790,7 @@ "categories": [ "Biography & Autobiography" ], - "thumbnail": "https://books.google.com/books/content?id=f8LrtwEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api&w=512", + "thumbnail": "https://coryd.dev/media/books/1573449709-see-a-little-light.jpg", "language": "en", "link": "https://books.google.com/books/about/See_a_Little_Light.html?hl=&id=f8LrtwEACAAJ" } diff --git a/src/_data/music.js b/src/_data/music.js index ce07fcdd..2827d5c1 100644 --- a/src/_data/music.js +++ b/src/_data/music.js @@ -58,8 +58,9 @@ const fetchAllTimeData = async (fields, table) => { return rows } -const aggregateData = (data, groupByField, groupByType, sort = true) => { +const aggregateData = (data, groupByField, groupByType) => { const aggregation = {} + data.forEach(item => { const key = item[groupByField] if (!aggregation[key]) { @@ -92,7 +93,8 @@ const aggregateData = (data, groupByField, groupByType, sort = true) => { } aggregation[key].plays++ }) - const aggregatedData = sort ? Object.values(aggregation).sort((a, b) => b.plays - a.plays) : Object.values(aggregation) + + const aggregatedData = Object.values(aggregation).sort((a, b) => b.plays - a.plays) aggregatedData.forEach((item, index) => { item.rank = index + 1 @@ -158,7 +160,7 @@ export default async function() { artists: aggregateData(recentData, 'artist_name', 'artists'), albums: aggregateData(recentData, 'album_name', 'albums'), tracks: aggregateData(recentData, 'track_name', 'track'), - tracksChronological: aggregateData(recentData, 'track_name', 'track', false), + tracksChronological: aggregateData(recentData, 'track_name', 'track').sort((a, b) => b.timestamp - a.timestamp), genres: aggregateGenres(recentData), totalTracks: recentData?.length?.toLocaleString('en-US') }