예제 #1
0
func ListCases(w http.ResponseWriter, r *http.Request) {
	//Need better explaination of 'status', currently, only hasReport/isUpdated
	db := liboct.GetDefaultDB()
	var query liboct.DBQuery
	page_string := r.URL.Query().Get("Page")
	page, err := strconv.Atoi(page_string)
	if err == nil {
		query.Page = page
	}
	pageSizeString := r.URL.Query().Get("PageSize")
	pageSize, err := strconv.Atoi(pageSizeString)
	if err != nil {
		query.PageSize = pageSize
	}

	status := r.URL.Query().Get("Status")
	if len(status) > 0 {
		query.Params = make(map[string]string)
		query.Params["Status"] = status
	}
	ids := db.Lookup(liboct.DBCase, query)

	var caseList []liboct.TestCase
	for index := 0; index < len(ids); index++ {
		if val, err := db.Get(liboct.DBCase, ids[index]); err == nil {
			tc, _ := liboct.CaseFromString(val.String())
			caseList = append(caseList, tc)
		}
	}

	liboct.RenderOK(w, fmt.Sprintf("%d cases founded", len(caseList)), caseList)
}
예제 #2
0
func CleanRepo(repo liboct.TestCaseRepo) {
	var query liboct.DBQuery
	db := liboct.GetDefaultDB()
	query.Params = make(map[string]string)
	query.Params["RepoID"] = repo.GetID()
	ids := db.Lookup(liboct.DBRepo, query)
	for index := 0; index < len(ids); index++ {
		db.Remove(liboct.DBCase, ids[index])
	}
}
예제 #3
0
func GetResourceQuery(r *http.Request) liboct.DBQuery {
	var query liboct.DBQuery
	page_string := r.URL.Query().Get("Page")
	page, err := strconv.Atoi(page_string)
	if err == nil {
		query.Page = page
	}
	pageSizeString := r.URL.Query().Get("PageSize")
	pageSize, err := strconv.Atoi(pageSizeString)
	if err == nil {
		query.PageSize = pageSize
	}

	//TODO: use a list , also add the list to the lib
	query.Params = make(map[string]string)
	query.Params["Class"] = r.URL.Query().Get("Class")
	query.Params["Distribution"] = r.URL.Query().Get("Distribution")
	query.Params["Version"] = r.URL.Query().Get("Version")
	query.Params["Arch"] = r.URL.Query().Get("Arch")
	query.Params["CPU"] = r.URL.Query().Get("CPU")
	query.Params["Memory"] = r.URL.Query().Get("Memory")

	return query
}