chore(*): use prettier for formatting

This commit is contained in:
Cory Dransfeldt 2025-06-14 16:43:12 -07:00
parent 6c659fe1d0
commit 029caaaa9e
No known key found for this signature in database
73 changed files with 1390 additions and 794 deletions

View file

@ -1,19 +1,19 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchDataFromView = async (viewName) => {
try {
return await EleventyFetch(`${POSTGREST_URL}/${viewName}?select=*`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error(`Error fetching data from view ${viewName}:`, error);
@ -32,17 +32,17 @@ export default async function fetchMusicData() {
monthTracks,
monthArtists,
monthAlbums,
monthGenres,
monthGenres
] = await Promise.all([
fetchDataFromView("recent_tracks"),
fetchDataFromView("week_tracks"),
fetchDataFromView("week_artists"),
fetchDataFromView("week_albums"),
fetchDataFromView("week_genres"),
fetchDataFromView("month_tracks"),
fetchDataFromView("month_artists"),
fetchDataFromView("month_albums"),
fetchDataFromView("month_genres"),
fetchDataFromView('recent_tracks'),
fetchDataFromView('week_tracks'),
fetchDataFromView('week_artists'),
fetchDataFromView('week_albums'),
fetchDataFromView('week_genres'),
fetchDataFromView('month_tracks'),
fetchDataFromView('month_artists'),
fetchDataFromView('month_albums'),
fetchDataFromView('month_genres')
]);
return {
@ -52,9 +52,7 @@ export default async function fetchMusicData() {
artists: weekArtists,
albums: weekAlbums,
genres: weekGenres,
totalTracks: weekTracks
.reduce((acc, track) => acc + track.plays, 0)
.toLocaleString("en-US"),
totalTracks: weekTracks.reduce((acc, track) => acc + track.plays, 0).toLocaleString('en-US')
},
month: {
tracks: monthTracks,
@ -63,11 +61,11 @@ export default async function fetchMusicData() {
genres: monthGenres,
totalTracks: monthTracks
.reduce((acc, track) => acc + track.plays, 0)
.toLocaleString("en-US"),
},
.toLocaleString('en-US')
}
};
} catch (error) {
console.error("Error fetching and processing music data:", error);
console.error('Error fetching and processing music data:', error);
return {
recent: [],
week: {
@ -75,15 +73,15 @@ export default async function fetchMusicData() {
artists: [],
albums: [],
genres: [],
totalTracks: "0",
totalTracks: '0'
},
month: {
tracks: [],
artists: [],
albums: [],
genres: [],
totalTracks: "0",
},
totalTracks: '0'
}
};
}
}