/
run.go
56 lines (49 loc) · 2.01 KB
/
run.go
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
53
54
55
56
package main
import (
"context"
"database/sql"
"flag"
"fmt"
"os"
"github.com/target/goalert/util/log"
_ "github.com/jackc/pgx/v4/stdlib"
)
var queries = [][]string{
{"UserCount", `select count(id) from users`},
{"CMMax", `select count(id) from user_contact_methods group by user_id order by count desc limit 1`},
{"NRMax", `select count(id) from user_notification_rules group by user_id order by count desc limit 1`},
{"NRCMMax", `select count(id) from user_notification_rules group by user_id,contact_method_id order by count desc limit 1`},
{"EPCount", `select count(id) from escalation_policies`},
{"EPMaxStep", `select count(id) from escalation_policy_steps group by escalation_policy_id order by count desc limit 1`},
{"EPMaxAssigned", `select count(id) from escalation_policy_actions group by escalation_policy_step_id order by count desc limit 1`},
{"SvcCount", `select count(id) from services`},
{"RotationMaxPart", `select count(id) from rotation_participants group by rotation_id order by count desc limit 1`},
{"ScheduleCount", `select count(id) from schedules`},
{"AlertClosedCount", `select count(id) from alerts where status = 'closed'`},
{"AlertActiveCount", `select count(id) from alerts where status = 'triggered' or status = 'active'`},
{"RotationCount", `select count(id) from rotations`},
{"IntegrationKeyMax", `select count(id) from integration_keys group by service_id order by count desc limit 1`},
{"ScheduleMaxRules", `select count(id) from schedule_rules group by schedule_id order by count desc limit 1`},
}
func noErr(err error) {
if err == nil {
return
}
log.Log(context.TODO(), err)
os.Exit(1)
}
func main() {
mult := flag.Float64("m", 1.5, "Multiplier for prod values.")
url := flag.String("db", os.Getenv("DB_URL"), "DB connection URL.")
flag.Parse()
db, err := sql.Open("pgx", *url)
noErr(err)
for _, q := range queries {
var n int
row := db.QueryRow(q[1])
noErr(row.Scan(&n))
n = int(float64(n)**mult) + 1
fmt.Printf("\t%s = %d // %s\n", q[0], n, q[1])
}
db.Close()
}