~emersion/drmdb

4d007f2f85a19c84159df7345cca5e675a32f0e2 — Simon Ser 2 years ago 13f521b
Fix /formats page stats
2 files changed, 17 insertions(+), 15 deletions(-)

M public/formats.html
M server.go
M public/formats.html => public/formats.html +4 -4
@@ 33,11 33,11 @@
            {{$row := .}}
            <td class="pre">{{.Modifier}}</td>
            <td class="pre">{{.Format}}</td>
            {{range $plane, $_ := $.Planes}}
            {{template "pct-cell" (pct (index $row.Planes $plane) $.Total)}}
            {{range $plane, $total := $.Planes}}
            {{template "pct-cell" (pct (index $row.Planes $plane) $total)}}
            {{end}}
            {{range $drv, $_ := $.Drivers}}
            {{template "pct-cell" (pct (index $row.Drivers $drv) $.Total)}}
            {{range $drv, $total := $.Drivers}}
            {{template "pct-cell" (pct (index $row.Drivers $drv) $total)}}
            {{end}}
        </tr>
        {{end}}

M server.go => server.go +13 -11
@@ 400,22 400,25 @@ func New() *echo.Echo {
			Drivers map[string]int
		}

		total := 0
		planes := make(map[drm.PlaneType]bool)
		drivers := make(map[string]bool)
		// For each (modifier, format) pair, build two tables by walking each
		// device:
		// - Number of devices supporting it by plane type (max: number of
		//   devices having such a plane)
		// - Number of devices supporting it by driver (max: number of devices
		//   supported by the driver)
		planes := make(map[drm.PlaneType]int)
		drivers := make(map[string]int)
		formats := make(map[modifierAndFormat]formatData)
		err := walkLatest(walkLatestDevice, func(k string, n *drmtree.Node) error {
			total++
			drivers[n.Driver.Name] = true
			drivers[n.Driver.Name]++

			planeFormats := make(map[drm.PlaneType]map[modifierAndFormat]bool)
			driverFormats := make(map[modifierAndFormat]bool)

			for _, plane := range n.Planes {
				planes[plane.Type()] = true

				if _, ok := planeFormats[plane.Type()]; !ok {
					planeFormats[plane.Type()] = make(map[modifierAndFormat]bool)
					planes[plane.Type()]++
				}

				inFormats := plane.InFormats()


@@ 450,11 453,10 @@ func New() *echo.Echo {
		}

		return c.Render(http.StatusOK, "formats.html", struct {
			Total int
			Planes map[drm.PlaneType]bool
			Drivers map[string]bool
			Planes map[drm.PlaneType]int
			Drivers map[string]int
			Formats map[modifierAndFormat]formatData
		}{total, planes, drivers, formats})
		}{planes, drivers, formats})
	})

	e.Static("/assets", "public/assets")