Skip to content

Commit

Permalink
feat: add collection.sex field
Browse files Browse the repository at this point in the history
This patch adds a `collection.sex` field to indicate the original
intended sex for the items in a collection. This is used to decide
whether or not a show is "menswear" or not.
  • Loading branch information
nicholaschiang committed Jul 25, 2023
1 parent d9bd74a commit 66e190f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function Header() {
{matches
.filter((match) => match.handle && match.handle.breadcrumb)
.map((match, index) => (
<Fragment key={index}>
<Fragment key={match.id}>
{index !== 0 && (
<span className='text-gray-300 dark:text-gray-600'>/</span>
)}
Expand Down
9 changes: 7 additions & 2 deletions app/routes/shows.$showId/scores-header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useLoaderData } from '@remix-run/react'
import { useMemo } from 'react'
import { Sex } from '@prisma/client'

import { prisma } from 'db.server'
import { cn } from 'utils/cn'
Expand Down Expand Up @@ -67,6 +68,11 @@ export async function getScores(showId: number): Promise<Scores> {

export function ScoresHeader() {
const show = useLoaderData<typeof loader>()
const sex = show.collections
.map((collection) => collection.sex)
.every((value) => value === Sex.MAN)
? 'Menswear'
: ''
return (
<div className='grid gap-2'>
<video
Expand All @@ -92,8 +98,7 @@ export function ScoresHeader() {
{show.brands.map((brand) => brand.name).join(', ')}
</h1>
<h2 className='uppercase mb-6 text-sm'>
{show.season.name.replace('_', '-')} {show.season.year}{' '}
READY-TO-WEAR
{show.season.name.replace('_', '-')} {show.season.year} {sex}
</h2>
<ul className='grid grid-cols-2 gap-2 mt-auto'>
<ScoreItem score={show.scores.critic} name='Critic Score' />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `sex` to the `Collection` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Collection" ADD COLUMN "sex" "Sex" NOT NULL;
5 changes: 4 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,12 @@ model Collection {
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
// The collection's name, as designated by the brand or designer.
// The collection's name (e.g. "Hermès Spring-Summer 2023 Menswear").
name String @unique
// The collection's intended sex (i.e. "menswear" v.s. "womenswear").
sex Sex
// The collection's style category (if limited to a single category).
style Style? @relation(fields: [styleId], references: [id], onDelete: Cascade, onUpdate: Cascade)
styleId Int?
Expand Down
7 changes: 4 additions & 3 deletions scripts/node/save/shows/hermes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Prisma, Tier, SeasonName } from '@prisma/client'
import { type Prisma, Sex, Tier, SeasonName } from '@prisma/client'

const NUM_LOOKS = 53

Expand Down Expand Up @@ -569,7 +569,8 @@ const link: Prisma.LinkCreateInput = {
brand: { connectOrCreate: { where: { name: brand.name }, create: brand } },
}
const collection: Prisma.CollectionCreateInput = {
name: 'Hermès Spring-Summer 2023',
name: 'Hermès Spring-Summer 2023 Menswear',
sex: Sex.MAN,
season: {
connectOrCreate: {
where: { name_year: { name: season.name, year: season.year } },
Expand All @@ -582,7 +583,7 @@ const collection: Prisma.CollectionCreateInput = {
links: { connectOrCreate: { where: { url: link.url }, create: link } },
}
export const show: Prisma.ShowCreateInput = {
name: 'Hermès Spring-Summer 2023',
name: 'Hermès Spring-Summer 2023 Menswear',
url: 'https://www.hermes.com/us/en/story/302944-men-summer-2023-runway-show/',
description: `A bright, vibrant summer; the joy of being together. The vacation spirit, a magic destination both joyous and serene, with the breeze imperceptibly ruffling the clothes that enfold you. A feeling of lightness makes you float in the sunlight.
Expand Down
3 changes: 2 additions & 1 deletion scripts/node/save/shows/isabel-marant.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Prisma, Tier, SeasonName } from '@prisma/client'
import { type Prisma, Sex, Tier, SeasonName } from '@prisma/client'

const NUM_LOOKS = 59

Expand Down Expand Up @@ -220,6 +220,7 @@ const brand: Prisma.BrandCreateInput = {
}
const collection: Prisma.CollectionCreateInput = {
name: 'Isabel Marant Fall-Winter 2023',
sex: Sex.WOMAN,
season: {
connectOrCreate: {
where: { name_year: { name: season.name, year: season.year } },
Expand Down

0 comments on commit 66e190f

Please sign in to comment.