From 49148d8ccf177d7158cfde8679b5c9eb3b1f3ad1 Mon Sep 17 00:00:00 2001 From: rtz12 Date: Sun, 9 Oct 2016 16:44:49 +0200 Subject: Bildtyp nicht mehr schreiben, TagType beachten diff --git a/tools/importer/main.go b/tools/importer/main.go index 13ed0cb..fd7af37 100644 --- a/tools/importer/main.go +++ b/tools/importer/main.go @@ -9,6 +9,7 @@ import ( "fagott.pw/grilist/grilist" "fagott.pw/grilist/modules/grils" + "fagott.pw/grilist/modules/tags" _ "github.com/lib/pq" ) @@ -88,17 +89,15 @@ func InsertGril(g WrappedGril) int { if g.Image != "" { fmt.Fprintf( exportFile, - "%d %d %s\n", + "%d %s\n", dbID, - 0, g.Image) } if g.Thumb != "" { fmt.Fprintf( exportFile, - "%d %d %s\n", + "%d %s\n", dbID, - 1, g.Thumb) } } @@ -113,7 +112,8 @@ func InsertTags(dbID int, g WrappedGril, taglist map[string]int) { continue } var id int - row := db.QueryRow("INSERT INTO grilist.tags (name) VALUES ($1) RETURNING id;", v) + row := db.QueryRow(`INSERT INTO grilist.tags (name, type) VALUES + ($1, $2) RETURNING id;`, v, tags.TagTypeGril) row.Scan(&id) taglist[v] = id fmt.Printf("Inserted tag %s as %d\n", v, id) @@ -216,7 +216,7 @@ func main() { } taglist := make(map[string]int) - rows, _ := db.Query("SELECT id, name FROM grilist.tags;") + rows, _ := db.Query("SELECT id, name FROM grilist.tags WHERE type = $1;", tags.TagTypeGril) for rows.Next() { var id int var name string -- cgit v0.10.1