Skip to content

Commit

Permalink
Adjust automatic table generation to respect existing list order, ins…
Browse files Browse the repository at this point in the history
…tead of re-sorting based on shortname due to range behaviour
  • Loading branch information
Bertware committed Feb 3, 2025
1 parent 3ee874a commit 94a2b76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{{ $data := slice }}
{{ $url := "https://prod-stip-pingdom-status-export.s3.eu-central-1.amazonaws.com/data-availability.json" }}
{{ with resources.GetRemote $url }}
{{ $cacheKey := print $url (now.Format "2006-01-02 15:04") }}
{{ $opts := dict "key" $cacheKey }}
{{ with resources.GetRemote $url $opts }}
{{ $data = . | transform.Unmarshal }}
{{ end }}

Expand All @@ -15,9 +17,9 @@
</tr>
</thead>
<tbody>
{{ range $key, $value := $data }}
{{ range $value := $data }}
{{ if not (eq (printf "%T" $value) "string") }}
{{ if eq (index $value "staticData") true }}
{{ if and (eq (index $value "staticData") true) (eq (index $value "trafiklabEnabled") true) }}
<tr>
<td>{{ .name }}</td>
<td><code>{{.shortname}}</code></td>
Expand All @@ -27,7 +29,7 @@
{{ end }}
{{ end }}
<tr>
<td class="tl-muted" colspan="3">Last updated: {{ strings.Substr (index $data "last-update") 0 10 }}</td>
<td class="tl-muted" colspan="3">Last updated: {{ now.Format "2006-01-02" }}</td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ $data := slice }}
{{ $url := "https://prod-stip-pingdom-status-export.s3.eu-central-1.amazonaws.com/data-availability.json" }}
{{ $cacheKey := print $url (now.Format "2006-01-02") }}
{{ $cacheKey := print $url (now.Format "2006-01-02 15:04") }}
{{ $opts := dict "key" $cacheKey }}
{{ with resources.GetRemote $url $opts }}
{{ $data = . | transform.Unmarshal }}
Expand All @@ -20,9 +20,9 @@
</tr>
</thead>
<tbody>
{{ range $key, $value := $data }}
{{ range $value := $data }}
{{ if not (eq (printf "%T" $value) "string") }}
{{ if eq (index $value "staticData") true }}
{{ if and (eq (index $value "staticData") true) (eq (index $value "trafiklabEnabled") true) }}
<tr>
<td>{{ .name }}</td>
<td><code>{{.shortname}}</code></td>
Expand All @@ -35,7 +35,7 @@
{{ end }}
{{ end }}
<tr>
<td class="tl-muted" colspan="5">Last updated: {{ strings.Substr (index $data "last-update") 0 10 }}</td>
<td class="tl-muted" colspan="5">Last updated: {{ now.Format "2006-01-02" }}</td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit 94a2b76

Please sign in to comment.