Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

try putting every kanji into its own task queue when populating datas…

…tore
  • Loading branch information...
commit 380e9a343af40108c0b1bfc1d0723710d23f73cf 1 parent 6aab299
@shawnps authored
Showing with 12 additions and 12 deletions.
  1. +11 −11 kanjihub/admin/populate.go
  2. +1 −1  kanjihub/api/kanjihub.go
View
22 kanjihub/admin/populate.go
@@ -25,10 +25,6 @@ type Kanji struct {
func populate(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
- populateLater.Call(c)
-}
-
-var populateLater = delay.Func("populate", func(c appengine.Context) {
kanjidic := kanjidic2.ParseKanjiDic2("admin/kanjidic2/kanjidic2.xml")
for _, kanji := range kanjidic {
k := Kanji{
@@ -52,12 +48,16 @@ var populateLater = delay.Func("populate", func(c appengine.Context) {
k.Meanings = append(k.Meanings, m.Value)
}
}
- key := datastore.NewKey(c, "Kanji", kanji.Literal, 0, nil)
- _, err := datastore.Put(c, key, &k)
- c.Infof("Added kanji %s", kanji.Literal)
- if err != nil {
- c.Errorf(err.Error())
- return
- }
+ populateLater.Call(c, k)
+ }
+}
+
+var populateLater = delay.Func("populate", func(c appengine.Context, k Kanji) {
+ key := datastore.NewKey(c, "Kanji", k.Literal, 0, nil)
+ _, err := datastore.Put(c, key, &k)
+ c.Infof("Added kanji %s", k.Literal)
+ if err != nil {
+ c.Errorf(err.Error())
+ return
}
})
View
2  kanjihub/api/kanjihub.go
@@ -65,7 +65,7 @@ func KanjiSearchHandler(w http.ResponseWriter, r *http.Request) {
if _, err := q.GetAll(c, &results); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
- }
+ }
// marshall kanji into json
jsonResults, err := json.Marshal(results)

1 comment on commit 380e9a3

@sym3tri
Collaborator

Not sure if you saw what I said in irc, but one task per kanji might be a bit extreme. We can probably get by with 100 or 10 per task. Not a problem now I guess, but if we want to use tasks for other things we might eat up our quota very quickly.

Please sign in to comment.
Something went wrong with that request. Please try again.