// TODO(gaozifeng): Consider using https://github.com/smallnest/gen to generate Go structs.

package db

import (
	"encoding/json"
	"time"

	"github.com/pingcap/test-infra/common/model"
)

type User struct {
	ID        model.ID  `db:"id"`
	Email     string    `db:"email"`
	Name      string    `db:"name"`
	Avatar    string    `db:"avatar"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type PersonalToken struct {
	ID          model.ID         `db:"id"`
	UserID      model.ID         `db:"user_id"`
	Name        string           `db:"name"`
	HashedToken string           `db:"hashed_token"`
	ExpiresAt   *model.Timestamp `db:"expires_at"`
	LastUsedAt  *int64           `db:"last_used_at"`
	Scopes      *string          `db:"scopes"`
	CreatedAt   time.Time        `db:"created_at"`
	UpdatedAt   time.Time        `db:"updated_at"`
}

type DailySummary struct {
	Date    string  `db:"date"`
	Summary *string `db:"summary"`
}

type ResourcePool struct {
	ID        model.ID  `db:"id"`
	RmsName   string    `db:"rms_name"`
	Name      string    `db:"name"`
	Aliases   string    `db:"aliases"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`

	TotalCPU              float64 `db:"total_cpu"`
	TotalMEM              uint64  `db:"total_mem"`
	NonTestbedOccupiedCPU float64 `db:"nontestbed_occupied_cpu"`
	NonTestbedOccupiedMEM uint64  `db:"nontestbed_occupied_mem"`
	IdleCPU               float64 `db:"idle_cpu"`
	IdleMEM               uint64  `db:"idle_mem"`

	BorrowedPolicy model.ResourcePoolBorrowedPolicies `db:"borrowed_policy"`
}

type TestbedSetup struct {
	ID   model.ID        `db:"id"`
	Body json.RawMessage `db:"body"`
}
