Fix cache bugs and player list display bugs.
Some checks are pending
ci/woodpecker/push/build Pipeline is pending
Some checks are pending
ci/woodpecker/push/build Pipeline is pending
This commit is contained in:
parent
ac912af1d9
commit
c209cf05ba
@ -206,18 +206,26 @@
|
||||
<p>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="centered">Player List{{ if .Queried.PlayerCount }} ({{ .Queried.PlayerCount }}) {{ end }}</th>
|
||||
<th>Player List{{ if .Queried.PlayerCount }} ({{ .Queried.PlayerCount }}) {{ end }}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="centered"><a href="{{ .ToggleQuery "players" }}" title="Collapse Player List.">Collapse Player List</a></td>
|
||||
</tr>
|
||||
{{ if gt (len (.Queried.GetPlayers .Data.ShowAnonymousPlayers)) 0 }}
|
||||
{{ if .Data.ShowAnonymousPlayers }}
|
||||
{{ range .Queried.Players }}
|
||||
<tr>
|
||||
<td>{{ if or .Data.ShowAnonymousPlayers (ne . "Anonymous Player") }}{{ . }}{{ end }}</td>
|
||||
<td>{{ . }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ range .Queried.Players }}
|
||||
<tr>
|
||||
<td>{{ if ne . "Anonymous Player" }}{{ . }}{{ end }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<tr>
|
||||
<td>No Detectable Players.</td>
|
||||
</tr>
|
||||
@ -232,7 +240,7 @@
|
||||
<p>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="centered">Mod List ({{ .Queried.PlayerCount }})</th>
|
||||
<th>Mod List ({{ .Queried.PlayerCount }})</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="centered"><a href="{{ .ToggleQuery "mods" }}" title="Collapse Mod List.">Collapse Mod List</a></td>
|
||||
|
@ -42,6 +42,7 @@ type Page struct {
|
||||
LastModifiedTemplate time.Time
|
||||
CachedMC *MC
|
||||
CollectedMCExpiry time.Time
|
||||
LastModifiedMC time.Time
|
||||
CacheMCMutex *sync.Mutex
|
||||
}
|
||||
|
||||
@ -50,10 +51,16 @@ func (p *Page) GetPath() string {
|
||||
}
|
||||
|
||||
func (p *Page) GetLastModified() time.Time {
|
||||
var toTest time.Time
|
||||
if p.LastModifiedData.After(p.LastModifiedTemplate) {
|
||||
return p.LastModifiedData
|
||||
toTest = p.LastModifiedData
|
||||
} else {
|
||||
return p.LastModifiedTemplate
|
||||
toTest = p.LastModifiedTemplate
|
||||
}
|
||||
if p.LastModifiedMC.After(toTest) {
|
||||
return p.LastModifiedMC
|
||||
} else {
|
||||
return toTest
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +121,8 @@ func (p *Page) GetMC(theData *DataYaml, theMarshal *Marshal) MC {
|
||||
theMarshal.Online = false
|
||||
p.CachedMC = nil
|
||||
}
|
||||
p.CollectedMCExpiry = time.Now().Add(theData.MCQueryInterval)
|
||||
p.LastModifiedMC = time.Now()
|
||||
p.CollectedMCExpiry = p.LastModifiedMC.Add(theData.MCQueryInterval)
|
||||
} else {
|
||||
if p.CachedMC == nil {
|
||||
theMC = MC{}
|
||||
|
Loading…
Reference in New Issue
Block a user