Skip to content

Commit

Permalink
Finally
Browse files Browse the repository at this point in the history
  • Loading branch information
jakozaur committed May 2, 2024
1 parent 8687231 commit 24f11f6
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions quesma/quesma/ui/unsupported_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"mitmproxy/quesma/model"
"mitmproxy/quesma/tracing"
"regexp"
"sort"
"sync"
)

Expand Down Expand Up @@ -59,7 +60,32 @@ func (qmc *QuesmaManagementConsole) generateReportForUnsupportedRequests() []byt
}
qmc.mutex.Unlock()

return qmc.generateReportForRequests("Unsupported requests", debugKeyValueSlice, []byte{})
types := qmc.GetUnsupportedTypesWithCount()

type typeCount struct {
name string
count int
}
var slice []typeCount
for name, count := range types {
slice = append(slice, typeCount{name, count})
}
sort.Slice(slice, func(i, j int) bool {
return slice[i].count > slice[j].count
})

var buffer HtmlBuffer
buffer.Html("<br />")
buffer.Html(`<h3>Unsupported queries by type</h3>`)
buffer.Html(`<ul id="unsupported-queries-stats">`)
for _, t := range slice {
buffer.Html(fmt.Sprintf(`<li><a class="debug-warn-log" href="/unsupported-requests/%s">`, t.name))
buffer.Text(fmt.Sprintf(`%s: %d`, t.name, t.count))
buffer.Html("</a></li>\n")
}
buffer.Html("</ul>")

return qmc.generateReportForRequests("Unsupported requests", debugKeyValueSlice, buffer.Bytes())
}

func (qmc *QuesmaManagementConsole) generateUnsupportedQuerySidePanel() []byte {
Expand All @@ -79,7 +105,7 @@ func (qmc *QuesmaManagementConsole) generateUnsupportedQuerySidePanel() []byte {
}

var buffer HtmlBuffer
linkToMainView := `<li><a href="/unsupported-requests/"`
linkToMainView := `<li><a href="/unsupported-requests"`
buffer.Html(`<ul id="unsupported-queries-stats" hx-swap-oob="true">`)
if totalErrorsCount > 0 {
buffer.Html(fmt.Sprintf(`%s class="debug-warn-log"">%d total (%d recent)</a></li>`, linkToMainView, totalErrorsCount, savedErrorsCount))
Expand Down

0 comments on commit 24f11f6

Please sign in to comment.