Exemple #1
0
// Cancel deletes the current running timer.
func Cancel(w http.ResponseWriter, r *http.Request) {
	ctx := appengine.NewContext(r)
	u := user.Current(ctx)
	timer, err := datastore.LoadRunningTimer(ctx, u.String())
	if internalError(w, err) {
		return
	}
	if timer == nil {
		printEmptyTimer(w)
		return
	}
	err = datastore.DeleteRunningTimer(ctx, timer)
	if internalError(w, err) {
		return
	}
	printEmptyTimer(w)
}
Exemple #2
0
// Reset collection running timer stats for a user and deletes the timer.
func Reset(w http.ResponseWriter, r *http.Request) {
	owner := r.FormValue("owner")
	if owner == "" {
		panic("Unknown owner.")
	}
	ctx := appengine.NewContext(r)
	timer, err := datastore.LoadRunningTimer(ctx, owner)
	if err != nil {
		panic("Unable to load running timer for " + owner + " : " + err.Error())
	}
	minute, err := stats.Minute(timer)
	if err != nil {
		panic(err)
	}
	err = updateAllDimensions(ctx, timer, minute)
	if err != nil {
		panic(err)
	}
	err = datastore.DeleteRunningTimer(ctx, timer)
	if err != nil {
		panic("Unable to delete running timer for " + owner + " : " + err.Error())
	}
}