Example #1
0
func userCurrent(w http.ResponseWriter, r *http.Request) *handler.Error {
	db := datastore.New()
	defer db.Close()

	c := context.New(r)
	u := user.Current(c, db)
	m := bson.M{"Name": u.Name, "Email": u.Email}

	render.Json(w, m)
	return nil
}
Example #2
0
func projectsByUser(w http.ResponseWriter, r *http.Request) *handler.Error {
	db := datastore.New()
	defer db.Close()

	c := context.New(r)
	u := user.Current(c, db)

	projects := ProjectsByUser(u, db)
	render.Json(w, projects)

	return nil
}
Example #3
0
func projectHistory(w http.ResponseWriter, r *http.Request) *handler.Error {
	db := datastore.New()
	defer db.Close()

	c := context.New(r)
	u := user.Current(c, db)

	id := bson.ObjectIdHex(mux.Vars(r)["projectId"])

	project := ProjectById(u, id)
	render.Json(w, project.History(db))

	return nil
}
Example #4
0
func apkById(w http.ResponseWriter, r *http.Request) *handler.Error {
	db := datastore.New()
	defer db.Close()

	apkId := bson.ObjectIdHex(mux.Vars(r)["id"])

	var apk *Apk
	// TODO confirm user has access to apk
	if err := db.C("apks").FindId(apkId).One(&apk); err != nil {
		return handler.NewError(err, 500, "Failed to locate apk.")
	}

	render.Json(w, apk)
	return nil
}
Example #5
0
func errorsByApkId(w http.ResponseWriter, r *http.Request) *handler.Error {
	db := datastore.New()
	defer db.Close()

	apkId := bson.ObjectIdHex(mux.Vars(r)["apkId"])

	var reports []*Report
	q := bson.M{"apkid": apkId}
	if err := db.C("reports").Find(q).All(&reports); err != nil {
		return handler.NewError(err, 500, "Error querying for apk reports.")
	}

	render.Json(w, groupErrors(reports))
	return nil
}
Example #6
0
func errorDetails(w http.ResponseWriter, r *http.Request) *handler.Error {
	db := datastore.New()
	defer db.Close()

	// get session user
	// c := context.New(r)
	// u := user.Current(c, db)

	apkId := mux.Vars(r)["apkId"]
	reportId := mux.Vars(r)["reportId"]

	var report *Report
	db.C("reports").FindId(bson.ObjectIdHex(reportId)).One(&report)
	// get info from related reports to attach here
	var reports []*Report
	q := bson.M{"apkid": bson.ObjectIdHex(apkId)} // TODO confirm user has access to project
	if err := db.C("reports").Find(q).All(&reports); err != nil {
		return handler.NewError(err, 500, "Error querying for apk reports.")
	}
	attachGroupDetails(report, reports)

	render.Json(w, report)
	return nil
}