fix: bug fixes

This commit is contained in:
2026-07-02 15:28:58 -07:00
parent 1f84e78690
commit 227ce67f4d
8 changed files with 91 additions and 20 deletions
+38
View File
@@ -0,0 +1,38 @@
-- Create a temp table
CREATE TABLE torrent_tmp (
infohash text NOT NULL,
name text NOT NULL,
size_bytes bigint NOT NULL,
created_unix bigint NOT NULL,
seeders integer NOT NULL,
leechers integer NOT NULL,
completed integer NOT NULL,
scraped_date bigint NOT NULL,
published bigint NOT NULL
);
-- Copy from csv
COPY torrent_tmp
FROM
'../torrents.csv' WITH (
FORMAT csv,
HEADER);
-- default sort by seeders
CREATE TABLE torrent AS
SELECT
*
FROM
torrent_tmp
ORDER BY
seeders DESC;
-- Add the identity column
ALTER TABLE torrent
ADD COLUMN id int GENERATED ALWAYS AS IDENTITY,
ADD COLUMN name_search tsvector GENERATED ALWAYS AS (to_tsvector('english', name)) STORED;
CREATE INDEX idx_name ON torrent USING gin (name_search);
DROP TABLE torrent_tmp;