Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24 add orm #34

Merged
merged 8 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
526 changes: 526 additions & 0 deletions components/Accordions.tsx

Large diffs are not rendered by default.

1,292 changes: 425 additions & 867 deletions components/FilterOption.tsx

Large diffs are not rendered by default.

37 changes: 16 additions & 21 deletions components/PartsTab.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
import { filterOptions, productInfo, productType } from "@/types";
import { useEffect, useState } from "react";
import { Button, Container } from "react-bootstrap";
import initSqlJs from "sql.js";
import { DataSource } from "typeorm";
import FilterOption from "./FilterOption";
import ProductList from "./ProductList";
import SelectedProduct from "./SelectedProduct";

export default function PartsTab({
type,
buf,
sql,
dataSource,
}: {
type: keyof productType;
buf: ArrayBuffer;
sql: initSqlJs.SqlJsStatic;
dataSource: DataSource | undefined;
}) {
const [originProducts, setOriginProducts] = useState<productInfo[]>();
const [convertedProducts, setConvertedProducts] = useState<productInfo[]>();

useEffect(() => {
if (buf && sql) {
const db = new sql.Database(new Uint8Array(buf));
let productList: productInfo[] = [];
db.each(
`SELECT * FROM ${type} LIMIT 30`,
(row) => {
productList.push(row as productInfo);
},
() => {},
);
console.log(productList);
setOriginProducts(productList);
setConvertedProducts(productList);
if (dataSource) {
(async () => {
let productList: productInfo[] = [];

productList = (await dataSource.manager.query(
`SELECT * FROM ${type} LIMIT 30`,
)) as productInfo[];

setOriginProducts(productList);
setConvertedProducts(productList);
})();
}
}, [buf, sql, type]);
}, [dataSource, type]);

const [submittedFilterOption, setSubmittedFilterOption] =
useState<filterOptions>({
Expand Down Expand Up @@ -65,8 +61,7 @@ export default function PartsTab({
show={show}
handleClose={() => handleClose()}
type={type}
buf={buf}
sql={sql}
dataSource={dataSource}
setConvertedProducts={setConvertedProducts}
submittedFilterOption={submittedFilterOption}
setSubmittedFilterOption={setSubmittedFilterOption}
Expand Down
1 change: 0 additions & 1 deletion components/ProductList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export default function ProductList({
onClick={() => {
let newSelectedProducts = Object.assign({}, selectedProducts);
newSelectedProducts[id] = iterator;
console.log(newSelectedProducts);
// ここで無限ループ😇
setSelectedProducts(newSelectedProducts);
}}
Expand Down
58 changes: 58 additions & 0 deletions db/Cpu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Column, Entity, PrimaryColumn } from "typeorm";

@Entity("cpu")
export class Cpu {
@PrimaryColumn("text")
id!: string;

@Column("text", { nullable: true })
name!: string | null;

@Column("bigint", { nullable: true })
price!: number | null;

@Column("bigint", { nullable: true })
sales_rank!: number | null;

@Column("float", { nullable: true })
review_score!: number | null;

@Column("bigint", { nullable: true })
bbs_count!: number | null;

@Column("text", { nullable: true })
date!: string | null;

@Column("text", { nullable: true })
manufacturer!: string | null;

@Column("text", { nullable: true })
cpu_name!: string | null;

@Column("text", { nullable: true })
codename!: string | null;

@Column("float", { nullable: true })
frequency!: number | null;

@Column("text", { nullable: true })
socket!: string | null;

@Column("bigint", { nullable: true })
core_count!: number | null;

@Column("bigint", { nullable: true })
thread_count!: number | null;

@Column("text", { nullable: true })
gpu!: string | null;

@Column("bigint", { nullable: true })
multi_thread_score!: number | null;

@Column("bigint", { nullable: true })
single_thread_score!: number | null;

@Column("bigint", { nullable: true })
tdp!: number | null;
}
49 changes: 49 additions & 0 deletions db/Gpu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Column, Entity, PrimaryColumn } from "typeorm";

@Entity("gpu")
export class Gpu {
@PrimaryColumn("text")
id!: string;

@Column("text", { nullable: true })
name!: string | null;

@Column("bigint", { nullable: true })
price!: number | null;

@Column("bigint", { nullable: true })
sales_rank!: number | null;

@Column("float", { nullable: true })
review_score!: number | null;

@Column("bigint", { nullable: true })
bbs_count!: number | null;

@Column("text", { nullable: true })
date!: string | null;

@Column("text", { nullable: true })
manufacturer!: string | null;

@Column("text", { nullable: true })
gpu_name!: string | null;

@Column("text", { nullable: true })
bus_interface!: string | null;

@Column("text", { nullable: true })
slot!: string | null;

@Column("text", { nullable: true })
standard!: string | null;

@Column("text", { nullable: true })
capacity!: string | null;

@Column("text", { nullable: true })
monitor!: string | null;

@Column("bigint", { nullable: true })
score!: number | null;
}
43 changes: 43 additions & 0 deletions db/Memory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Column, Entity, PrimaryColumn } from "typeorm";

@Entity("memory")
export class Memory {
@PrimaryColumn("text")
id!: string;

@Column("text", { nullable: true })
name!: string | null;

@Column("bigint", { nullable: true })
price!: number | null;

@Column("bigint", { nullable: true })
sales_rank!: number | null;

@Column("float", { nullable: true })
review_score!: number | null;

@Column("bigint", { nullable: true })
bbs_count!: number | null;

@Column("text", { nullable: true })
date!: string | null;

@Column("text", { nullable: true })
manufacturer!: string | null;

@Column("text", { nullable: true })
capacity!: string | null;

@Column("bigint", { nullable: true })
pcs!: number | null;

@Column("text", { nullable: true })
standard!: string | null;

@Column("text", { nullable: true })
interface!: string | null;

@Column("bigint", { nullable: true })
price_per_gb!: number | null;
}
43 changes: 43 additions & 0 deletions db/Motherboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Column, Entity, PrimaryColumn } from "typeorm";

@Entity("motherboard")
export class Motherboard {
@PrimaryColumn("text")
id!: string;

@Column("text", { nullable: true })
name!: string | null;

@Column("bigint", { nullable: true })
price!: number | null;

@Column("bigint", { nullable: true })
sales_rank!: number | null;

@Column("float", { nullable: true })
review_score!: number | null;

@Column("bigint", { nullable: true })
bbs_count!: number | null;

@Column("text", { nullable: true })
date!: string | null;

@Column("text", { nullable: true })
manufacturer!: string | null;

@Column("text", { nullable: true })
form_factor!: string | null;

@Column("text", { nullable: true })
socket!: string | null;

@Column("text", { nullable: true })
chipset!: string | null;

@Column("text", { nullable: true })
memory!: string | null;

@Column("text", { nullable: true })
gpu!: string | null;
}
46 changes: 46 additions & 0 deletions db/Ssd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Column, Entity, PrimaryColumn } from "typeorm";

@Entity("ssd")
export class Ssd {
@PrimaryColumn("text")
id!: string;

@Column("text", { nullable: true })
name!: string | null;

@Column("bigint", { nullable: true })
price!: number | null;

@Column("bigint", { nullable: true })
sales_rank!: number | null;

@Column("float", { nullable: true })
review_score!: number | null;

@Column("bigint", { nullable: true })
bbs_count!: number | null;

@Column("text", { nullable: true })
date!: string | null;

@Column("text", { nullable: true })
manufacturer!: string | null;

@Column("text", { nullable: true })
capacity!: string | null;

@Column("bigint", { nullable: true })
price_per_gb!: number | null;

@Column("text", { nullable: true })
cell_type!: string | null;

@Column("text", { nullable: true })
size!: string | null;

@Column("text", { nullable: true })
interface!: string | null;

@Column("bigint", { nullable: true })
tbw!: number | null;
}
27 changes: 27 additions & 0 deletions json/cpu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"core_count": [
2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 32, 36, 44, 48, 56, 64,
72, 84, 96, 112, 120, 128, 144
],
"socket": [
"LGA1150",
"LGA1151",
"LGA1155",
"LGA1156",
"LGA1200",
"LGA1700",
"LGA1851",
"LGA2011",
"LGA2011-3",
"LGA2066",
"LGA3647",
"LGA4189",
"LGA4677",
"LGA775",
"Socket AM4",
"Socket AM5",
"Socket F",
"Socket sTR5",
"Socket sWRX8"
]
}
Loading