Skip to content

Commit

Permalink
Update data availability table automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertware committed Feb 3, 2025
1 parent e5b1156 commit 93b1f8e
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 62 deletions.
2 changes: 1 addition & 1 deletion content/api/gtfs-datasets/gtfs-regional/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ per minute, see [realtime data](#realtime-data) for more information.

### Operators covered by this dataset

{{% include "/headless/stip-data-availability.md" %}}
{{% stip-data-availability %}}

### Breaking changes

Expand Down
3 changes: 2 additions & 1 deletion content/api/gtfs-datasets/gtfs-sweden/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ The static data in this dataset is updated on a daily basis. The real-time data
per minute, see [realtime data](#realtime-data) for more information.

### Operators covered by this dataset
{{% include "/headless/stip-data-availability.md" %}}

{{% stip-data-availability %}}

### Breaking changes
These datasets have the **stable** status. This means that we will communicate when fields are
Expand Down
3 changes: 2 additions & 1 deletion content/api/netex-datasets/netex-regional/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ visit [Samtrafiken Open Data - NeTEx](https://samtrafiken.atlassian.net/wiki/spa
The static data in this dataset is updated on a daily basis, typically between 03:00 and 07:00.

### Operators covered by this dataset
{{% include "/headless/stip-data-availability.md" %}}

{{% stip-data-availability %}}

### Breaking changes
This dataset has the **stable** status. This means that the fields can be added without prior warning, but when changes
Expand Down
2 changes: 1 addition & 1 deletion content/api/netex-datasets/netex-sweden/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The static data in this dataset is updated on a daily basis, typically between 1

### Operators covered by this dataset

{{% include "/headless/stip-data-availability.md" %}}
{{% stip-data-availability-static %}}

### Breaking changes

Expand Down
58 changes: 0 additions & 58 deletions content/headless/stip-data-availability.md

This file was deleted.

4 changes: 4 additions & 0 deletions themes/trafiklab-2024/assets/sass/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,8 @@ h6 {
// caption under a centered image should be centered
width: 100%;
text-align: center;
}

.tl-muted {
color: $color-gray-dark;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{ $data := slice }}
{{ $url := "https://prod-stip-pingdom-status-export.s3.eu-central-1.amazonaws.com/data-availability.json" }}
{{ with resources.GetRemote $url }}
{{ $data = . | transform.Unmarshal }}
{{ end }}

The following table shows which operators are covered by this dataset.

<table>
<thead>
<tr>
<th>Operator</th>
<th>Abbreviation</th>
<th>Static data</th>
</tr>
</thead>
<tbody>
{{ range $key, $value := $data }}
{{ if not (eq (printf "%T" $value) "string") }}
{{ if eq (index $value "staticData") true }}
<tr>
<td>{{ .name }}</td>
<td><code>{{.shortname}}</code></td>
<td>{{ if eq (index $value "staticData") true }} ✔️ {{ end }}</td>
</tr>
{{ end }}
{{ end }}
{{ end }}
<tr>
<td class="tl-muted" colspan="3">Last updated: {{ strings.Substr (index $data "last-update") 0 10 }}</td>
</tr>
</tbody>
</table>

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{ $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") }}
{{ $opts := dict "key" $cacheKey }}
{{ with resources.GetRemote $url $opts }}
{{ $data = . | transform.Unmarshal }}
{{ end }}

The following table shows which operators are covered by this dataset.

<table>
<thead>
<tr>
<th>Operator</th>
<th>Abbreviation</th>
<th>Static data</th>
<th>Real-time data</th>
<th>Vehicle positions</th>
<th>Occupancy data</th>
</tr>
</thead>
<tbody>
{{ range $key, $value := $data }}
{{ if not (eq (printf "%T" $value) "string") }}
{{ if eq (index $value "staticData") true }}
<tr>
<td>{{ .name }}</td>
<td><code>{{.shortname}}</code></td>
<td>{{ if eq (index $value "staticData") true }} ✔️ {{ end }}</td>
<td>{{ if eq (index $value "tripUpdates") true }} ✔️ {{ end }}</td>
<td>{{ if eq (index $value "vehiclePositions") true }} ✔️ {{ end }}</td>
<td>{{ if or (eq (index $value "shortname") "skane") (eq (index $value "shortname") "otraf") }} ✔️ {{ end }}</td>
</tr>
{{ end }}
{{ end }}
{{ end }}
<tr>
<td class="tl-muted" colspan="5">Last updated: {{ strings.Substr (index $data "last-update") 0 10 }}</td>
</tr>
</tbody>
</table>

0 comments on commit 93b1f8e

Please sign in to comment.