aboutsummaryrefslogtreecommitdiff
path: root/backend/internal/model/types.go
blob: 4e439b8b038bc7b73a954881eeed90f3963a52b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package model

import "time"

type Service struct {
	ID                int       `json:"id"`
	Name              string    `json:"name"`
	URL               string    `json:"url"`
	GroupName         string    `json:"group_name"`
	IntervalSeconds   int       `json:"interval_seconds"`
	IsActive          bool      `json:"is_active"`
	DiscordWebhookURL string    `json:"discord_webhook_url,omitempty"`
	AlertEmail        string    `json:"alert_email,omitempty"`
	KeywordToFind     string    `json:"keyword_to_find,omitempty"`
	CreatedAt         time.Time `json:"created_at"`
}

type Heartbeat struct {
	ID             int       `json:"id"`
	ServiceID      int       `json:"service_id"`
	StatusCode     int       `json:"status_code"`
	ResponseTimeMs int64     `json:"response_time_ms"`
	IsUp           bool      `json:"is_up"`
	ErrorMessage   string    `json:"error_message,omitempty"`
	TestedAt       time.Time `json:"tested_at"`
}

type Maintenance struct {
	ID        int       `json:"id"`
	Title     string    `json:"title"`
	StartTime time.Time `json:"start_time"`
	EndTime   time.Time `json:"end_time"`
	IsActive  bool      `json:"is_active"`
}

type ServiceStats struct {
	ServiceID       int     `json:"service_id"`
	Uptime24h       float64 `json:"uptime_24h"`
	Uptime7d        float64 `json:"uptime_7d"`
	Uptime30d       float64 `json:"uptime_30d"`
	AvgResponseMs24h float64 `json:"avg_response_ms_24h"`
	AvgResponseMs7d  float64 `json:"avg_response_ms_7d"`
	AvgResponseMs30d float64 `json:"avg_response_ms_30d"`
	TotalChecks24h  int     `json:"total_checks_24h"`
	TotalChecks7d   int     `json:"total_checks_7d"`
	TotalChecks30d  int     `json:"total_checks_30d"`
}

type ServiceWithHeartbeat struct {
	Service
	LastHeartbeat *Heartbeat `json:"last_heartbeat,omitempty"`
}