aboutsummaryrefslogtreecommitdiff
path: root/tools/importer/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'tools/importer/main.go')
-rw-r--r--tools/importer/main.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/importer/main.go b/tools/importer/main.go
index fd7af37..4eba9a0 100644
--- a/tools/importer/main.go
+++ b/tools/importer/main.go
@@ -179,6 +179,28 @@ func InsertTraits(dbID int, g WrappedGril, traitlist map[string]int) {
179 LogErr(err) 179 LogErr(err)
180 } 180 }
181} 181}
182
183func InsertSeries(dbID int, g WrappedGril) {
184 rows, err := db.Query("SELECT appearance_id FROM grils_appearances WHERE gril_id = $1;", dbID)
185 LogErr(err)
186 existingSeries := make(map[int]bool, 0)
187 for rows.Next() {
188 var seriesID int
189 rows.Scan(&seriesID)
190 existingSeries[seriesID] = true
191 }
192 for _, v := range g.Gril.Series {
193 if _, ok := existingSeries[v.ID]; ok {
194 continue
195 }
196 _, err := db.Exec("INSERT INTO grilist.grils_appearances (gril_id, appearance_id) VALUES ($1, $2);",
197 dbID, v.ID)
198 existingSeries[v.ID] = true
199 fmt.Printf("Assigned series %d to %s\n", v.ID, g.Gril.RomajiName)
200 LogErr(err)
201 }
202}
203
182func main() { 204func main() {
183 flag.StringVar(&path, "path", "", "path of the source files") 205 flag.StringVar(&path, "path", "", "path of the source files")
184 flag.StringVar(&sourceType, "type", "", "type of the files (ACD, AniDB)") 206 flag.StringVar(&sourceType, "type", "", "type of the files (ACD, AniDB)")
@@ -252,6 +274,7 @@ func main() {
252 } 274 }
253 InsertTags(dbID, g, taglist) 275 InsertTags(dbID, g, taglist)
254 InsertTraits(dbID, g, traitlist) 276 InsertTraits(dbID, g, traitlist)
277 InsertSeries(dbID, g)
255 278
256 return nil 279 return nil
257 }) 280 })