The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/services/star/model.go

54 lines
1.1 KiB

package star
import "errors"
var ErrCommandValidationFailed = errors.New("command missing required fields")
type Star struct {
ID int64 `xorm:"pk autoincr 'id'" db:"id"`
UserID int64 `xorm:"user_id" db:"user_id"`
DashboardID int64 `xorm:"dashboard_id" db:"dashboard_id"`
}
// ----------------------
// COMMANDS
type StarDashboardCommand struct {
UserID int64 `xorm:"user_id"`
DashboardID int64 `xorm:"dashboard_id"`
}
func (cmd *StarDashboardCommand) Validate() error {
if cmd.DashboardID == 0 || cmd.UserID == 0 {
return ErrCommandValidationFailed
}
return nil
}
type UnstarDashboardCommand struct {
UserID int64 `xorm:"user_id"`
DashboardID int64 `xorm:"dashboard_id"`
}
func (cmd *UnstarDashboardCommand) Validate() error {
if cmd.DashboardID == 0 || cmd.UserID == 0 {
return ErrCommandValidationFailed
}
return nil
}
// ---------------------
// QUERIES
type GetUserStarsQuery struct {
UserID int64 `xorm:"user_id"`
}
type IsStarredByUserQuery struct {
UserID int64 `xorm:"user_id"`
DashboardID int64 `xorm:"dashboard_id"`
}
type GetUserStarsResult struct {
UserStars map[int64]bool
}