Skip to content

Commit

Permalink
minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mat Ryer committed Aug 6, 2016
1 parent 8c99045 commit 143319f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion chapter9/answersapp/api/answers.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func GetAnswers(ctx context.Context, questionKey *datastore.Key) ([]*Answer, err
answerKeys, err := datastore.NewQuery("Answer").
Ancestor(questionKey).
Order("-Score").
Order("-CTime").
Order("CTime").
GetAll(ctx, &answers)
for i, answer := range answers {
answer.Key = answerKeys[i]
Expand Down
3 changes: 1 addition & 2 deletions chapter9/answersapp/api/handle_votes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package api

import (
"errors"
"net/http"

"google.golang.org/appengine"
"google.golang.org/appengine/datastore"

"net/http"
)

func handleVotes(w http.ResponseWriter, r *http.Request) {
Expand Down
7 changes: 7 additions & 0 deletions chapter9/answersapp/default/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ indexes:
- name: Score
direction: desc

- kind: Answer
ancestor: yes
properties:
- name: Score
direction: desc
- name: CTime

- kind: Answer
ancestor: yes
properties:
Expand Down
6 changes: 3 additions & 3 deletions chapter9/answersapp/web/templates/question.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ <h2 class='ui dividing header'>Submit an answer</h2>
$('<div>', {class:'content'}).append(
$('<a>', {class:'author'}).text(answer.user.display_name),
$('<div>', {class:'metadata'}).append(
$('<span>', {class:'date'}).text(moment(answer.created).fromNow()),
$("<span>", {class:'ui label'}).text(answer.score + " point(s)")
$('<span>', {class:'date'}).text(moment(answer.created).fromNow())
),
$('<div>', {class:'text'}).text(answer.answer),
$('<div>', {class:'actions'}).append(
Expand All @@ -89,7 +88,8 @@ <h2 class='ui dividing header'>Submit an answer</h2>
'data-score':'-1',
'data-answer-id': answer.id
})
).click(onVoteClick)
).click(onVoteClick),
$("<span>", {class:'ui label'}).text(answer.score + " point(s)")
)
)
).appendTo(answersList)
Expand Down

0 comments on commit 143319f

Please sign in to comment.