chore: normalize formatting
This commit is contained in:
parent
01ed2ac3b3
commit
2f6cfbe7ae
61 changed files with 921 additions and 743 deletions
|
@ -1,47 +1,47 @@
|
|||
import { createClient } from '@supabase/supabase-js'
|
||||
import { parseCountryField } from '../../config/utilities/index.js'
|
||||
import { createClient } from "@supabase/supabase-js";
|
||||
import { parseCountryField } from "../../config/utilities/index.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 = 1000
|
||||
const SUPABASE_URL = process.env.SUPABASE_URL;
|
||||
const SUPABASE_KEY = process.env.SUPABASE_KEY;
|
||||
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY);
|
||||
const PAGE_SIZE = 1000;
|
||||
|
||||
const fetchAllArtists = async () => {
|
||||
let artists = []
|
||||
let rangeStart = 0
|
||||
let artists = [];
|
||||
let rangeStart = 0;
|
||||
|
||||
while (true) {
|
||||
const { data, error } = await supabase
|
||||
.from('optimized_artists')
|
||||
.select('*')
|
||||
.range(rangeStart, rangeStart + PAGE_SIZE - 1)
|
||||
.from("optimized_artists")
|
||||
.select("*")
|
||||
.range(rangeStart, rangeStart + PAGE_SIZE - 1);
|
||||
|
||||
if (error) {
|
||||
console.error('Error fetching artists:', error)
|
||||
break
|
||||
console.error("Error fetching artists:", error);
|
||||
break;
|
||||
}
|
||||
|
||||
artists = artists.concat(data)
|
||||
if (data.length < PAGE_SIZE) break
|
||||
rangeStart += PAGE_SIZE
|
||||
artists = artists.concat(data);
|
||||
if (data.length < PAGE_SIZE) break;
|
||||
rangeStart += PAGE_SIZE;
|
||||
}
|
||||
|
||||
return artists
|
||||
}
|
||||
return artists;
|
||||
};
|
||||
|
||||
const processArtists = (artists) => {
|
||||
return artists.map(artist => ({
|
||||
return artists.map((artist) => ({
|
||||
...artist,
|
||||
country: parseCountryField(artist['country']),
|
||||
}))
|
||||
}
|
||||
country: parseCountryField(artist["country"]),
|
||||
}));
|
||||
};
|
||||
|
||||
export default async function () {
|
||||
try {
|
||||
const artists = await fetchAllArtists()
|
||||
return processArtists(artists)
|
||||
const artists = await fetchAllArtists();
|
||||
return processArtists(artists);
|
||||
} catch (error) {
|
||||
console.error('Error fetching and processing artists data:', error)
|
||||
return []
|
||||
console.error("Error fetching and processing artists data:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue