From 0c6f300f90bf576ffd67df7331fc57b55c5484d3 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 8 May 2021 00:43:14 +0200 Subject: Added start and end dates to recent items --- models.go | 3 +++ page.css | 25 +++++++++++++------------ recent.tmpl | 11 +++++++---- storage.go | 18 ++++++++++++++++-- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/models.go b/models.go index 95c30c8..d79850b 100644 --- a/models.go +++ b/models.go @@ -14,6 +14,8 @@ type Team []uint32 type Battle struct { Id string `json:"-"` LastModified time.Time `json:"-"` + StartTime time.Time `json:"started_at"` + EndTime time.Time `json:"ended_at"` Teams [2]Team `json:"teams"` Killmails []Killmail `json:"killmails"` Name string `json:"name"` @@ -28,6 +30,7 @@ type EsiKillmail struct { Z float64 `json:"z"` } `json:"position"` } `json:"victim"` + Time time.Time `json:"killmail_time"` } type EsiUniverseSystem struct { diff --git a/page.css b/page.css index a7733a1..bd3b5e2 100644 --- a/page.css +++ b/page.css @@ -59,24 +59,25 @@ footer { padding: 1em; } -.recent-item .id { - color: #555; - font-size: 80% +.recent-item { + padding: 0.2em; + border-bottom: 1px solid #242529; } -.recent-item > header { - text-align: inherit; +.recent-item:hover { + background: #1e1f23; } -.recent-item > header > .last-modified { - float: right; +.recent-item > .details { + color: #555; + font-size: 80%; } -.recent-item { - padding: 0.2em; - border-bottom: 1px solid #242529; +.left-right { + display: flex; + justify-content: space-between; } -.recent-item:hover { - background: #1e1f23; +.left-right > * { + display: block; } diff --git a/recent.tmpl b/recent.tmpl index 6d20a8c..8311636 100644 --- a/recent.tmpl +++ b/recent.tmpl @@ -14,11 +14,14 @@

Recent

{{range .}}
-
+
{{.Name}} - {{.LastModified.Format "January 02, 2006 15:04 UTC"}} -
- {{.Id}} + {{.StartTime.Format "January 02, 2006 15:04 UTC"}} +
+
+ {{.Id}} + Last updated on {{.StartTime.Format "January 02, 2006 15:04 UTC"}} +
{{end}}

About

diff --git a/storage.go b/storage.go index 9a8b8fc..738826e 100644 --- a/storage.go +++ b/storage.go @@ -78,12 +78,26 @@ func (s *Storage) AddBattle(battle *Battle) error { if err != nil { return err } - battle.Name = fmt.Sprintf("Battle in %s", system.Name) + battle.Name = fmt.Sprintf("Fight in %s", system.Name) + battle.StartTime = details.Time + battle.EndTime = details.Time + for _, km := range battle.Killmails[1:] { + details, err := GetKillmail(km.Id, km.Hash) + if err != nil { + return err + } + if battle.StartTime.After(details.Time) { + battle.StartTime = details.Time + } + if battle.EndTime.Before(details.Time) { + battle.EndTime = details.Time + } + } + data, err := json.Marshal(battle) if err != nil { return err } - return ioutil.WriteFile(s.Path+"/battles/"+battle.Id, data, 0644) } -- cgit v1.1