// Fetch results for a specific profile
Fetch results for a specific profile
// Fetch results for a specific profile
func fetchPerformanceProfileResults(baseURL, profileID string, pageSize, pageNumber int) ([]models.PerformanceResult, []byte, error) {
	client := &http.Client{}
	var response *models.PerformanceResultsAPIResponse
	url := baseURL + "/api/user/performance/profiles/" + profileID + "/results"
	tempURL := fmt.Sprintf("%s?pageSize=%d&page=%d", url, pageSize, pageNumber)
	req, err := utils.NewRequest("GET", tempURL, nil)
	if err != nil {
		return nil, nil, err
	}
	resp, err := client.Do(req)
	if err != nil {
		return nil, nil, ErrFailRequest(err)
	}
	if utils.ContentTypeIsHTML(resp) {
		return nil, nil, ErrUnauthenticated()
	}
	if resp.StatusCode != 200 {
		return nil, nil, ErrFailReqStatus(resp.StatusCode)
	}
	defer resp.Body.Close()
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, nil, errors.Wrap(err, utils.PerfError("failed to read response body"))
	}
	err = json.Unmarshal(body, &response)
	if err != nil {
		return nil, nil, ErrFailUnmarshal(err)
	}
	return response.Results, body, nil
}
func fetchPerformanceProfileResults ( baseURL , profileID string , pageSize , pageNumber int ) ( [ ] models . PerformanceResult , [ ] byte , error ) { client := & http . Client { } var response * models . PerformanceResultsAPIResponse url := baseURL + " " + profileID + " " tempURL := fmt . Sprintf ( " " , url , pageSize , pageNumber ) req , err := utils . NewRequest ( " " , tempURL , nil ) if err != nil { return nil , nil , err } resp , err := client . Do ( req ) if err != nil { return nil , nil , ErrFailRequest ( err ) } if utils . ContentTypeIsHTML ( resp ) { return nil , nil , ErrUnauthenticated ( ) } if resp . StatusCode != 200 { return nil , nil , ErrFailReqStatus ( resp . StatusCode ) } defer resp . Body . Close ( ) body , err := io . ReadAll ( resp . Body ) if err != nil { return nil , nil , errors . Wrap ( err , utils . PerfError ( " " ) ) } err = json . Unmarshal ( body , & response ) if err != nil { return nil , nil , ErrFailUnmarshal ( err ) } return response . Results , body , nil }
Fetch results for a specific profile
Fetch results for a specific profile
// failsafe for no authentication // failsafe for bad api call