Skip to content
This repository has been archived by the owner on Mar 16, 2020. It is now read-only.

Commit

Permalink
New goon API for Kind fetching
Browse files Browse the repository at this point in the history
Old API broke because it no longer returns incomplete keys.
  • Loading branch information
maddyblue committed Jan 26, 2014
1 parent d71eaa4 commit 1c68edc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions admin.go
Expand Up @@ -32,7 +32,7 @@ import (

func AllFeedsOpml(c mpg.Context, w http.ResponseWriter, r *http.Request) {
gn := goon.FromContext(c)
q := datastore.NewQuery(gn.Key(&Feed{}).Kind()).KeysOnly()
q := datastore.NewQuery(gn.Kind(&Feed{})).KeysOnly()
keys, _ := gn.GetAll(q, nil)
fs := make([]*Feed, len(keys))
for i, k := range keys {
Expand Down Expand Up @@ -63,7 +63,7 @@ func feedsToOpml(feeds []*Feed) []byte {

func AllFeeds(c mpg.Context, w http.ResponseWriter, r *http.Request) {
gn := goon.FromContext(c)
q := datastore.NewQuery(gn.Key(&Feed{}).Kind()).KeysOnly()
q := datastore.NewQuery(gn.Kind(&Feed{})).KeysOnly()
keys, _ := gn.GetAll(q, nil)
templates.ExecuteTemplate(w, "admin-all-feeds.html", keys)
}
Expand All @@ -75,7 +75,7 @@ func AdminFeed(c mpg.Context, w http.ResponseWriter, r *http.Request) {
serveError(w, err)
return
}
q := datastore.NewQuery(gn.Key(&Story{}).Kind()).KeysOnly()
q := datastore.NewQuery(gn.Kind(&Story{})).KeysOnly()
fk := gn.Key(&f)
q = q.Ancestor(fk)
q = q.Limit(100)
Expand Down Expand Up @@ -159,7 +159,7 @@ func AdminDateFormats(c mpg.Context, w http.ResponseWriter, r *http.Request) {

func AdminStats(c mpg.Context, w http.ResponseWriter, r *http.Request) {
gn := goon.FromContext(c)
uc, _ := datastore.NewQuery(gn.Key(&User{}).Kind()).Count(c)
uc, _ := datastore.NewQuery(gn.Kind(&User{})).Count(c)
templates.ExecuteTemplate(w, "admin-stats.html", struct {
Users int
}{
Expand All @@ -169,7 +169,7 @@ func AdminStats(c mpg.Context, w http.ResponseWriter, r *http.Request) {

func AdminUser(c mpg.Context, w http.ResponseWriter, r *http.Request) {
gn := goon.FromContext(c)
q := datastore.NewQuery(gn.Key(&User{}).Kind()).Limit(1)
q := datastore.NewQuery(gn.Kind(&User{})).Limit(1)
q = q.Filter("e =", r.FormValue("u"))
it := gn.Run(q)
var u User
Expand All @@ -185,7 +185,7 @@ func AdminUser(c mpg.Context, w http.ResponseWriter, r *http.Request) {
u.Until = d
gn.Put(&u)
}
q = datastore.NewQuery(gn.Key(&Log{}).Kind()).Ancestor(k)
q = datastore.NewQuery(gn.Kind(&Log{})).Ancestor(k)
_, err = gn.GetAll(q, &h)
ud.Parent = gn.Key(&u)
gn.Get(&ud)
Expand Down
14 changes: 7 additions & 7 deletions user.go
Expand Up @@ -238,7 +238,7 @@ func ListFeeds(c mpg.Context, w http.ResponseWriter, r *http.Request) {
})
lock := sync.Mutex{}
fl := make(map[string][]*Story)
q := datastore.NewQuery(gn.Key(&Story{}).Kind()).
q := datastore.NewQuery(gn.Kind(&Story{})).
Filter(IDX_COL+" >=", u.Read).
KeysOnly().
Order("-" + IDX_COL).
Expand Down Expand Up @@ -318,7 +318,7 @@ func ListFeeds(c mpg.Context, w http.ResponseWriter, r *http.Request) {
close(queue)
c.Step("stars", func(c mpg.Context) {
gn := goon.FromContext(c)
q := datastore.NewQuery(gn.Key(&UserStar{}).Kind()).
q := datastore.NewQuery(gn.Kind(&UserStar{})).
Ancestor(ud.Parent).
KeysOnly().
Filter("c >=", u.Read).
Expand Down Expand Up @@ -600,7 +600,7 @@ func ClearFeeds(c mpg.Context, w http.ResponseWriter, r *http.Request) {
&UserOpml{},
}
for _, i := range types {
k := gn.Key(i).Kind()
k := gn.Kind(i)
go del(k)
}

Expand Down Expand Up @@ -707,7 +707,7 @@ func FeedHistory(c mpg.Context, w http.ResponseWriter, r *http.Request) {
u := User{Id: cu.ID}
uk := gn.Key(&u)
if v := r.FormValue("v"); len(v) == 0 {
q := datastore.NewQuery(gn.Key(&UserOpml{}).Kind()).Ancestor(uk).KeysOnly()
q := datastore.NewQuery(gn.Kind(&UserOpml{})).Ancestor(uk).KeysOnly()
keys, err := gn.GetAll(q, nil)
if err != nil {
serveError(w, err)
Expand Down Expand Up @@ -755,7 +755,7 @@ func GetFeed(c mpg.Context, w http.ResponseWriter, r *http.Request) {
var stars []string
wg := sync.WaitGroup{}
fk := gn.Key(&f)
q := datastore.NewQuery(gn.Key(&Story{}).Kind()).Ancestor(fk).KeysOnly()
q := datastore.NewQuery(gn.Kind(&Story{})).Ancestor(fk).KeysOnly()
q = q.Order("-" + IDX_COL)
if cur := r.FormValue("c"); cur != "" {
if dc, err := datastore.DecodeCursor(cur); err == nil {
Expand All @@ -767,7 +767,7 @@ func GetFeed(c mpg.Context, w http.ResponseWriter, r *http.Request) {
go c.Step("stars", func(c mpg.Context) {
gn := goon.FromContext(c)
usk := starKey(c, f.Url, "")
q := datastore.NewQuery(gn.Key(&UserStar{}).Kind()).Ancestor(gn.Key(usk).Parent()).KeysOnly()
q := datastore.NewQuery(gn.Kind(&UserStar{})).Ancestor(gn.Key(usk).Parent()).KeysOnly()
keys, _ := gn.GetAll(q, nil)
stars = make([]string, len(keys))
for i, key := range keys {
Expand Down Expand Up @@ -856,7 +856,7 @@ func GetStars(c mpg.Context, w http.ResponseWriter, r *http.Request) {
gn := goon.FromContext(c)
cu := user.Current(c)
u := User{Id: cu.ID}
q := datastore.NewQuery(gn.Key(&UserStar{}).Kind()).
q := datastore.NewQuery(gn.Kind(&UserStar{})).
Ancestor(gn.Key(&u)).
Order("-c").
Limit(20)
Expand Down

0 comments on commit 1c68edc

Please sign in to comment.