Remove broken decklist functionality

This commit is contained in:
The Magician 2024-05-19 10:06:28 +01:00
parent 87a94f800d
commit 6def107873
4 changed files with 1 additions and 143 deletions

View File

@ -1,10 +1,7 @@
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:
mysql --user=root --password=$(shell pass show sevenkeys/mysql) <sql/createdb.sql mysql --user=root --password=$(shell pass show sevenkeys/mysql) <sql/createdb.sql
importcards: createdb importcards: createdb
go run cmd/importcards/main.go go run cmd/importcards/main.go
getdecks:
go run cmd/getdecks/main.go

View File

@ -1,18 +0,0 @@
package main
import (
"fmt"
"sevenkeys/mtggoldfish"
)
func main() {
params := mtggoldfish.DeckSearchParameters{
Format: "pauper",
IncludeTournamentDecks: true,
StartDate: "04/14/2024",
EndDate: "04/28/2024",
}
decks, _ := mtggoldfish.DeckSearch(params)
fmt.Println(decks)
}

View File

@ -1,98 +0,0 @@
package mtggoldfish
import (
"fmt"
"github.com/PuerkitoBio/goquery"
"github.com/geziyor/geziyor"
"github.com/geziyor/geziyor/client"
"github.com/geziyor/geziyor/export"
)
var DECK_SEARCH_URL string = "https://www.mtggoldfish.com/deck_searches/create"
const (
TypeMaindeck = "maindeck"
TypeSideboard = "sideboard"
TypeCommander = "commander"
)
type DeckSearchIncludedCard struct {
Name string
Quantity int
Type string
}
type DeckSearchParameters struct {
Name string
Format string
IncludeTournamentDecks bool
IncludeUserDecks bool
Player string
StartDate string // TODO: Date type?
EndDate string // TODO: Date type?
IncludedCards []DeckSearchCard
}
func (p *DeckSearchParameters) String() string {
searchUrl := DECK_SEARCH_URL + "?utf8=✓" +
"&deck_search[name]=" + p.Name +
"&deck_search[format]=" + p.Format +
"&deck_search[types][]="
if p.IncludeTournamentDecks {
searchUrl = searchUrl + "&deck_search[types][]=tournament"
}
if p.IncludeUserDecks {
searchUrl = searchUrl + "&deck_search[types][]=user"
}
searchUrl = searchUrl + "&deck_search[player]=" + p.Player
//"&deck_search[date_range]=" + p.StartDate + " - " + p.EndDate
return searchUrl
}
type DeckSearchCard struct {
Name string
Quantity int
Type string
}
type DeckSearchDecklist struct {
MtgGoldfishId int
Date string // TODO: Date type?
Name string
Source string
Format string
Author string
Cards []DeckSearchCard
}
type DeckSearchResults struct {
Decklists []DeckSearchDecklist
DeckCount int
PageCount int
}
func parseSearchResults(g *geziyor.Geziyor, r *client.Response) {
r.HTMLDoc.Find("div.table-responsive").Each(func(i int, s *goquery.Selection) {
g.Exports <- map[string]interface{}{
"test": s.Find("table>thead>tr>th").Text(),
}
})
}
func DeckSearch(params DeckSearchParameters) (DeckSearchResults, error) {
searchUrl := `https://www.mtggoldfish.com/deck_searches/create?utf8=✓&deck_search[name]=Burn&deck_search[format]=pauper&deck_search[types][]=&deck_search[types][]=tournament&deck_search[types][]=user&deck_search[player]=Jirach1&deck_search[date_range]=04%2F14%2F2024+-+04%2F28%2F2024&deck_search[deck_search_card_filters_attributes][0][card]=Kuldotha+Rebirth&deck_search[deck_search_card_filters_attributes][0][quantity]=4&deck_search[deck_search_card_filters_attributes][0][type]=maindeck&deck_search[deck_search_card_filters_attributes][1][card]=&deck_search[deck_search_card_filters_attributes][1][quantity]=1&deck_search[deck_search_card_filters_attributes][1][type]=maindeck&deck_search[deck_search_card_filters_attributes][2][card]=&deck_search[deck_search_card_filters_attributes][2][quantity]=1&deck_search[deck_search_card_filters_attributes][2][type]=maindeck&counter=3&commit=Search`
fmt.Println(searchUrl)
geziyor.NewGeziyor(&geziyor.Options{
StartURLs: []string{searchUrl},
ParseFunc: parseSearchResults,
Exporters: []export.Exporter{&export.JSON{}},
}).Start()
return DeckSearchResults{}, nil
}

View File

@ -19,26 +19,3 @@ CREATE TABLE IF NOT EXISTS CardPrinting (
SetCode VARCHAR(6) NOT NULL, SetCode VARCHAR(6) NOT NULL,
ImageUrl VARCHAR(2048) NOT NULL ImageUrl VARCHAR(2048) NOT NULL
); );
CREATE TABLE IF NOT EXISTS TournamentDecklist (
Id INT AUTO_INCREMENT PRIMARY KEY,
DeckName VARCHAR(100) NOT NULL,
DatePublished DATE NOT NULL,
Source VARCHAR(200) NOT NULL,
Format VARCHAR(25) NOT NULL,
AuthorName VARCHAR(100) NOT NULL
);
CREATE TABLE IF NOT EXISTS TournamentDecklistCard (
TournamentDecklistId INT NOT NULL,
GamepieceId INT NOT NULL,
PRIMARY KEY (TournamentDecklistId, GamepieceId),
FOREIGN KEY TournamentDecklistId REFERENCES TournamentDecklist(Id),
FOREIGN KEY GamepieceId REFERENCES Gamepiece(Id),
CardPrintingId INT NULL,
FOREIGN KEY CardPrintingId REFERENCES CardPrinting(Id),
Quantity INT NOT NULL
);