added template, fixed typos, added interval querying
parent
7e62f366e7
commit
ae0b2b2890
@ -0,0 +1,18 @@
|
||||
.PHONY: postgres adminer migrate
|
||||
|
||||
postgres:
|
||||
docker run --rm -ti --network host -e POSTGRES_PASSWORD=secret postgres
|
||||
|
||||
adminer:
|
||||
docker run --rm -ti --network host adminer
|
||||
|
||||
reflex:
|
||||
reflex -s go run cmd/goddit/main.go
|
||||
|
||||
migrate:
|
||||
migrate -source file://migrations \
|
||||
-database postgres://postgres:secret@localhost/postgres?sslmode=disable up
|
||||
|
||||
migrate-down:
|
||||
migrate -source file://migrations \
|
||||
-database postgres://postgres:secret@localhost/postgres?sslmode=disable down
|
@ -0,0 +1,12 @@
|
||||
module git.snrd.de/Spaenny/steamServer
|
||||
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
git.snrd.de/Spaenny/steamserver v0.0.0-20210920125724-7e62f366e7e0
|
||||
github.com/go-chi/chi v1.5.4
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/jmoiron/sqlx v1.3.4
|
||||
github.com/lib/pq v1.10.3
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
)
|
@ -0,0 +1,17 @@
|
||||
git.snrd.de/Spaenny/steamserver v0.0.0-20210920125724-7e62f366e7e0 h1:b43+U83rjT0A+1k6MP5Muu/crGVzciaszaPGIFBXNow=
|
||||
git.snrd.de/Spaenny/steamserver v0.0.0-20210920125724-7e62f366e7e0/go.mod h1:rl0ho92HJaP8HYnk2Fwqq4fWnFrVaolgiadz5iPqRWk=
|
||||
github.com/go-chi/chi v1.5.4 h1:QHdzF2szwjqVV4wmByUnTcsbIg7UGaQ0tPF2t5GcAIs=
|
||||
github.com/go-chi/chi v1.5.4/go.mod h1:uaf8YgoFazUOkPBG7fxPftUylNumIev9awIWOENIuEg=
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/jmoiron/sqlx v1.3.4 h1:wv+0IJZfL5z0uZoUjlpKgHkgaFSYD+r9CfrXjEXsO7w=
|
||||
github.com/jmoiron/sqlx v1.3.4/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg=
|
||||
github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg=
|
||||
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
@ -1,46 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
|
||||
type Server struct {
|
||||
AppID int `json:"AppID"`
|
||||
Name string `json:"Name"`
|
||||
Map string `json:"Map"`
|
||||
Players int `json:"Players"`
|
||||
MaxPlayers int `json:"MaxPlayers"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
serverJSON := `{
|
||||
"Protocol": 17,
|
||||
"Name": "Spenny.TF | DM #1",
|
||||
"Map": "cp_process_final",
|
||||
"Folder": "tf",
|
||||
"Game": "TFTrue deathmatch ",
|
||||
"AppID": 440,
|
||||
"Players": 0,
|
||||
"MaxPlayers": 8,
|
||||
"Bots": 0,
|
||||
"ServerType": 1,
|
||||
"ServerOS": 1,
|
||||
"Visibility": false,
|
||||
"VAC": true,
|
||||
"Version": "6774624",
|
||||
"EDF": 177,
|
||||
"ExtendedServerInfo": {
|
||||
"Port": 27015,
|
||||
"SteamID": 90151367621494793,
|
||||
"Keywords": "cp,nocrits",
|
||||
"GameID": 440
|
||||
}
|
||||
}`
|
||||
|
||||
var server Server
|
||||
json.Unmarshal([]byte(serverJSON), &server)
|
||||
fmt.Println(server)
|
||||
}
|
||||
|
@ -1,21 +1,20 @@
|
||||
CREATE TABLE servers (
|
||||
CREATE TABLE regions (
|
||||
id UUID PRIMARY KEY,
|
||||
region_id UUID NOT NULL REFERENCES regions(id) ON DELETE CASCADE,
|
||||
gamemode_id UUID NOT NULL REFERENCES gamemodes(id) ON DELETE CASCADE,
|
||||
app_id INT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
map TEXT NOT NULL,
|
||||
players INT,
|
||||
max_players INT
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE regions (
|
||||
CREATE TABLE gamemodes (
|
||||
id UUID PRIMARY KEY,
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE gamemodes (
|
||||
CREATE TABLE servers (
|
||||
id UUID PRIMARY KEY,
|
||||
region_id UUID NOT NULL REFERENCES regions(id) ON DELETE CASCADE,
|
||||
gamemode_id UUID NOT NULL REFERENCES gamemodes(id) ON DELETE CASCADE,
|
||||
app_id INT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
description NOT NULL
|
||||
map TEXT NOT NULL,
|
||||
players INT,
|
||||
max_players INT
|
||||
);
|
||||
|
@ -0,0 +1,58 @@
|
||||
<html lang="en"><head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://unpkg.com/tailwindcss@1.0.4/dist/tailwind.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body class="h-screen overflow-hidden flex items-center justify-center" style="background: #edf2f7;">
|
||||
|
||||
<div class="container mx-auto px-4 sm:px-8">
|
||||
<div class="py-8">
|
||||
<div>
|
||||
<h2 class="text-2xl font-semibold leading-tight">Serverlist</h2>
|
||||
</div>
|
||||
|
||||
<div class="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
|
||||
<div class="inline-block min-w-full shadow rounded-lg overflow-hidden">
|
||||
<table class="min-w-full leading-normal">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||
Servername
|
||||
</th>
|
||||
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||
Map
|
||||
</th>
|
||||
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||
Players
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Servers}}
|
||||
<tr>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="flex items-center">
|
||||
|
||||
<div class="ml-3">
|
||||
<p class="text-gray-900 whitespace-no-wrap">{{.Name}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<p class="text-gray-900 whitespace-no-wrap">{{.Map}}</p>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<p class="text-gray-900 whitespace-no-wrap">{{.Players}}/{{.MaxPlayers}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue