Skip to content

Commit

Permalink
fix(scripts/node): update to conform with new schema
Browse files Browse the repository at this point in the history
This patch updates the existing Node.js import scripts to conform with
the new Prisma schema changes (replacing reviews with articles, removing
the country code field, etc).
  • Loading branch information
nicholaschiang committed Aug 14, 2023
1 parent ac92d4c commit 23ff38e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 25 deletions.
4 changes: 2 additions & 2 deletions scripts/node/save/aritzia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ async function save(dir = 'public/data/aritzia') {
/* eslint-disable-next-line no-restricted-syntax */
for await (const product of products) {
const country: Prisma.CountryCreateOrConnectWithoutBrandsInput = {
where: { code: 'ca' },
create: { code: 'ca', name: 'canada' },
where: { name: 'Canada' },
create: { name: 'Canada' },
}
// TODO not all of the brands listed on Aritzia are owned by Aritzia or
// based out of Canada (e.g. Adidas, Nike, Levi's, etc).
Expand Down
25 changes: 19 additions & 6 deletions scripts/node/save/shows/hermes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const fashionotography: Prisma.PublicationCreateInput = {
// in its compliments, it should be assigned a 1/5 or 2/5. If a review seems
// energetically positive, assign a 3/5. Only if a review is resoundingly
// enthusiastically positive should you assign a 4/5. Never assign a 5/5.
export const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
export const reviews: Prisma.ArticleCreateWithoutShowInput[] = [
{
author: {
connectOrCreate: {
Expand All @@ -133,6 +133,7 @@ export const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
create: fashionotography,
},
},
title: 'Hermès Spring/Summer 2023 – Paris Fashion Week Men’s',
url: 'https://www.fashionotography.com/hermes-spring-summer-2023-pfw-mens/',
content: `
<p>
Expand Down Expand Up @@ -198,6 +199,7 @@ export const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
create: highs,
},
},
title: 'Hermès SS23 Is a Lesson in Outerwear',
url: 'https://www.highsnobiety.com/p/hermes-spring-summer-2023/',
score: 3 / 5,
content: `
Expand Down Expand Up @@ -251,6 +253,8 @@ export const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
create: bazaar,
},
},
title: 'All The Looks From The Hermès Spring/Summer 2023 Men’s Collection',
subtitle: 'A masterclass in refined summer dressing.',
url: 'https://www.harpersbazaar.com.sg/gallery/all-the-looks-from-the-hermes-spring-summer-2023-mens-collection/',
score: 2 / 5,
content: `
Expand Down Expand Up @@ -297,6 +301,8 @@ export const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
create: wwd,
},
},
title: 'Hermès Men’s Spring 2023',
subtitle: 'Models were dressed for fun times: déjeuner at Hotel du Cap-Eden-Roc near Cap d’Antibes, or aperitivo hour at Villa d’Este on Lake Como.',
url: 'https://wwd.com/runway/mens-spring-2023/paris/hermes/review/',
score: 3 / 5,
content: `
Expand Down Expand Up @@ -352,6 +358,8 @@ export const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
create: lofficiel,
},
},
title: 'Hermès: the Spring Summer 2023 collection',
subtitle: 'Between characters from the underwater world and pastel-colored kniwtwear, the Hermès Spring Summer 2023 men’s collection is described by Véronique Nichanian as "innovatively fascinating"',
url: 'https://www.lofficielibiza.com/fashion/hermes-man-collection-spring-summer-2023-photo-fashion-show',
score: 4 / 5,
content: `
Expand Down Expand Up @@ -404,6 +412,8 @@ export const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
create: lofficiel,
},
},
title: 'Hermès Spring/Summer 2024 Collection Embodies the Dream Mediterranean Summer',
subtitle: 'Véronique Nichanian’s sensual Spring/Summer 2024 collection for Hermès is a love letter to the Mediterranean.',
url: 'https://www.lofficielusa.com/fashion/hermes-spring-summer-2024-collection',
score: 3 / 5,
content: `
Expand Down Expand Up @@ -490,6 +500,7 @@ export const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
create: vogue,
},
},
title: 'Hermès Spring 2023 Menswear Collection',
url: 'https://www.vogue.com/fashion-shows/spring-2023-menswear/hermes',
score: 2 / 5,
content: `
Expand Down Expand Up @@ -523,6 +534,8 @@ export const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
create: purse,
},
},
title: 'Hermès Men’s Spring/Summer 2023 RTW Review: Genre-Bending Appeal',
subtitle: 'The Men’s Ready-to-Wear Runway collection features fun spring colors and shapes that will appeal to all',
url: 'https://www.purseblog.com/hermes/hermes-mens-spring-summer-2023-rtw-review-genre-bending-appeal/',
score: 3 / 5,
content: `
Expand All @@ -548,8 +561,8 @@ export const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
},
]
export const country = {
where: { code: 'fr' },
create: { name: 'france', code: 'fr' },
where: { name: 'France' },
create: { name: 'France' },
}
export const brand: Prisma.BrandCreateInput = {
name: 'Hermès',
Expand Down Expand Up @@ -604,8 +617,8 @@ export const show: Prisma.ShowCreateInput = {
Berlingot canvas, nubuck calfskin, crepe cotton serge, perforated leather, sunset tints... the collection is precise, crafted with the refinement of the hand and the nonchalance of a mind that is free of barriers.
In the open-air enclosure of the Manufacture des Gobelins, Cyril Teste, close partner of Véronique Nichanian, imagined a gesture in the form of a canvas sliding out of the building, swaying slightly in the breeze before disappearing – as if diving – through a workshop window.`,
criticReviewSummary: `Hermès Spring-Summer 2023 Mens Ready-to-Wear delights with its innovative fusion of colors, playful marine-themed designs, and luxurious practicality. Véronique Nichanian’s collection blurs the boundaries between menswear and womenswear, offering a tender and harmonious wardrobe that celebrates the joy and lightness of summer.`,
consumerReviewSummary: null,
articlesConsensus: `Hermès Spring-Summer 2023 Mens Ready-to-Wear delights with its innovative fusion of colors, playful marine-themed designs, and luxurious practicality. Véronique Nichanian’s collection blurs the boundaries between menswear and womenswear, offering a tender and harmonious wardrobe that celebrates the joy and lightness of summer.`,
reviewsConsensus: null,
date: new Date('June 25, 2022'),
location: Location.PARIS,
video: { connectOrCreate: { where: { url: video.url }, create: video } },
Expand All @@ -616,7 +629,7 @@ export const show: Prisma.ShowCreateInput = {
},
},
looks: { create: looks },
reviews: { create: reviews },
articles: { create: reviews },
collections: {
connectOrCreate: { where: { name: collection.name }, create: collection },
},
Expand Down
14 changes: 8 additions & 6 deletions scripts/node/save/shows/isabel-marant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const savoir: Prisma.PublicationCreateInput = {
avatar:
'https://www.kindpng.com/picc/m/266-2665896_file-ntsw4mb-savoir-flair-arabia-logo-hd-png.png',
}
const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
const reviews: Prisma.ArticleCreateWithoutShowInput[] = [
{
author: {
connectOrCreate: {
Expand All @@ -88,6 +88,7 @@ const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
create: vogue,
},
},
title: 'Isabel Marant Fall 2023 Ready-to-Wear Collection',
url: 'https://www.vogue.com/fashion-shows/fall-2023-ready-to-wear/isabel-marant',
score: 4 / 5,
content: `
Expand Down Expand Up @@ -161,6 +162,7 @@ const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
create: savoir,
},
},
title: 'Isabel Marant Throws a Music-Fueled Rager for Fall/Winter 2023',
url: 'https://www.savoirflair.com/fashion/629428/isabel-marant-fall-winter-2023',
score: 4 / 5,
content: `
Expand Down Expand Up @@ -203,8 +205,8 @@ const reviews: Prisma.ReviewCreateWithoutShowInput[] = [
},
]
const country = {
where: { code: 'fr' },
create: { name: 'france', code: 'fr' },
where: { name: 'France' },
create: { name: 'France' },
}
const brand: Prisma.BrandCreateInput = {
name: 'Isabel Marant',
Expand Down Expand Up @@ -252,8 +254,8 @@ The graphic cut-outs of the flou shape new cleavages while plays on transparency
The color palette, first natural and minimal, explores yellow and magenta horizons before diving into black. A sparkling evening mixes textures – embroideries, velvet lurex – and volumes – oversized, fitted, cropped.
Inside the venue, the show’s soundtrack performed live by DJ Gabber Eleganza and Lulu Van Trapp resonates and intoxicates the crowd. A unique creation composed on the idea of desire and disorder, this season’s mantra.`,
criticReviewSummary: `A high-energy party atmosphere and a stunning lineup of veteran supermodels—a much needed refresher from Paris Fashion Week. The designs exude Isabel Marant’s signature style, featuring roomy knitwear, smashing outerwear, and cool-girl attire, all while empowering wearability and desirability. With a focus on desire and disorder, the collection showcases unique graphic cut-outs, metallic zips, and playful contrasts, leaving a lasting impression on the audience.`,
consumerReviewSummary: null,
articlesConsensus: `A high-energy party atmosphere and a stunning lineup of veteran supermodels—a much needed refresher from Paris Fashion Week. The designs exude Isabel Marant’s signature style, featuring roomy knitwear, smashing outerwear, and cool-girl attire, all while empowering wearability and desirability. With a focus on desire and disorder, the collection showcases unique graphic cut-outs, metallic zips, and playful contrasts, leaving a lasting impression on the audience.`,
reviewsConsensus: null,
date: new Date('March 2, 2023'),
location: Location.PARIS,
video: { connectOrCreate: { where: { url: video.url }, create: video } },
Expand All @@ -264,7 +266,7 @@ Inside the venue, the show’s soundtrack performed live by DJ Gabber Eleganza a
},
},
looks: { create: looks },
reviews: { create: reviews },
articles: { create: reviews },
collections: {
connectOrCreate: { where: { name: collection.name }, create: collection },
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/node/save/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function save() {
const create = reviews.filter((review) => !review.url?.includes('vogue.com'))
await prisma.show.update({
where: { id: 775 },
data: { reviews: { create } },
data: { articles: { create } },
})
}

Expand Down
10 changes: 5 additions & 5 deletions scripts/node/save/vogue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function parseSeason(season: string): ParsedSeason {

function getData(show: Show) {
const { season, ...etc } = parseSeason(show.season)
let review: Prisma.ReviewCreateWithoutShowInput | undefined
let review: Prisma.ArticleCreateWithoutShowInput | undefined
if (show.author_name && show.author_url)
review = {
title: show.title,
Expand All @@ -188,7 +188,7 @@ function getData(show: Show) {
summary: null,
content: show.content.join('\n'),
url: show.url,
date: show.date ? new Date(show.date) : null,
writtenAt: show.date ? new Date(show.date) : null,
author: {
connectOrCreate: {
where: { name: show.author_name },
Expand Down Expand Up @@ -238,10 +238,10 @@ function getData(show: Show) {
name,
url: show.url,
description: null,
criticReviewSummary: null,
consumerReviewSummary: null,
articlesConsensus: null,
reviewsConsensus: null,
date: show.date ? new Date(show.date) : null,
reviews: review ? { create: review } : undefined,
articles: review ? { create: review } : undefined,
season: {
connectOrCreate: {
where: { name_year: { name: season.name, year: season.year } },
Expand Down
10 changes: 5 additions & 5 deletions scripts/node/save/wwd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function getData(show: Show & { looks: Look[] }) {
show.season,
show.header,
)
let review: Prisma.ReviewCreateWithoutShowInput | undefined
let review: Prisma.ArticleCreateWithoutShowInput | undefined
const date = show.date
? DateTime.fromFormat(strip(show.date), 'LLLL d, yyyy, h:mma').toString()
: null
Expand All @@ -204,7 +204,7 @@ function getData(show: Show & { looks: Look[] }) {
const author = { name: strip(show.author_name), url: show.author_url }
log('Author:', author)
review = {
date,
writtenAt: date,
title: show.header,
subtitle: show.excerpt ? strip(show.excerpt) : null,
score: null,
Expand Down Expand Up @@ -299,9 +299,9 @@ function getData(show: Show & { looks: Look[] }) {
date,
url: show.url,
description: null,
criticReviewSummary: null,
consumerReviewSummary: null,
reviews: review ? { create: review } : undefined,
articlesConsensus: null,
reviewsConsensus: null,
articles: review ? { create: review } : undefined,
season: {
connectOrCreate: {
where: { name_year: { name: season.name, year: season.year } },
Expand Down

0 comments on commit 23ff38e

Please sign in to comment.