Skip to content

Commit

Permalink
More work
Browse files Browse the repository at this point in the history
  • Loading branch information
jakozaur committed May 2, 2024
1 parent 3ae654a commit 8687231
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
7 changes: 6 additions & 1 deletion quesma/quesma/ui/console_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,15 @@ func (qmc *QuesmaManagementConsole) createRouting() *mux.Router {
buf := qmc.generateErrorForReason(vars["reason"])
_, _ = writer.Write(buf)
})
router.PathPrefix("/unsupported-requests").HandlerFunc(func(writer http.ResponseWriter, r *http.Request) {
router.Path("/unsupported-requests").HandlerFunc(func(writer http.ResponseWriter, r *http.Request) {
buf := qmc.generateReportForUnsupportedRequests()
_, _ = writer.Write(buf)
})
router.PathPrefix("/unsupported-requests/{reason}").HandlerFunc(func(writer http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
buf := qmc.generateReportForUnsupportedType(vars["reason"])
_, _ = writer.Write(buf)
})
router.PathPrefix("/requests-by-str/{queryString}").HandlerFunc(func(writer http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
buf := qmc.generateReportForRequestsWithStr(vars["queryString"])
Expand Down
9 changes: 5 additions & 4 deletions quesma/quesma/ui/html_pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ func (qmc *QuesmaManagementConsole) generateReportForRequestsWithStr(requestStr
qmc.mutex.Unlock()

title := fmt.Sprintf("Report for str '%s' with %d results", requestStr, len(debugKeyValueSlice))
return qmc.generateReportForRequests(title, debugKeyValueSlice)
return qmc.generateReportForRequests(title, debugKeyValueSlice, []byte{})
}

func (qmc *QuesmaManagementConsole) generateReportForRequestsWithError() []byte {
Expand All @@ -874,7 +874,7 @@ func (qmc *QuesmaManagementConsole) generateReportForRequestsWithError() []byte
}
qmc.mutex.Unlock()

return qmc.generateReportForRequests("Report for requests with errors", debugKeyValueSlice)
return qmc.generateReportForRequests("Report for requests with errors", debugKeyValueSlice, []byte{})
}

func (qmc *QuesmaManagementConsole) generateReportForRequestsWithWarning() []byte {
Expand All @@ -890,10 +890,10 @@ func (qmc *QuesmaManagementConsole) generateReportForRequestsWithWarning() []byt
}
qmc.mutex.Unlock()

return qmc.generateReportForRequests("Report for requests with warnings", debugKeyValueSlice)
return qmc.generateReportForRequests("Report for requests with warnings", debugKeyValueSlice, []byte{})
}

func (qmc *QuesmaManagementConsole) generateReportForRequests(title string, requests []DebugKeyValue) []byte {
func (qmc *QuesmaManagementConsole) generateReportForRequests(title string, requests []DebugKeyValue, sidebar []byte) []byte {
buffer := newBufferWithHead()
buffer.Write(generateSimpleTop(title))

Expand All @@ -909,6 +909,7 @@ func (qmc *QuesmaManagementConsole) generateReportForRequests(title string, requ
buffer.Html("\n<h2>Menu</h2>")

buffer.Html(`<form action="/live">&nbsp;<input class="btn" type="submit" value="Back to live tail" /></form>`)
buffer.Write(sidebar)

buffer.Html("\n</div>")
buffer.Html("\n</body>")
Expand Down
15 changes: 8 additions & 7 deletions quesma/quesma/ui/unsupported_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (qmc *QuesmaManagementConsole) generateReportForUnsupportedRequests() []byt
}
qmc.mutex.Unlock()

return qmc.generateReportForRequests("Report for unsupported requests", debugKeyValueSlice)
return qmc.generateReportForRequests("Unsupported requests", debugKeyValueSlice, []byte{})
}

func (qmc *QuesmaManagementConsole) generateUnsupportedQuerySidePanel() []byte {
Expand All @@ -73,9 +73,9 @@ func (qmc *QuesmaManagementConsole) generateUnsupportedQuerySidePanel() []byte {
savedErrorsCount += count
}
typesSeenCount := len(typesCount)
unkownTypeCount := 0
unknownTypeCount := 0
if value, ok := typesCount[UnrecognizedQueryType]; ok {
unkownTypeCount = value
unknownTypeCount = value
}

var buffer HtmlBuffer
Expand All @@ -88,8 +88,9 @@ func (qmc *QuesmaManagementConsole) generateUnsupportedQuerySidePanel() []byte {
plural = ""
}
buffer.Html(fmt.Sprintf(`%s class="debug-warn-log"">%d different type%s</a></li>`, linkToMainView, typesSeenCount, plural))
if unkownTypeCount > 0 {
buffer.Html(fmt.Sprintf(`%s class="debug-error-log"">%d of unrecognized type</a></li>`, linkToMainView, unkownTypeCount))
if unknownTypeCount > 0 {
buffer.Html(fmt.Sprintf(`<li><a href="/unsupported-requests/%s"" class="debug-error-log">`, UnrecognizedQueryType))
buffer.Html(fmt.Sprintf(`%d of unrecognized type</a></li>`, unknownTypeCount))
}
} else {
buffer.Html(`<li>None!</a></li>`)
Expand Down Expand Up @@ -158,6 +159,6 @@ func (qmc *QuesmaManagementConsole) QueriesWithUnsupportedType(typeName string)
}

func (qmc *QuesmaManagementConsole) generateReportForUnsupportedType(typeName string) []byte {
debugKeyValueSlice := qmc.QueriesWithUnsupportedType(typeName)
return qmc.generateReportForRequests("Report for unsupported request '"+typeName+"'", debugKeyValueSlice)
requests := qmc.QueriesWithUnsupportedType(typeName)
return qmc.generateReportForRequests("Report for unsupported request '"+typeName+"'", requests, []byte{})
}

0 comments on commit 8687231

Please sign in to comment.