Commit 54be32f3 authored by Štěpán Dvorský's avatar Štěpán Dvorský
Browse files

refactor(backend): delete old seed/sample data code

parent 53119e97
Loading
Loading
Loading
Loading

backend/src/seed/build.ts

deleted100644 → 0
+0 −44
Original line number Diff line number Diff line
import { Build } from '@pcbuilder/common/api';
import memory from './memory';
import motherboard from './motherboard';
import processor from './processor';
import videoCard from './videoCard';

const findId = <T extends { id: string }>(data: T[], id: string) => {
  const found = data.find((obj) => obj.id === id);
  if (found === undefined) {
    throw Error(`No record with ID ${id} can be found`);
  }
  return found;
};

const findName = <T extends { name: string }>(data: T[], name: RegExp) => {
  const found = data.find((obj) => obj.name.match(name));
  if (found === undefined) {
    throw Error(`No record with name matching ${name} can be found`);
  }
  return found;
};

export default [
  new Build({
    id: 'Entry Level AMD Gaming Build',
    processor: findName(processor, /Ryzen 5 5600G/),
    motherboard: findName(motherboard, /ASRock B550M-HDV/),
    memory: findId(
      memory,
      'G.Skill Aegis 16 GB (2 x 8 GB) DDR4-3200 CL16 Memory'
    ),
    videoCard: null,
  }),
  new Build({
    id: 'Great AMD Gaming Build',
    processor: findName(processor, /Ryzen 5 7600X/),
    motherboard: findName(motherboard, /Gigabyte B650M K/),
    memory: findId(
      memory,
      'Corsair Vengeance LPX 16 GB (2 x 8 GB) DDR4-3200 CL16 Memory'
    ),
    videoCard: findName(videoCard, /Radeon RX 7900 XT/),
  }),
];

backend/src/seed/common.ts

deleted100644 → 0
+0 −1
Original line number Diff line number Diff line
export const idAndName = (name: string) => ({ id: name, name });

backend/src/seed/dataset.ts

deleted100644 → 0
+0 −740
Original line number Diff line number Diff line
/*
import type {
  Category,
  Preset,
  Build,
  Processor,
  Motherboard,
  Memory,
  VideoCard,
  Socket,
  FormFactor,
  IntegratedGraphics,
  Manufacturer,
  VideoChipset,
  PcieGeneration,
  MotherboardPcieSlot,
  MotherboardChipset,
  MemoryGeneration,
} from '@prisma/client';
*/

// (Category & {
//   presets: (Preset & .....)
// })[]      types

const data = [
  {
    id: '9c8e0662-58d9-45f7-ba89-71a7871d0fd9',
    name: 'Gaming',
    description: 'PC presets optimized for gaming performance.',
    presets: [
      {
        id: 'a3aa49f9-d6e3-44d1-9176-0bebbc4ec29c',
        name: 'Gaming PC',
        description: 'High-performance PC optimized for gaming.',
        build: {
          id: '6eeb3dac-bb96-40fb-a56a-ea43da1f534f',
          processor: {
            id: '07dce455-00c3-4616-9c30-a927a22a1a7d',
            name: 'AMD Ryzen 7',
            price: 299.99,
            manufacturer: {
              id: '',
              name: 'AMD',
            },
            socket: {
              id: 'db8ae0db-0734-4f27-920f-58e3a11908ec',
              name: 'AM4',
            },
            integratedGraphics: {
              id: '',
              name: '',
            },
            image: '',
          },
          motherboard: {
            id: 'e0fc37ef-748d-4966-adf9-f2be6093e767',
            name: 'ASUS ROG Strix B450-F',
            price: 149.99,
            memorySlotCount: 4,
            formFactor: {
              id: '',
              name: 'ATX',
            },
            manufacturer: {
              id: '9f3df317-c62f-41b0-98a9-3f88a4aa34cf',
              name: 'ASUS',
            },
            chipset: {
              id: '',
              name: 'AMD B450',
            },
            socket: {
              id: '',
              name: 'AM4',
            },
            pcieSlots: [
              {
                id: '',
                size: 16,
                count: 1,
              },
              {
                id: '',
                size: 4,
                count: 2,
              },
            ],
            image: '',
          },
          memory: {
            id: '',
            name: 'Corsair Vengeance LPX',
            price: 99.99,
            image: '',
            manufacturer: {
              id: 'edfeef0e-07e2-4b9e-9aaf-20892477fb3d',
              name: 'Corsair',
            },
            memoryGeneration: {
              id: '',
              name: '',
            },
          },
          videocard: {
            id: '',
            name: 'NVIDIA GeForce RTX 3060 Ti',
            price: 399.99,
            slotSize: 2,
            image: '',
            manufacturer: {
              id: 'ee777f3a-3d17-4dc0-86ff-15c76f6142bd',
              name: 'NVIDIA',
            },
            pcieGeneration: {
              id: '',
              name: '',
            },
            chipset: {
              id: '',
              name: '',
              manufacturer: {
                id: '',
                name: '',
              },
            },
          },
        },
      },
      {
        id: '',
        name: 'Streaming PC',
        description: 'A PC built for live streaming and content creation.',
        build: {
          id: '',
          processor: {
            id: '',
            name: 'Intel Core i9',
            price: 499.99,
            manufacturer: {
              id: '65b80be9-59ee-423c-94a9-cd9cd3b7a0f7',
              name: 'Intel',
            },
            socket: {
              id: '',
              name: '',
            },
            integratedGraphics: {
              id: '',
              name: '',
            },
            image: '',
          },
          motherboard: {
            id: '',
            name: 'Gigabyte Z590 AORUS Ultra',
            price: 349.99,
            memorySlotCount: 4,
            manufacturer: {
              id: 'af5761e0-12ba-4d6a-83e1-af3fa461aa0d',
              name: 'Gigabyte',
            },
            formFactor: {
              id: '',
              name: 'ATX',
            },
            chipset: {
              id: '',
              name: 'Intel Z590',
            },
            socket: {
              id: '',
              name: 'LGA 1200',
            },
            pcieSlots: [
              {
                id: '',
                size: 16,
                count: 2,
              },
              {
                id: '',
                size: 8,
                count: 1,
              },
            ],
            image: '',
          },
          memory: {
            id: '',
            name: 'Corsair Dominator Platinum RGB',
            price: 199.99,
            image: '',
            manufacturer: {
              id: 'edfeef0e-07e2-4b9e-9aaf-20892477fb3d',
              name: 'Corsair',
            },
            memoryGeneration: {
              id: '',
              name: '',
            },
          },
          videocard: {
            id: '',
            name: 'NVIDIA GeForce RTX 3080',
            price: 799.99,
            slotSize: 2,
            image: '',
            manufacturer: {
              id: 'ee777f3a-3d17-4dc0-86ff-15c76f6142bd',
              name: 'NVIDIA',
            },
            pcieGeneration: {
              id: '',
              name: '',
            },
            chipset: {
              id: '',
              name: '',
              manufacturer: {
                id: '',
                name: '',
              },
            },
          },
        },
      },
    ],
  },
  {
    id: '',
    name: 'Office',
    description: 'PC presets optimized for office productivity.',
    presets: [
      {
        id: '',
        name: 'Basic Office PC - processor without integrated graphics',
        description: 'An entry-level PC for office productivity.',
        build: {
          id: '',
          processor: {
            id: '',
            name: 'Intel Core i3',
            price: 199.99,
            manufacturer: {
              id: '65b80be9-59ee-423c-94a9-cd9cd3b7a0f7',
              name: 'Intel',
            },
            socket: {
              id: '',
              name: '',
            },
            integratedGraphics: null,
            image: '',
          },
          motherboard: {
            id: '',
            name: 'ASUS Prime H410M-A',
            price: 79.99,
            memorySlotCount: 2,
            manufacturer: {
              id: '9f3df317-c62f-41b0-98a9-3f88a4aa34cf',
              name: 'ASUS',
            },
            formFactor: {
              id: '',
              name: 'Micro ATX',
            },
            chipset: {
              id: '',
              name: 'Intel H410',
            },
            socket: {
              id: '',
              name: 'LGA 1200',
            },
            pcieSlots: [
              {
                id: '',
                size: 16,
                count: 1,
              },
              {
                id: '',
                size: 1,
                count: 2,
              },
            ],
            image: '',
          },
          memory: {
            id: '',
            name: 'Crucial Ballistix DDR4',
            price: 69.99,
            image: '',
            manufacturer: {
              id: '',
              name: '',
            },
            memoryGeneration: {
              id: '',
              name: '',
            },
          },
          videocard: {
            id: '',
            name: 'Integrated Graphics',
            price: 0,
            slotSize: 0,
            image: '',
            manufacturer: {
              id: 'ee777f3a-3d17-4dc0-86ff-15c76f6142bd',
              name: 'NVIDIA',
            },
            pcieGeneration: {
              id: '',
              name: '',
            },
            chipset: {
              id: '',
              name: '',
              manufacturer: {
                id: '',
                name: '',
              },
            },
          },
        },
      },
      {
        id: '',
        name: 'Mid-range Office PC',
        description: 'A balanced PC for general office tasks.',
        build: {
          id: '',
          processor: {
            id: '',
            name: 'Intel Core i5',
            price: 299.99,
            manufacturer: {
              id: '65b80be9-59ee-423c-94a9-cd9cd3b7a0f7',
              name: 'Intel',
            },
            socket: {
              id: '',
              name: '',
            },
            integratedGraphics: {
              id: '',
              name: '',
            },
            image: '',
          },
          motherboard: {
            id: '',
            name: 'ASRock B560 Pro4',
            price: 129.99,
            memorySlotCount: 4,
            formFactor: {
              id: '',
              name: 'ATX',
            },
            manufacturer: {
              id: '46c606be-0fa6-4454-8524-fc0454562a8c',
              name: 'ASRock',
            },
            chipset: {
              id: '',
              name: 'Intel B560',
            },
            socket: {
              id: '',
              name: 'LGA 1200',
            },
            pcieSlots: [
              {
                id: '',
                size: 16,
                count: 1,
              },
              {
                id: '',
                size: 4,
                count: 2,
              },
            ],
            image: '',
          },
          memory: {
            id: '',
            name: 'G.Skill Trident Z Neo',
            price: 129.99,
            image: '',
            manufacturer: {
              id: 'ad233a73-6742-4fca-ae19-19f2ec31ef9f',
              name: 'G.Skill',
            },
            memoryGeneration: {
              id: '',
              name: '',
            },
          },
          videocard: {
            id: '',
            name: 'Integrated Graphics',
            price: 0,
            slotSize: 0,
            image: '',
            manufacturer: {
              id: 'ee777f3a-3d17-4dc0-86ff-15c76f6142bd',
              name: 'NVIDIA',
            },
            pcieGeneration: {
              id: '',
              name: '',
            },
            chipset: {
              id: '',
              name: '',
              manufacturer: {
                id: '',
                name: '',
              },
            },
          },
        },
      },
      {
        id: '',
        name: 'High-performance Office PC',
        description: 'A powerful PC for demanding office applications.',
        build: {
          id: '',
          processor: {
            id: '',
            name: 'Intel Core i7',
            price: 399.99,
            manufacturer: {
              id: '65b80be9-59ee-423c-94a9-cd9cd3b7a0f7',
              name: 'Intel',
            },
            socket: {
              id: '',
              name: '',
            },
            integratedGraphics: {
              id: '',
              name: '',
            },
            image: '',
          },
          motherboard: {
            id: '',
            name: 'MSI MAG B560 Tomahawk',
            price: 179.99,
            memorySlotCount: 4,
            manufacturer: {
              id: '26cdffbb-ec68-4ca8-9063-f3b3e8a9e434',
              name: 'MSI',
            },
            formFactor: {
              id: '',
              name: 'ATX',
            },
            chipset: {
              id: '',
              name: 'Intel B560',
            },
            socket: {
              id: '',
              name: 'LGA 1200',
            },
            pcieSlots: [
              {
                id: '',
                size: 16,
                count: 2,
              },
              {
                id: '',
                size: 4,
                count: 1,
              },
            ],
            image: '',
          },
          memory: {
            id: '',
            name: 'Corsair Vengeance RGB Pro',
            price: 149.99,
            image: '',
            manufacturer: {
              id: 'edfeef0e-07e2-4b9e-9aaf-20892477fb3d',
              name: 'Corsair',
            },
            memoryGeneration: {
              id: '',
              name: '',
            },
          },
          videocard: {
            id: '',
            name: 'Integrated Graphics',
            price: 0,
            slotSize: 0,
            image: '',
            manufacturer: {
              id: 'ee777f3a-3d17-4dc0-86ff-15c76f6142bd',
              name: 'NVIDIA',
            },
            pcieGeneration: {
              id: '',
              name: '',
            },
            chipset: {
              id: '',
              name: '',
              manufacturer: {
                id: '',
                name: '',
              },
            },
          },
        },
      },
    ],
  },
  {
    id: '',
    name: 'Work',
    description: 'PC presets tailored for graphic design tasks.',
    presets: [
      {
        id: '',
        name: 'Graphic Design PC',
        description: 'Powerful PC for graphic design work.',
        build: {
          id: '',
          processor: {
            id: '',
            name: 'AMD Ryzen 9',
            price: 599.99,
            manufacturer: {
              id: 'fdddd91d-7cce-4e2c-a698-f8b60794372f',
              name: 'AMD',
            },
            socket: {
              id: '',
              name: '',
            },
            integratedGraphics: {
              id: '',
              name: '',
            },
            image: '',
          },
          motherboard: {
            id: '',
            name: 'ASUS ROG Strix X570-E',
            price: 299.99,
            memorySlotCount: 4,
            manufacturer: {
              id: '',
              name: '',
            },
            formFactor: {
              id: '',
              name: 'ATX',
            },
            chipset: {
              id: '',
              name: 'AMD X570',
            },
            socket: {
              id: '',
              name: 'AM4',
            },
            pcieSlots: [
              {
                id: '',
                size: 16,
                count: 2,
              },
              {
                id: '',
                size: 4,
                count: 1,
              },
            ],
            image: '',
          },
          memory: {
            id: '',
            name: 'G.Skill Ripjaws V',
            price: 199.99,
            image: '',
            manufacturer: {
              id: '',
              name: '',
            },
            memoryGeneration: {
              id: '',
              name: '',
            },
          },
          videocard: {
            id: '',
            name: 'NVIDIA GeForce RTX 3070',
            price: 699.99,
            slotSize: 2,
            image: '',
            manufacturer: {
              id: 'ee777f3a-3d17-4dc0-86ff-15c76f6142bd',
              name: 'NVIDIA',
            },
            pcieGeneration: {
              id: '',
              name: '',
            },
            chipset: {
              id: '',
              name: '',
              manufacturer: {
                id: '',
                name: '',
              },
            },
          },
        },
      },
    ],
  },
  {
    id: '',
    name: 'High-End',
    description: 'PC presets optimized for video editing workflows.',
    presets: [
      {
        id: '',
        name: 'High-End pc',
        description: 'High end pc for ultimate pcmasters.',
        build: {
          id: '',
          processor: {
            id: '',
            name: 'Intel Core i9',
            price: 499.99,
            manufacturer: {
              id: '65b80be9-59ee-423c-94a9-cd9cd3b7a0f7',
              name: 'Intel',
            },
            socket: {
              id: '',
              name: '',
            },
            integratedGraphics: {
              id: '',
              name: '',
            },
            image: '',
          },
          motherboard: {
            id: '',
            name: 'ASUS ROG Maximus XIII Hero',
            price: 499.99,
            memorySlotCount: 4,
            manufacturer: {
              id: '',
              name: '',
            },
            formFactor: {
              id: '',
              name: 'ATX',
            },
            chipset: {
              id: '',
              name: 'Intel Z590',
            },
            socket: {
              id: '',
              name: 'LGA 1200',
            },
            pcieSlots: [
              {
                id: '',
                size: 16,
                count: 2,
              },
              {
                id: '',
                size: 8,
                count: 1,
              },
            ],
            image: '',
          },
          memory: {
            id: '',
            name: 'Corsair Dominator Platinum RGB',
            price: 199.99,
            image: '',
            manufacturer: {
              id: '',
              name: '',
            },
            memoryGeneration: {
              id: '',
              name: '',
            },
          },
          videocard: {
            id: '',
            name: 'NVIDIA GeForce RTX 3090',
            price: 1499.99,
            slotSize: 3,
            image: '',
            manufacturer: {
              id: 'ee777f3a-3d17-4dc0-86ff-15c76f6142bd',
              name: 'NVIDIA',
            },
            pcieGeneration: {
              id: '',
              name: '',
            },
            chipset: {
              id: '',
              name: '',
              manufacturer: {
                id: '',
                name: '',
              },
            },
          },
        },
      },
    ],
  },
];

export default data;

backend/src/seed/index.ts

deleted100644 → 0
+0 −0

Empty file deleted.

backend/src/seed/memory.ts

deleted100644 → 0
+0 −21
Original line number Diff line number Diff line
import { Manufacturer, Memory, MemoryGeneration } from '@pcbuilder/common/api';
import { idAndName } from './common';
import data from './data/memory.json';

export default data.map(
  ({
    $title,
    $price,
    Manufacturer: manufacturer,
    Speed: generationAndSpeed,
  }) => {
    const [generation] = generationAndSpeed.split('-');
    return new Memory({
      ...idAndName($title),
      price: $price,
      manufacturer: new Manufacturer(idAndName(manufacturer)),
      memoryGeneration: new MemoryGeneration(idAndName(generation!)),
      image: '',
    });
  }
);
Loading