chore: access pattern consistency

This commit is contained in:
Cory Dransfeldt 2024-08-01 09:10:15 -07:00
parent 1c75acb37e
commit 6e206cdf47
No known key found for this signature in database
6 changed files with 8 additions and 9 deletions

View file

@ -1,6 +1,6 @@
{
"name": "coryd.dev",
"version": "21.0.0",
"version": "21.0.1",
"description": "The source for my personal site. Built using 11ty (and other tools).",
"type": "module",
"scripts": {

View file

@ -19,8 +19,8 @@ const fetchAllBadges = async () => {
const transformedData = data.map(badge => ({
...badge,
image: badge.image?.filename_disk || '',
})).sort((a, b) => a.sort - b.sort)
image: badge.image?.['filename_disk'] || '',
})).sort((a, b) => a['sort'] - b['sort'])
return transformedData
}

View file

@ -16,7 +16,7 @@ const fetchBlogroll = async () => {
return []
}
return data.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()))
return data.sort((a, b) => a['name'].toLowerCase().localeCompare(b['name'].toLowerCase()))
}
export default async function () {

View file

@ -69,7 +69,7 @@ const aggregateData = (data, groupByField, groupByType, genreMapping) => {
aggregation[key].plays++
})
return Object.values(aggregation).sort((a, b) => b.plays - a.plays).map((item, index) => ({ ...item, rank: index + 1 }))
return Object.values(aggregation).sort((a, b) => b['plays'] - a['plays']).map((item, index) => ({ ...item, rank: index + 1 }))
}
const buildRecents = (data) => {

View file

@ -3,7 +3,6 @@ import { createClient } from '@supabase/supabase-js'
const SUPABASE_URL = process.env.SUPABASE_URL
const SUPABASE_KEY = process.env.SUPABASE_KEY
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
const PAGE_SIZE = 100
const fetchAllRobots = async () => {
@ -26,7 +25,7 @@ const fetchAllRobots = async () => {
from += PAGE_SIZE
}
return robots.map(robot => robot.user_agent).sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
return robots.map(robot => robot['user_agent']).sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
}
export default async function () {

View file

@ -129,7 +129,7 @@ export default async function () {
try {
const rawShows = await fetchAllShows()
const shows = rawShows.map(prepareShowData)
const episodes = shows.flatMap(prepareEpisodeData).sort((a, b) => new Date(b.last_watched_at) - new Date(a.last_watched_at))
const episodes = shows.flatMap(prepareEpisodeData).sort((a, b) => new Date(b['last_watched_at']) - new Date(a['last_watched_at']))
const favoriteShows = shows.filter(show => show.favorite)
@ -137,7 +137,7 @@ export default async function () {
shows,
watchHistory: formatEpisodeData(episodes),
recentlyWatched: formatEpisodeData(episodes.slice(0, 225)),
favorites: formatEpisodeData(favoriteShows.flatMap(prepareEpisodeData)).sort((a, b) => a.name.localeCompare(b.name)),
favorites: formatEpisodeData(favoriteShows.flatMap(prepareEpisodeData)).sort((a, b) => a['name'].localeCompare(b['name'])),
}
} catch (error) {
console.error('Error fetching and processing shows data:', error)