feat: significantly reduce build times
This commit is contained in:
parent
228bd1b681
commit
1c75acb37e
21 changed files with 671 additions and 558 deletions
|
@ -9,37 +9,46 @@ const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
|
|||
const fetchAlbumReleases = async () => {
|
||||
const today = DateTime.utc().toISO()
|
||||
const { data, error } = await supabase
|
||||
.from('albums')
|
||||
.from('optimized_album_releases')
|
||||
.select(`
|
||||
name,
|
||||
key,
|
||||
release_date,
|
||||
release_link,
|
||||
total_plays,
|
||||
art(filename_disk),
|
||||
artists(name_string, mbid, country)
|
||||
art,
|
||||
artist_name,
|
||||
artist_mbid,
|
||||
artist_country
|
||||
`)
|
||||
.gt('release_date', today)
|
||||
|
||||
if (error) {
|
||||
console.error('Error fetching data:', error)
|
||||
return
|
||||
return []
|
||||
}
|
||||
|
||||
return data.filter(album => !album['total_plays'] || !album['total_plays'] > 0).map(album => ({
|
||||
artist: album['artists']['name_string'],
|
||||
return data
|
||||
.filter(album => !album['total_plays'] || album['total_plays'] <= 0)
|
||||
.map(album => ({
|
||||
artist: album['artist_name'],
|
||||
title: album['name'],
|
||||
date: DateTime.fromISO(album['release_date']).toLocaleString(DateTime.DATE_FULL),
|
||||
url: album['release_link'],
|
||||
image: `/${album?.['art']?.['filename_disk']}` || '',
|
||||
artist_url: `/music/artists/${sanitizeMediaString(album['artists']['name_string'])}-${sanitizeMediaString(parseCountryField(album['artists']['country']))}`,
|
||||
mbid: album['artists']['mbid'],
|
||||
image: album['art'] ? `/${album['art']}` : '',
|
||||
artist_url: `/music/artists/${sanitizeMediaString(album['artist_name'])}-${sanitizeMediaString(parseCountryField(album['artist_country']))}`,
|
||||
mbid: album['artist_mbid'],
|
||||
timestamp: DateTime.fromISO(album['release_date']).toSeconds(),
|
||||
type: 'album-release'
|
||||
}
|
||||
)).sort((a, b) => a['timestamp'] - b['timestamp'])
|
||||
}))
|
||||
.sort((a, b) => a['timestamp'] - b['timestamp'])
|
||||
}
|
||||
|
||||
export default async function () {
|
||||
return await fetchAlbumReleases()
|
||||
}
|
||||
try {
|
||||
return await fetchAlbumReleases()
|
||||
} catch (error) {
|
||||
console.error('Error fetching and processing album releases:', error)
|
||||
return []
|
||||
}
|
||||
}
|
Reference in a new issue