示例#1
0
func (p *Project) LoadLastApk(db *datastore.DB) {
	if len(p.ApkIds) == 0 {
		return
	}
	if err := db.C("apks").FindId(p.ApkIds[0]).One(&p.LastApk); err != nil {
		panic(err)
	}
}
示例#2
0
// Projects retrieves a list of the user's projects from db.
func ProjectsByUser(u *user.User, db *datastore.DB) (projects []*Project) {
	q := bson.M{"userids": u.Id}
	if err := db.C("projects").Find(q).All(&projects); err != nil {
		panic(err)
	}
	for _, project := range projects {
		project.LoadLastApk(db)
	}
	return projects
}
示例#3
0
// ProjectsOverview provides a list of last apk uploaded for each project in slice.
func ProjectsOverview(db *datastore.DB, projects []*Project) (apks []*Apk) {
	var ids []bson.ObjectId
	for _, p := range projects {
		ids = append(ids, p.ApkIds[0])
	}
	q := bson.M{"_id": bson.M{"$in": ids}}
	if err := db.C("apks").Find(q).All(&apks); err != nil {
		panic(err)
	}

	return apks
}
示例#4
0
// ProjectHistory returns a slice of all apks for project.
func (p *Project) History(db *datastore.DB) (apks []*Apk) {
	q := bson.M{"_id": bson.M{"$in": p.ApkIds}}
	db.C("apks").Find(q).Sort("-time").All(&apks)
	return apks
}