aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/importer/main.go12
1 files changed, 6 insertions, 6 deletions
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 (
9 9
10 "fagott.pw/grilist/grilist" 10 "fagott.pw/grilist/grilist"
11 "fagott.pw/grilist/modules/grils" 11 "fagott.pw/grilist/modules/grils"
12 "fagott.pw/grilist/modules/tags"
12 13
13 _ "github.com/lib/pq" 14 _ "github.com/lib/pq"
14) 15)
@@ -88,17 +89,15 @@ func InsertGril(g WrappedGril) int {
88 if g.Image != "" { 89 if g.Image != "" {
89 fmt.Fprintf( 90 fmt.Fprintf(
90 exportFile, 91 exportFile,
91 "%d %d %s\n", 92 "%d %s\n",
92 dbID, 93 dbID,
93 0,
94 g.Image) 94 g.Image)
95 } 95 }
96 if g.Thumb != "" { 96 if g.Thumb != "" {
97 fmt.Fprintf( 97 fmt.Fprintf(
98 exportFile, 98 exportFile,
99 "%d %d %s\n", 99 "%d %s\n",
100 dbID, 100 dbID,
101 1,
102 g.Thumb) 101 g.Thumb)
103 } 102 }
104 } 103 }
@@ -113,7 +112,8 @@ func InsertTags(dbID int, g WrappedGril, taglist map[string]int) {
113 continue 112 continue
114 } 113 }
115 var id int 114 var id int
116 row := db.QueryRow("INSERT INTO grilist.tags (name) VALUES ($1) RETURNING id;", v) 115 row := db.QueryRow(`INSERT INTO grilist.tags (name, type) VALUES
116 ($1, $2) RETURNING id;`, v, tags.TagTypeGril)
117 row.Scan(&id) 117 row.Scan(&id)
118 taglist[v] = id 118 taglist[v] = id
119 fmt.Printf("Inserted tag %s as %d\n", v, id) 119 fmt.Printf("Inserted tag %s as %d\n", v, id)
@@ -216,7 +216,7 @@ func main() {
216 } 216 }
217 217
218 taglist := make(map[string]int) 218 taglist := make(map[string]int)
219 rows, _ := db.Query("SELECT id, name FROM grilist.tags;") 219 rows, _ := db.Query("SELECT id, name FROM grilist.tags WHERE type = $1;", tags.TagTypeGril)
220 for rows.Next() { 220 for rows.Next() {
221 var id int 221 var id int
222 var name string 222 var name string