klabapi

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KLABCacheTTL = 6 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KlabCustomerInput

type KlabCustomerInput struct {
	IdCustomer         *int32   `json:"idCustomer" validate:"required"`
	FirstName          *string  `json:"FirstName" validate:"required"`
	LastName           *string  `json:"LastName" validate:"required"`
	IdGroups           *int32   `json:"idGroups"`
	DOB                *string  `json:"DOB"`
	SEX                *int32   `json:"SEX"`
	DobYear            *int32   `json:"dob_year"`
	DobMonth           *int32   `json:"dob_month"`
	DobDay             *int32   `json:"dob_day"`
	PidNumber          *string  `json:"pid_number"`
	Company            *string  `json:"company"`
	Occupation         *string  `json:"occupation"`
	Education          *string  `json:"education"`
	Address            *string  `json:"address"`
	PhoneHome          *string  `json:"phone_home"`
	PhoneWork          *string  `json:"phone_work"`
	PhoneMobile        *string  `json:"phone_mobile"`
	Faxno              *string  `json:"faxno"`
	Email              *string  `json:"email"`
	Username           *string  `json:"username"`
	Password           *string  `json:"password"`
	Readonly           *int32   `json:"readonly"`
	Warnings           *int32   `json:"warnings"`
	AllowToSave        *int32   `json:"allow_to_save"`
	AllowToCloud       *int32   `json:"allow_to_cloud"`
	Flag2              *int32   `json:"flag2"`
	Idsport            *int32   `json:"idsport"`
	Medication         *string  `json:"medication"`
	Addinfo            *string  `json:"addinfo"`
	TeamName           *string  `json:"team_name"`
	Add1               *int32   `json:"add1"`
	Athlete            *int32   `json:"athlete"`
	Add10              *string  `json:"add10"`
	Add20              *string  `json:"add20"`
	Updatemode         *int32   `json:"updatemode"`
	WeightKg           *float64 `json:"weight_kg"`
	HeightCm           *float64 `json:"height_cm"`
	DateModified       *float64 `json:"date_modified"`
	RecomTestlevel     *int32   `json:"recom_testlevel"`
	CreatedBy          *int64   `json:"created_by"`
	ModBy              *int64   `json:"mod_by"`
	ModDate            *string  `json:"mod_date"`
	Deleted            *int32   `json:"deleted"`
	CreatedDate        *string  `json:"created_date"`
	Modded             *int32   `json:"modded"`
	AllowAnonymousData *string  `json:"allow_anonymous_data" validate:"omitempty,oneof=0 1"`
	Locked             *int32   `json:"locked"`
	AllowToSprintai    *int32   `json:"allow_to_sprintai"`
	TosprintaiFrom     *string  `json:"tosprintai_from"`
	StatSent           *string  `json:"stat_sent"`
	SporttiID          *string  `json:"sportti_id" validate:"required"`
}

Models

type KlabDataBulkInput

type KlabDataBulkInput map[string]KlabDataBundleInput

type KlabDataBundleInput

type KlabDataBundleInput struct {
	Customer        []KlabCustomerInput    `json:"customer"         validate:"omitempty,dive"`
	MeasurementList []KlabMeasurementInput `json:"measurement_list" validate:"omitempty,dive"`
	DirTest         []KlabDirTestInput     `json:"dirtest"          validate:"omitempty,dive"`
	DirTestSteps    []KlabDirTestStepInput `json:"dirteststeps"     validate:"omitempty,dive"`
	DirReport       []KlabDirReportInput   `json:"dirreport"        validate:"omitempty,dive"`
	DirRawData      []KlabDirRawDataInput  `json:"dirrawdata"       validate:"omitempty,dive"`
	DirResults      []KlabDirResultsInput  `json:"dirresults"       validate:"omitempty,dive"`
}

type KlabDataHandler

type KlabDataHandler struct {
	// contains filtered or unexported fields
}

func NewKlabDataHandler

func NewKlabDataHandler(store klab.Data, cache *cache.Storage) *KlabDataHandler

func (*KlabDataHandler) GetKlabData

func (h *KlabDataHandler) GetKlabData(w http.ResponseWriter, r *http.Request)

GetKlabData godoc

@Summary		Get kLab data by Sportti ID
@Description	Returns measurement_list + all child tables for the given customer (no customer row)
@Tags			KLAB - Data
@Accept			json
@Produce		json
@Param			id	query		string	true	"Sportti ID"
@Success		200	{object}	swagger.KlabDataResponse
@Failure		400	{object}	swagger.ValidationErrorResponse
@Failure		401	{object}	swagger.UnauthorizedResponse
@Failure		403	{object}	swagger.ForbiddenResponse
@Failure		404	{object}	swagger.NotFoundResponse
@Failure		500	{object}	swagger.InternalServerErrorResponse
@Failure		503	{object}	swagger.ServiceUnavailableResponse
@Security		BearerAuth
@Router			/klab/data [get]

func (*KlabDataHandler) InsertKlabDataBulk

func (h *KlabDataHandler) InsertKlabDataBulk(w http.ResponseWriter, r *http.Request)

UpsertKlabDataBulk godoc

@Summary		Upsert k-Lab data (one customer per request)
@Description	Upsert a full k-Lab bundle for a single customer. The JSON root object key must be the customer id.
@Tags			KLAB - Data
@Accept			json
@Produce		json
@Param			data	body	swagger.KlabDataBulkDoc	true	"klab data"
@Success		201		"Data processed successfully"
@Failure		400		{object}	swagger.ValidationErrorResponse
@Failure		401		{object}	swagger.UnauthorizedResponse
@Failure		403		{object}	swagger.ForbiddenResponse
@Failure		500		{object}	swagger.InternalServerErrorResponse
@Failure		503		{object}	swagger.ServiceUnavailableResponse
@Security		BearerAuth
@Router			/klab/data [post]

type KlabDirRawDataInput

type KlabDirRawDataInput struct {
	IdDirRawData  *int32  `json:"idDirRawData" validate:"required"`
	IdMeasurement *int32  `json:"idMeasurement" validate:"required"`
	RawData       *string `json:"rawdata"`
	ColumnData    *string `json:"columndata"`
	Info          *string `json:"info"`
	UnitsData     *string `json:"unitsdata"`
	CreatedBy     *int64  `json:"created_by"`
	ModBy         *int64  `json:"mod_by"`
	ModDate       *string `json:"mod_date"`
	Deleted       *int32  `json:"deleted"`
	CreatedDate   *string `json:"created_date"`
	Modded        *int32  `json:"modded"`
}

type KlabDirReportInput

type KlabDirReportInput struct {
	Iddirreport   *int32  `json:"iddirreport" validate:"required"`
	PageInstr     *string `json:"page_instructions"`
	Idmeasurement *int32  `json:"idmeasurement" validate:"required"`
	TemplateRec   *int32  `json:"template_rec"`
	LibrecName    *string `json:"librec_name"`
	CreatedBy     *int64  `json:"created_by"`
	ModBy         *int64  `json:"mod_by"`
	ModDate       *string `json:"mod_date"`
	Deleted       *int32  `json:"deleted"`
	CreatedDate   *string `json:"created_date"`
	Modded        *int32  `json:"modded"`
}

type KlabDirResultsInput

type KlabDirResultsInput struct {
	Iddirresults       *int32   `json:"iddirresults" validate:"required"`
	Idmeasurement      *int32   `json:"idmeasurement" validate:"required"`
	MaxVo2mlkgmin      *float64 `json:"max_vo2mlkgmin"`
	MaxVo2mlmin        *float64 `json:"max_vo2mlmin"`
	MaxVo2             *float64 `json:"max_vo2"`
	MaxHr              *float64 `json:"max_hr"`
	MaxSpeed           *float64 `json:"max_speed"`
	MaxPace            *float64 `json:"max_pace"`
	MaxP               *float64 `json:"max_p"`
	MaxPkg             *float64 `json:"max_pkg"`
	MaxAngle           *float64 `json:"max_angle"`
	MaxLac             *float64 `json:"max_lac"`
	MaxAdd1            *float64 `json:"max_add1"`
	MaxAdd2            *float64 `json:"max_add2"`
	MaxAdd3            *float64 `json:"max_add3"`
	LacAnkVo2mlkgmin   *float64 `json:"lac_ank_vo2mlkgmin"`
	LacAnkVo2mlmin     *float64 `json:"lac_ank_vo2mlmin"`
	LacAnkVo2          *float64 `json:"lac_ank_vo2"`
	LacAnkVo2pr        *float64 `json:"lac_ank_vo2pr"`
	LacAnkHr           *float64 `json:"lac_ank_hr"`
	LacAnkSpeed        *float64 `json:"lac_ank_speed"`
	LacAnkPace         *float64 `json:"lac_ank_pace"`
	LacAnkP            *float64 `json:"lac_ank_p"`
	LacAnkPkg          *float64 `json:"lac_ank_pkg"`
	LacAnkAngle        *float64 `json:"lac_ank_angle"`
	LacAnkLac          *float64 `json:"lac_ank_lac"`
	LacAnkAdd1         *float64 `json:"lac_ank_add1"`
	LacAnkAdd2         *float64 `json:"lac_ank_add2"`
	LacAnkAdd3         *float64 `json:"lac_ank_add3"`
	LacAerkVo2mlkgmin  *float64 `json:"lac_aerk_vo2mlkgmin"`
	LacAerkVo2mlmin    *float64 `json:"lac_aerk_vo2mlmin"`
	LacAerkVo2         *float64 `json:"lac_aerk_vo2"`
	LacAerkVo2pr       *float64 `json:"lac_aerk_vo2pr"`
	LacAerkHr          *float64 `json:"lac_aerk_hr"`
	LacAerkSpeed       *float64 `json:"lac_aerk_speed"`
	LacAerkPace        *float64 `json:"lac_aerk_pace"`
	LacAerkP           *float64 `json:"lac_aerk_p"`
	LacAerkPkg         *float64 `json:"lac_aerk_pkg"`
	LacAerkAngle       *float64 `json:"lac_aerk_angle"`
	LacAerkLac         *float64 `json:"lac_aerk_lac"`
	LacAerkAdd1        *float64 `json:"lac_aerk_add1"`
	LacAerkAdd2        *float64 `json:"lac_aerk_add2"`
	LacAerkAdd3        *float64 `json:"lac_aerk_add3"`
	VentAnkVo2mlkgmin  *float64 `json:"vent_ank_vo2mlkgmin"`
	VentAnkVo2mlmin    *float64 `json:"vent_ank_vo2mlmin"`
	VentAnkVo2         *float64 `json:"vent_ank_vo2"`
	VentAnkVo2pr       *float64 `json:"vent_ank_vo2pr"`
	VentAnkHr          *float64 `json:"vent_ank_hr"`
	VentAnkSpeed       *float64 `json:"vent_ank_speed"`
	VentAnkPace        *float64 `json:"vent_ank_pace"`
	VentAnkP           *float64 `json:"vent_ank_p"`
	VentAnkPkg         *float64 `json:"vent_ank_pkg"`
	VentAnkAngle       *float64 `json:"vent_ank_angle"`
	VentAnkLac         *float64 `json:"vent_ank_lac"`
	VentAnkAdd1        *float64 `json:"vent_ank_add1"`
	VentAnkAdd2        *float64 `json:"vent_ank_add2"`
	VentAnkAdd3        *float64 `json:"vent_ank_add3"`
	VentAerkVo2mlkgmin *float64 `json:"vent_aerk_vo2mlkgmin"`
	VentAerkVo2mlmin   *float64 `json:"vent_aerk_vo2mlmin"`
	VentAerkVo2        *float64 `json:"vent_aerk_vo2"`
	VentAerkVo2pr      *float64 `json:"vent_aerk_vo2pr"`
	VentAerkHr         *float64 `json:"vent_aerk_hr"`
	VentAerkSpeed      *float64 `json:"vent_aerk_speed"`
	VentAerkPace       *float64 `json:"vent_aerk_pace"`
	VentAerkP          *float64 `json:"vent_aerk_p"`
	VentAerkPkg        *float64 `json:"vent_aerk_pkg"`
	VentAerkAngle      *float64 `json:"vent_aerk_angle"`
	VentAerkLac        *float64 `json:"vent_aerk_lac"`
	VentAerkAdd1       *float64 `json:"vent_aerk_add1"`
	VentAerkAdd2       *float64 `json:"vent_aerk_add2"`
	VentAerkAdd3       *float64 `json:"vent_aerk_add3"`
	CreatedBy          *int64   `json:"created_by"`
	ModBy              *int64   `json:"mod_by"`
	ModDate            *string  `json:"mod_date"`
	Deleted            *int32   `json:"deleted"`
	CreatedDate        *string  `json:"created_date"`
	Modded             *int32   `json:"modded"`
}

type KlabDirTestInput

type KlabDirTestInput struct {
	IdDirTest     *int32   `json:"idDirTest" validate:"required"`
	IdMeasurement *int32   `json:"idMeasurement" validate:"required"`
	MeasCols      *string  `json:"MeasCols"`
	WeightKg      *float64 `json:"weightkg"`
	HeightCm      *float64 `json:"heightcm"`
	BMI           *float64 `json:"bmi"`
	FatPr         *float64 `json:"fat_pr"`
	FatP1         *float64 `json:"fat_p1"`
	FatP2         *float64 `json:"fat_p2"`
	FatP3         *float64 `json:"fat_p3"`
	FatP4         *float64 `json:"fat_p4"`
	FatStyle      *int32   `json:"fat_style"`
	FatEquip      *string  `json:"fat_equip"`
	FVC           *float64 `json:"fvc"`
	FEV1          *float64 `json:"fev1"`
	AirPress      *float64 `json:"air_press"`
	AirTemp       *float64 `json:"air_temp"`
	AirHumid      *float64 `json:"air_humid"`
	TestProtocol  *string  `json:"testprotocol"`
	AirPressUnit  *int32   `json:"air_press_unit"`
	SettingsList  *string  `json:"settingslist"`
	Lt1X          *float64 `json:"lt1_x"`
	Lt1Y          *float64 `json:"lt1_y"`
	Lt2X          *float64 `json:"lt2_x"`
	Lt2Y          *float64 `json:"lt2_y"`
	Vt1X          *float64 `json:"vt1_x"`
	Vt2X          *float64 `json:"vt2_x"`
	Vt1Y          *float64 `json:"vt1_y"`
	Vt2Y          *float64 `json:"vt2_y"`
	Lt1CalcX      *float64 `json:"lt1_calc_x"`
	Lt1CalcY      *float64 `json:"lt1_calc_y"`
	Lt2CalcX      *float64 `json:"lt2_calc_x"`
	Lt2CalcY      *float64 `json:"lt2_calc_y"`
	ProtocolModel *int32   `json:"protocolmodel"`
	TestType      *int32   `json:"testtype"`
	ProtocolXVal  *int32   `json:"protocolxval"`
	StepTime      *int32   `json:"steptime"`
	WRest         *int32   `json:"w_rest"`
	CreatedBy     *int64   `json:"created_by"`
	ModBy         *int64   `json:"mod_by"`
	ModDate       *string  `json:"mod_date"`
	Deleted       *int32   `json:"deleted"`
	CreatedDate   *string  `json:"created_date"`
	Modded        *int32   `json:"modded"`
	NoRawData     *int32   `json:"norawdata"`
}

type KlabDirTestStepInput

type KlabDirTestStepInput struct {
	Iddirteststeps *int32   `json:"iddirteststeps" validate:"required"`
	Idmeasurement  *int32   `json:"idmeasurement" validate:"required"`
	Stepno         *int32   `json:"stepno"`
	AnaTime        *int32   `json:"ana_time"`
	TimeStop       *float64 `json:"timestop"`
	Speed          *float64 `json:"speed"`
	Pace           *float64 `json:"pace"`
	Angle          *float64 `json:"angle"`
	Elev           *float64 `json:"elev"`
	Vo2calc        *float64 `json:"vo2calc"`
	TTot           *float64 `json:"t_tot"`
	TEx            *float64 `json:"t_ex"`
	Fico2          *float64 `json:"fico2"`
	Fio2           *float64 `json:"fio2"`
	Feco2          *float64 `json:"feco2"`
	Feo2           *float64 `json:"feo2"`
	Vde            *float64 `json:"vde"`
	Vco2           *float64 `json:"vco2"`
	Vo2            *float64 `json:"vo2"`
	Bf             *float64 `json:"bf"`
	Ve             *float64 `json:"ve"`
	Petco2         *float64 `json:"petco2"`
	Peto2          *float64 `json:"peto2"`
	Vo2kg          *float64 `json:"vo2kg"`
	Re             *float64 `json:"re"`
	Hr             *float64 `json:"hr"`
	La             *float64 `json:"la"`
	Rer            *float64 `json:"rer"`
	VeStpd         *float64 `json:"ve_stpd"`
	Veo2           *float64 `json:"veo2"`
	Veco2          *float64 `json:"veco2"`
	Tv             *float64 `json:"tv"`
	EeAe           *float64 `json:"ee_ae"`
	LaVo2          *float64 `json:"la_vo2"`
	O2pulse        *float64 `json:"o2pulse"`
	VdeTv          *float64 `json:"vde_tv"`
	Va             *float64 `json:"va"`
	O2sa           *float64 `json:"o2sa"`
	Rpe            *float64 `json:"rpe"`
	BpSys          *float64 `json:"bp_sys"`
	BpDia          *float64 `json:"bp_dia"`
	Own1           *float64 `json:"own1"`
	Own2           *float64 `json:"own2"`
	Own3           *float64 `json:"own3"`
	Own4           *float64 `json:"own4"`
	Own5           *float64 `json:"own5"`
	StepIsRest     *int32   `json:"step_is_rest"`
	StepIs30max    *int32   `json:"step_is_30max"`
	StepIs60max    *int32   `json:"step_is_60max"`
	StepIsRec      *int32   `json:"step_is_rec"`
	CalcStart      *int32   `json:"calc_start"`
	CalcEnd        *int32   `json:"calc_end"`
	Comments       *string  `json:"comments"`
	TimeStart      *float64 `json:"timestart"`
	Duration       *float64 `json:"duration"`
	Eco            *float64 `json:"eco"`
	P              *float64 `json:"p"`
	Wkg            *float64 `json:"wkg"`
	Vo230s         *float64 `json:"vo2_30s"`
	Vo2Pr          *float64 `json:"vo2_pr"`
	StepIsLast     *int32   `json:"step_is_last"`
	Deleted        *int32   `json:"deleted"`
	CreatedBy      *int64   `json:"created_by"`
	ModBy          *int64   `json:"mod_by"`
	ModDate        *string  `json:"mod_date"`
	CreatedDate    *string  `json:"created_date"`
	Modded         *int32   `json:"modded"`
	Own6           *float64 `json:"own6"`
	Own7           *float64 `json:"own7"`
	Own8           *float64 `json:"own8"`
	Own9           *float64 `json:"own9"`
	Own10          *float64 `json:"own10"`
	To2            *float64 `json:"to2"`
	Tco2           *float64 `json:"tco2"`
}

type KlabMeasurementInput

type KlabMeasurementInput struct {
	IdMeasurement  *int32  `json:"idMeasurement" validate:"required"`
	MeasName       *string `json:"MeasName"`
	IdCustomer     *int32  `json:"idCustomer"`
	TableName      *string `json:"tableName"`
	IdPatternDef   *string `json:"idpatterndef"`
	DoYear         *int32  `json:"do_year"`
	DoMonth        *int32  `json:"do_month"`
	DoDay          *int32  `json:"do_day"`
	DoHour         *int32  `json:"do_hour"`
	DoMin          *int32  `json:"do_min"`
	SessionNo      *int32  `json:"sessionno"`
	Info           *string `json:"info"`
	Measurements   *string `json:"measurements"`
	GroupNotes     *string `json:"groupnotes"`
	CbCharts       *string `json:"cbcharts"`
	CbComments     *string `json:"cbcomments"`
	CreatedBy      *int64  `json:"created_by"`
	ModBy          *int64  `json:"mod_by"`
	ModDate        *string `json:"mod_date"`
	Deleted        *int32  `json:"deleted"`
	CreatedDate    *string `json:"created_date"`
	Modded         *int32  `json:"modded"`
	TestLocation   *string `json:"test_location"`
	Keywords       *string `json:"keywords"`
	TesterName     *string `json:"tester_name"`
	ModderName     *string `json:"modder_name"`
	MeasType       *int32  `json:"meastype"`
	SentToSprintAI *string `json:"sent_to_sprintai"`
}

type KlabUserParams

type KlabUserParams struct {
	ID string `validate:"required,numeric"`
}

type SporttiIDParam

type SporttiIDParam struct {
	SporttiID string `form:"sportti_id" validate:"required,numeric"`
}

type UserDataHandler

type UserDataHandler struct {
	// contains filtered or unexported fields
}

func NewUserDataHandler

func NewUserDataHandler(store klab.Users, cache *cache.Storage) *UserDataHandler

func (*UserDataHandler) DeleteUser

func (h *UserDataHandler) DeleteUser(w http.ResponseWriter, r *http.Request)

DeleteUser godoc

@Summary		Delete a customer (hard delete)
@Description	Removes a KLab customer by sportti_id. Related measurement_list and dir* tables are removed via FK cascades.
@Tags			KLAB - User
@Accept			json
@Produce		json
@Param			sportti_id	query	string	true	"Sportti ID"
@Success		200
@Failure		400	{object}	swagger.ValidationErrorResponse
@Failure		401	{object}	swagger.UnauthorizedResponse
@Failure		403	{object}	swagger.ForbiddenResponse
@Failure		404	{object}	swagger.NotFoundResponse
@Failure		500	{object}	swagger.InternalServerErrorResponse
@Failure		503	{object}	swagger.ServiceUnavailableResponse
@Security		BearerAuth
@Router			/klab/user [delete]

func (*UserDataHandler) GetUser

func (h *UserDataHandler) GetUser(w http.ResponseWriter, r *http.Request)

GetUser godoc

@Summary		Get customer by Sportti ID
@Description	Retrieve a single KLAB customer by sportti_id
@Tags			KLAB - User
@Accept			json
@Produce		json
@Param			id	query		integer	true	"Sportti ID"
@Success		200	{object}	swagger.UserKlabResponse
@Failure		400	{object}	swagger.ValidationErrorResponse
@Failure		401	{object}	swagger.UnauthorizedResponse
@Failure		403	{object}	swagger.ForbiddenResponse
@Failure		404	{object}	swagger.NotFoundResponse
@Failure		500	{object}	swagger.InternalServerErrorResponse
@Failure		503	{object}	swagger.ServiceUnavailableResponse
@Security		BearerAuth
@Router			/klab/user [get]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL