Start working on speeding up imports

This commit is contained in:
The Magician 2024-05-19 20:29:50 +01:00
parent af27b138bc
commit 72452ee2fa
3 changed files with 18 additions and 140 deletions

View File

@ -1,7 +1,8 @@
removedb: removedb:
mysql --user=root --password=$(shell pass show sevenkeys/mysql) <sql/removedb.sql mysql --user=root --password=$(shell pass show sevenkeys/mysql) <sql/removedb.sql
createdb: createdb: removedb
mysql --user=root --password=$(shell pass show sevenkeys/mysql) <sql/createdb.sql mysql --user=root --password=$(shell pass show sevenkeys/mysql) <sql/createdb.sql
importsets: createdb
importcards: createdb go run cmd/importsets/main.go
importcards: importsets
go run cmd/importcards/main.go go run cmd/importcards/main.go

View File

@ -1,130 +0,0 @@
package types
type Colors []string
type RelatedCard struct {
Id string `json:"id"`
Object string `json:"object"`
Component string `json:"component"`
Name string `json:"name"`
TypeLine string `json:"type_line"`
ApiUri string `json:"uri"`
}
type CardFace struct {
Artist string `json:"artist"`
ArtistId string `json:"artist_id"`
ManaValue float32 `json:"cmc"`
ColorIndicator Colors `json:"color_indicator"`
Colors Colors `json:"colors"`
Defense string `json:"defense"`
FlavorText string `json:"flavor_text"`
IllustrationId string `json:"illustration_id"`
ImageUris map[string]string `json:"image_uris"` // TODO: Find out the structure of this object
Layout string `json:"layout"`
Loyalty string `json:"loyalty"`
ManaCost string `json:"mana_cost"`
Name string `json:"name"`
Object string `json:"object"`
OracleId string `json:"oracle_id"`
Power string `json:"power"`
PrintedName string `json:"printed_name"`
PrintedText string `json:"printed_text"`
PrintedTypeLine string `json:"printed_type_line"`
Toughness string `json:"toughness"`
TypeLine string `json:"type_line"`
Watermark string `json:"watermark"`
}
type Card struct {
// Core fields
ArenaId int `json:"arena_id"`
Id string `json:"id"`
Language string `json:"lang"`
MtgoId int `json:"mtgo_id"`
MtgoFoilid int `json:"mtgo_foil_id"`
MultiverseIds []int `json:"multiverse_ids"`
TcgplayerId int `json:"tcgplayer_id"`
TcgplayerEtchedId int `json:"tcgplayer_etched_id"`
Object string `json:"object"`
Layout string `json:"layout"`
OracleId string `json:"oracle_id"`
PrintsSearchUri string `json:"prints_search_uri"`
RulingsUri string `json:"rulings_uri"`
ScryfallUri string `json:"scryfall_uri"`
ApiUri string `json:"uri"`
// Gameplay fields
AllParts []RelatedCard `json:"all_parts"`
CardFaces []CardFace `json:"card_faces"`
ManaValue float32 `json:"cmc"`
ColorIdentity Colors `json:"color_identity"`
ColorIndicator Colors `json:"color_indicator"`
Colors Colors `json:"colors"`
Defense string `json:"defense"`
EdhrecRank int `json:"edhrec_rank"`
HandModifier string `json:"hand_modifier"`
Keywords []string `json:"keywords"`
Legalities map[string]string `json:"legalities"`
LifeModifier string `json:"life_modifier"`
Loyalty string `json:"loyalty"`
ManaCost string `json:"mana_cost"`
Name string `json:"name"`
OracleText string `json:"oracle_text"`
PennyDreadfulRank int `json:"penny_rank"`
Power string `json:"power"`
ProducedMana Colors `json:"produced_mana"`
ReserveList bool `json:"reserved"`
Toughness string `json:"toughness"`
TypeLine string `json:"type_line"`
// Printing fields
Artist string `json:"artist"`
ArtistIds []string `json:"artist_ids"`
AttractionLights []interface{} `json:"attraction_lights"` // TODO: Figure out schema
Booster bool `json:"booster"`
BorderColor string `json:"border_color"`
CardBackId string `json:"card_back_id"`
CollectorNumber string `json:"collector_number"`
ContentWarning bool `json:"content_warning"`
Digital bool `json:"digital"`
Finishes []interface{} `json:"finishes"` // TODO: Find out how flags are formatted
FlavorName string `json:"flavor_name"`
FlavorText string `json:"flavor_text"`
FrameEffects []string `json:"frame_effects"`
Frame string `json:"frame"`
FullArt bool `json:"full_art"`
Games []string `json:"games"`
HighresImage bool `json:"highres_image"`
IllustrationId string `json:"illustration_id"`
ImageStatus string `json:"image_status"`
ImageUris map[string]string `json:"image_uris"` // TODO: Find out shape of object
Oversized bool `json:"oversized"`
Prices map[string]string `json:"prices"`
PrintedName string `json:"printed_name"`
PrintedText string `json:"printed_text"`
PrintedTypeLine string `json:"printed_type_line"`
Promo bool `json:"promo"`
PromoTypes []string `json:"promo_types"`
PurchaseUris interface{} `json:"purchase_uris"` // TODO: Find out shape of object
Rarity string `json:"rarity"`
RelatedUris interface{} `json:"related_uris"` // TODO: Find out shape of object
ReleasedAt string `json:"released_at"` // TODO: Datetime type?
Reprint bool `json:"reprint"`
ScryfallSetUri string `json:"scryfall_set_uri"`
SetName string `json:"set_name"`
SetSearchUri string `json:"set_search_uri"`
SetType string `json:"set_type"`
SetUri string `json:"set_uri"`
Set string `json:"set"`
SetId string `json:"set_id"`
StorySpotlight bool `json:"story_spotlight"`
Textless bool `json:"textless"`
Variation bool `json:"variation"`
VariationOf string `json:"variation_of"`
SecurityStamp string `json:"security_stamp"`
Watermark string `json:"watermark"`
PreviewedAt string `json:"preview.previewed_at"`
PreviewSourceUri string `json:"preview.source_uri"`
PreviewSource string `json:"preview.source"`
}

View File

@ -7,15 +7,22 @@ CREATE TABLE IF NOT EXISTS CacheTimestamps (
Stamp DATETIME NOT NULL Stamp DATETIME NOT NULL
); );
CREATE TABLE IF NOT EXISTS Gamepiece ( CREATE TABLE IF NOT EXISTS ExpansionSet (
Id INT AUTO_INCREMENT PRIMARY KEY, SetCode VARCHAR(6) PRIMARY KEY,
Name VARCHAR(150) NOT NULL Name VARCHAR(60) NOT NULL,
CardCount INT NOT NULL,
IconSvgUri VARCHAR(60) NOT NULL
); );
CREATE TABLE IF NOT EXISTS CardPrinting ( CREATE TABLE IF NOT EXISTS CardPrinting (
Id INT AUTO_INCREMENT PRIMARY KEY, Id VARCHAR(36) PRIMARY KEY, -- GUID
GamepieceId INT NOT NULL, Name VARCHAR(150) NOT NULL
FOREIGN KEY (GamepieceId) REFERENCES Gamepiece(Id),
SetCode VARCHAR(6) NOT NULL, SetCode VARCHAR(6) NOT NULL,
ImageUrl VARCHAR(2048) NOT NULL FOREIGN KEY (SetCode) REFERENCES ExpansionSet(SetCode),
IsFoil BOOLEAN NOT NULL,
IsReserved BOOLEAN NOT NULL,
IsRacist BOOLEAN NOT NULL,
IsPromo BOOLEAN NOT NULL,
CollectorNumber VARCHAR(10) NOT NULL,
Language VARCHAR(3) NOT NULL
); );