From 6fba92d36432d28e3ad62e6b3da5a3b807011482 Mon Sep 17 00:00:00 2001 From: rtz12 Date: Wed, 12 Oct 2016 22:33:24 +0200 Subject: Mal wieder Jans Suppe ausgeloeffelt diff --git a/models/tag.go b/models/tag.go new file mode 100644 index 0000000..9ecd73c --- /dev/null +++ b/models/tag.go @@ -0,0 +1,8 @@ +package models + +type TagType int + +const ( + TagTypeGril TagType = iota + TagTypeSeries +) diff --git a/modules/tags/tag.go b/modules/tags/tag.go deleted file mode 100644 index 026df0f..0000000 --- a/modules/tags/tag.go +++ /dev/null @@ -1,8 +0,0 @@ -package tags - -type TagType int - -const ( - TagTypeGril TagType = iota - TagTypeSeries -) diff --git a/tools/animeimporter/ACDv2Reader.go b/tools/animeimporter/ACDv2Reader.go index 36564e4..38162d6 100644 --- a/tools/animeimporter/ACDv2Reader.go +++ b/tools/animeimporter/ACDv2Reader.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "fagott.pw/grilist/modules/grils" + "fagott.pw/grilist/models" ) func ifErrExit(err error) { @@ -55,5 +55,5 @@ func (r *ACDv2Reader) Read(path string) WrappedSeries { } func (r *ACDv2Reader) ID() int { - return int(grils.DataSourceACD) + return int(models.DataSourceACD) } diff --git a/tools/animeimporter/main.go b/tools/animeimporter/main.go index 81ba516..17da658 100644 --- a/tools/animeimporter/main.go +++ b/tools/animeimporter/main.go @@ -8,8 +8,7 @@ import ( "path/filepath" "fagott.pw/grilist/grilist" - "fagott.pw/grilist/modules/series" - "fagott.pw/grilist/modules/tags" + "fagott.pw/grilist/models" ) var path string @@ -20,7 +19,7 @@ var db *sql.DB var r SeriesReader type WrappedSeries struct { - Series series.Series + Series models.Series Image string } @@ -104,7 +103,7 @@ func InsertTags(dbID int, s WrappedSeries, taglist map[string]int) { } var id int row := db.QueryRow("INSERT INTO grilist.tags (name, type) VALUES ($1, $2) RETURNING id;", - v, tags.TagTypeSeries) + v, models.TagTypeSeries) row.Scan(&id) taglist[v] = id fmt.Printf("Inserted tag %s as %d\n", v, id) @@ -167,7 +166,7 @@ func main() { } taglist := make(map[string]int) - rows, err := db.Query("SELECT id, name FROM grilist.tags WHERE type = $1;", tags.TagTypeSeries) + rows, err := db.Query("SELECT id, name FROM grilist.tags WHERE type = $1;", models.TagTypeSeries) LogErr(err) for rows.Next() { var id int diff --git a/tools/importer/ACDReader.go b/tools/importer/ACDReader.go index 694087e..1d5e8c9 100644 --- a/tools/importer/ACDReader.go +++ b/tools/importer/ACDReader.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "fagott.pw/grilist/modules/grils" + "fagott.pw/grilist/models" ) var tagRegex = regexp.MustCompile(`\(.+)\<\/a\>`) @@ -31,7 +31,7 @@ func toInt(s string) int { func (r *ACDReader) Read(path string) WrappedGril { g := WrappedGril{} - g.Gril = grils.Gril{} + g.Gril = models.Gril{} data, err := ioutil.ReadFile(path) ifErrExit(err) var jObj interface{} @@ -77,5 +77,5 @@ func (r *ACDReader) Read(path string) WrappedGril { } func (r *ACDReader) ID() int { - return int(grils.DataSourceACD) + return int(models.DataSourceACD) } diff --git a/tools/importer/ACDv2Reader.go b/tools/importer/ACDv2Reader.go index 4dab3c0..f34dd15 100644 --- a/tools/importer/ACDv2Reader.go +++ b/tools/importer/ACDv2Reader.go @@ -6,8 +6,7 @@ import ( "path/filepath" "strings" - "fagott.pw/grilist/modules/grils" - "fagott.pw/grilist/modules/series" + "fagott.pw/grilist/models" ) const failMsg = "Offenbar war meine Annahme bzgl. der Traits nicht ganz korrekt" @@ -45,7 +44,7 @@ type ACDv2Gril struct { func (r *ACDv2Reader) Read(path string) WrappedGril { g := WrappedGril{} - g.Gril = grils.Gril{} + g.Gril = models.Gril{} data, err := ioutil.ReadFile(path) ifErrExit(err) var jObj ACDv2Gril @@ -61,7 +60,7 @@ func (r *ACDv2Reader) Read(path string) WrappedGril { for _, v := range jObj.Tags { g.Gril.Tags = append(g.Gril.Tags, v.Name) } - g.Gril.Traits = make([]grils.Trait, 0) + g.Gril.Traits = make([]models.Trait, 0) if len(jObj.Traits.Official) != len(jObj.Traits.Indexed) { panic(failMsg) } @@ -69,16 +68,16 @@ func (r *ACDv2Reader) Read(path string) WrappedGril { if jObj.Traits.Official[i].Name != jObj.Traits.Indexed[i].Name { panic(failMsg) } - t := grils.Trait{ + t := models.Trait{ Name: jObj.Traits.Official[i].Name, Value: jObj.Traits.Indexed[i].Value, OfficialValue: jObj.Traits.Official[i].Value, } g.Gril.Traits = append(g.Gril.Traits, t) } - g.Gril.Series = make([]series.Series, 0) + g.Gril.Series = make([]models.Series, 0) for _, v := range jObj.Assignments { - s := series.Series{ + s := models.Series{ ID: v, } g.Gril.Series = append(g.Gril.Series, s) @@ -87,5 +86,5 @@ func (r *ACDv2Reader) Read(path string) WrappedGril { } func (r *ACDv2Reader) ID() int { - return int(grils.DataSourceACD) + return int(models.DataSourceACD) } diff --git a/tools/importer/main.go b/tools/importer/main.go index 8c60ef7..284ef44 100644 --- a/tools/importer/main.go +++ b/tools/importer/main.go @@ -8,8 +8,7 @@ import ( "path/filepath" "fagott.pw/grilist/grilist" - "fagott.pw/grilist/modules/grils" - "fagott.pw/grilist/modules/tags" + "fagott.pw/grilist/models" _ "github.com/lib/pq" ) @@ -22,7 +21,7 @@ var db *sql.DB var r GrilReader type WrappedGril struct { - Gril grils.Gril + Gril models.Gril Image string Thumb string } @@ -113,7 +112,7 @@ func InsertTags(dbID int, g WrappedGril, taglist map[string]int) { } var id int row := db.QueryRow(`INSERT INTO grilist.tags (name, type) VALUES - ($1, $2) RETURNING id;`, v, tags.TagTypeGril) + ($1, $2) RETURNING id;`, v, models.TagTypeGril) row.Scan(&id) taglist[v] = id fmt.Printf("Inserted tag %s as %d\n", v, id) @@ -242,7 +241,7 @@ func main() { } taglist := make(map[string]int) - rows, _ := db.Query("SELECT id, name FROM grilist.tags WHERE type = $1;", tags.TagTypeGril) + rows, _ := db.Query("SELECT id, name FROM grilist.tags WHERE type = $1;", models.TagTypeGril) for rows.Next() { var id int var name string -- cgit v0.10.1