Skip to content

Commit

Permalink
Merge pull request #12 from falsepopsky/dev
Browse files Browse the repository at this point in the history
db: add banlist `23/04/2024`
  • Loading branch information
falsepopsky authored Apr 18, 2024
2 parents 416dc97 + 3893ae5 commit 7175a1c
Show file tree
Hide file tree
Showing 18 changed files with 2,936 additions and 2,349 deletions.
7 changes: 3 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{
"name": "Forbidden Duel Links Dev Container",
"name": "Forbidden Duel Links",
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"nodeGypDependencies": true,
"version": "20.11.1",
"version": "20.12.2",
"nvmVersion": "latest"
}
},
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"bradlc.vscode-tailwindcss",
"prisma.prisma",
"pkief.material-icon-theme",
"github.vscode-github-actions",
"github.vscode-pull-request-github"
]
Expand Down
20 changes: 13 additions & 7 deletions .github/labeler.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
"🌐 web":
- "app/**"
- changed-files:
- any-glob-to-any-file: app/**
"📚 docs":
- "README.md"
- changed-files:
- any-glob-to-any-file: README.md
"💽 db":
- "prisma/**"
- "lib/**"
- changed-files:
- any-glob-to-any-file:
- prisma/**
- lib/**
"⚙️ configs":
- ".prettierrc"
- "next.config.js"
- ".eslintrc.json"
- changed-files:
- any-glob-to-any-file:
- ".prettierrc"
- next.config.js
- ".eslintrc.json"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- main

env:
PNPM_VERSION: 8.15.3
PNPM_VERSION: 9.0.2

jobs:
lint:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/labeler.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Labeler
on: [pull_request]
on: pull_request

jobs:
labeler:
Expand All @@ -9,7 +9,6 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4.3.0
- uses: actions/labeler@v5.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/labeler.yaml
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.11.1
v20.12.2
3 changes: 0 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
"[prisma]": {
"editor.defaultFormatter": "Prisma.prisma"
},
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "/.github/workflows/*.yml"
},
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ all the latest information on banned and limited cards

`Forbidden Duel Links` is licensed under the
[Apache-2.0](https://github.com/falsepopsky/forbidden-duel-links/blob/main/LICENSE) license - ©
2023 [falsepopsky](https://github.com/falsepopsky).
2023 - Present [falsepopsky](https://github.com/falsepopsky).
8 changes: 0 additions & 8 deletions app/ThemeProvider.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Metadata, Viewport } from 'next';
import { ThemeProvider } from 'next-themes';
import { IBM_Plex_Sans } from 'next/font/google';
import { Navbar } from './NavBar';
import Theme from './ThemeProvider';
import './globals.css';

const ibm_plex_sans = IBM_Plex_Sans({
Expand Down Expand Up @@ -30,10 +30,10 @@ export default function RootLayout({ children }: { children: React.ReactNode })
return (
<html lang='en' suppressHydrationWarning className={ibm_plex_sans.className}>
<body className='bg-slate-100 text-zinc-800 selection:bg-neutral-900 selection:text-neutral-300 dark:bg-neutral-900 dark:text-slate-100 dark:selection:bg-neutral-300 dark:selection:text-neutral-900'>
<Theme attribute='class'>
<ThemeProvider attribute='class'>
<Navbar />
{children}
</Theme>
</ThemeProvider>
</body>
</html>
);
Expand Down
10 changes: 5 additions & 5 deletions app/rush/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatDateToISO, getBanlistByDate, getBanlistByFormat } from '@/lib/queries';
import { formatDateToISO, getRushBanlistByDate, getRushBanlists } from '@/lib/queries';
import { type Metadata } from 'next';
import Link from 'next/link';
import { Tab } from '../../Tab';
Expand All @@ -13,7 +13,7 @@ interface ParamsProps {
}

export async function generateStaticParams() {
const data = await getBanlistByFormat(2);
const data = await getRushBanlists();

return data.map(({ slug }) => ({
slug,
Expand Down Expand Up @@ -100,12 +100,12 @@ export default async function Post({ params }: ParamsProps) {
const { slug } = params;

const date = formatDateToISO(slug);
const data = await getBanlistByDate(date, 2);
const data = await getRushBanlistByDate(date);

const filterByTypeRestriction = (type: string) => {
const typeExists = data?.restrictions.some((card) => card.type.name === type);
const typeExists = data?.RushRestriction.some((card) => card.type.name === type);
if (!typeExists) return null;
return data?.restrictions.filter((card) => card.type.name === type);
return data?.RushRestriction.filter((card) => card.type.name === type);
};

const free = filterByTypeRestriction('No Longer on List');
Expand Down
4 changes: 2 additions & 2 deletions app/rush/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getBanlistByFormat } from '@/lib/queries';
import { getRushBanlists } from '@/lib/queries';
import Link from 'next/link';

export default async function Banlist() {
const years = ['2024', '2023'];
const data = await getBanlistByFormat(2);
const data = await getRushBanlists();
const dates = data?.map(({ id, slug }) => {
return {
id,
Expand Down
10 changes: 5 additions & 5 deletions app/speed/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatDateToISO, getBanlistByDate, getBanlistByFormat } from '@/lib/queries';
import { formatDateToISO, getSpeedBanlistByDate, getSpeedBanlists } from '@/lib/queries';
import { type Metadata } from 'next';
import Link from 'next/link';
import { Tab } from '../../Tab';
Expand All @@ -13,7 +13,7 @@ interface ParamsProps {
}

export async function generateStaticParams() {
const data = await getBanlistByFormat(1);
const data = await getSpeedBanlists();

return data.map(({ slug }) => ({
slug,
Expand Down Expand Up @@ -100,12 +100,12 @@ export default async function Post({ params }: ParamsProps) {
const { slug } = params;

const date = formatDateToISO(slug);
const data = await getBanlistByDate(date, 1);
const data = await getSpeedBanlistByDate(date);

const filterByTypeRestriction = (type: string) => {
const typeExists = data?.restrictions.some((card) => card.type.name === type);
const typeExists = data?.SpeedRestriction.some((card) => card.type.name === type);
if (!typeExists) return null;
return data?.restrictions.filter((card) => card.type.name === type);
return data?.SpeedRestriction.filter((card) => card.type.name === type);
};

const free = filterByTypeRestriction('No Longer on List');
Expand Down
4 changes: 2 additions & 2 deletions app/speed/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getBanlistByFormat } from '@/lib/queries';
import { getSpeedBanlists } from '@/lib/queries';
import Link from 'next/link';

export default async function Banlist() {
const years = ['2024', '2023', '2022', '2021', '2020', '2019', '2018', '2017'];
const data = await getBanlistByFormat(1);
const data = await getSpeedBanlists();
const dates = data?.map(({ id, slug }) => {
return {
id,
Expand Down
65 changes: 51 additions & 14 deletions lib/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,71 @@ export function formatDateToISO(date: string): string {
}
}

export async function getBanlistByFormat(format: number) {
const data = await prisma.banlist.findMany({
export async function getRushBanlists() {
const data = await prisma.rushBanlist.findMany();

if (!data) {
throw new Error('Rush banlist schema is empty');
}

return data;
}

export async function getRushBanlistByDate(date: string) {
const data = await prisma.rushBanlist.findFirst({
where: {
date: {
gte: '2017-01-01T00:00:00Z',
lt: '2025-01-01T00:00:00Z',
date,
},
include: {
RushRestriction: {
select: {
card: {
select: {
name: true,
type: {
select: {
name: true,
},
},
},
},
type: {
select: {
name: true,
},
},
},
orderBy: {
type: { name: 'asc' },
},
},
formatId: format,
},
});

if (!data) {
throw new Error('Banlist schema is empty');
throw new Error(`There are no banlist records for the date: ${date}`);
}

return data;
}

export async function getBanlistByDate(date: string, format: number) {
const data = await prisma.banlist.findFirst({
export async function getSpeedBanlists() {
const data = await prisma.speedBanlist.findMany();

if (!data) {
throw new Error('Rush banlist schema is empty');
}

return data;
}

export async function getSpeedBanlistByDate(date: string) {
const data = await prisma.speedBanlist.findFirst({
where: {
AND: {
formatId: format,
date,
},
date,
},
include: {
restrictions: {
SpeedRestriction: {
select: {
card: {
select: {
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,33 @@
"postinstall": "prisma generate"
},
"dependencies": {
"@prisma/client": "^5.10.2",
"next": "^14.1.0",
"next-themes": "^0.2.1",
"@prisma/client": "^5.12.1",
"next": "^14.2.2",
"next-themes": "^0.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-tabs": "^1.0.4",
"@types/node": "^20.11.19",
"@types/react": "^18.2.57",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"autoprefixer": "^10.4.17",
"eslint": "^8.56.0",
"eslint-config-next": "^14.1.0",
"@types/node": "^20.12.7",
"@types/react": "^18.2.79",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-config-next": "^14.2.2",
"eslint-config-prettier": "^9.1.0",
"postcss": "^8.4.35",
"postcss": "^8.4.38",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.11",
"prisma": "^5.10.2",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"prettier-plugin-tailwindcss": "^0.5.14",
"prisma": "^5.12.1",
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5"
},
"engines": {
"node": "^18.18.2 || ^20.0.0",
"pnpm": ">=8"
"node": "^20.0.0",
"pnpm": ">=9"
},
"packageManager": "pnpm@8.15.3+sha256.fc4a49bd609550a41e14d20efbce802a4b892aa4cac877322de2f0924f122991"
"packageManager": "pnpm@9.0.2+sha256.d6fc013639b81658ff175829ebb9435bcb89eff206769e460fd3ae27c2054df6"
}
Loading

0 comments on commit 7175a1c

Please sign in to comment.