// Code generated by qtc from "stats_query_response.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.

// StatsQueryResponse generates response for /select/logsql/stats_query

//line app/vlselect/logsql/stats_query_response.qtpl:4
package logsql

//line app/vlselect/logsql/stats_query_response.qtpl:4
import (
	qtio422016 "io"

	qt422016 "github.com/valyala/quicktemplate"
)

//line app/vlselect/logsql/stats_query_response.qtpl:4
var (
	_ = qtio422016.Copy
	_ = qt422016.AcquireByteBuffer
)

//line app/vlselect/logsql/stats_query_response.qtpl:4
func StreamStatsQueryResponse(qw422016 *qt422016.Writer, rows []statsRow) {
//line app/vlselect/logsql/stats_query_response.qtpl:4
	qw422016.N().S(`{"status":"success","data":{"resultType":"vector","result":[`)
//line app/vlselect/logsql/stats_query_response.qtpl:10
	if len(rows) > 0 {
//line app/vlselect/logsql/stats_query_response.qtpl:11
		streamformatStatsRow(qw422016, &rows[0])
//line app/vlselect/logsql/stats_query_response.qtpl:12
		rows = rows[1:]

//line app/vlselect/logsql/stats_query_response.qtpl:13
		for i := range rows {
//line app/vlselect/logsql/stats_query_response.qtpl:13
			qw422016.N().S(`,`)
//line app/vlselect/logsql/stats_query_response.qtpl:14
			streamformatStatsRow(qw422016, &rows[i])
//line app/vlselect/logsql/stats_query_response.qtpl:15
		}
//line app/vlselect/logsql/stats_query_response.qtpl:16
	}
//line app/vlselect/logsql/stats_query_response.qtpl:16
	qw422016.N().S(`]}}`)
//line app/vlselect/logsql/stats_query_response.qtpl:20
}

//line app/vlselect/logsql/stats_query_response.qtpl:20
func WriteStatsQueryResponse(qq422016 qtio422016.Writer, rows []statsRow) {
//line app/vlselect/logsql/stats_query_response.qtpl:20
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vlselect/logsql/stats_query_response.qtpl:20
	StreamStatsQueryResponse(qw422016, rows)
//line app/vlselect/logsql/stats_query_response.qtpl:20
	qt422016.ReleaseWriter(qw422016)
//line app/vlselect/logsql/stats_query_response.qtpl:20
}

//line app/vlselect/logsql/stats_query_response.qtpl:20
func StatsQueryResponse(rows []statsRow) string {
//line app/vlselect/logsql/stats_query_response.qtpl:20
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vlselect/logsql/stats_query_response.qtpl:20
	WriteStatsQueryResponse(qb422016, rows)
//line app/vlselect/logsql/stats_query_response.qtpl:20
	qs422016 := string(qb422016.B)
//line app/vlselect/logsql/stats_query_response.qtpl:20
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vlselect/logsql/stats_query_response.qtpl:20
	return qs422016
//line app/vlselect/logsql/stats_query_response.qtpl:20
}

//line app/vlselect/logsql/stats_query_response.qtpl:22
func streamformatStatsRow(qw422016 *qt422016.Writer, r *statsRow) {
//line app/vlselect/logsql/stats_query_response.qtpl:22
	qw422016.N().S(`{"metric":{"__name__":`)
//line app/vlselect/logsql/stats_query_response.qtpl:25
	qw422016.N().Q(r.Name)
//line app/vlselect/logsql/stats_query_response.qtpl:26
	if len(r.Labels) > 0 {
//line app/vlselect/logsql/stats_query_response.qtpl:27
		for _, label := range r.Labels {
//line app/vlselect/logsql/stats_query_response.qtpl:27
			qw422016.N().S(`,`)
//line app/vlselect/logsql/stats_query_response.qtpl:28
			qw422016.N().Q(label.Name)
//line app/vlselect/logsql/stats_query_response.qtpl:28
			qw422016.N().S(`:`)
//line app/vlselect/logsql/stats_query_response.qtpl:28
			qw422016.N().Q(label.Value)
//line app/vlselect/logsql/stats_query_response.qtpl:29
		}
//line app/vlselect/logsql/stats_query_response.qtpl:30
	}
//line app/vlselect/logsql/stats_query_response.qtpl:30
	qw422016.N().S(`},"value":[`)
//line app/vlselect/logsql/stats_query_response.qtpl:32
	qw422016.N().F(float64(r.Timestamp) / 1e9)
//line app/vlselect/logsql/stats_query_response.qtpl:32
	qw422016.N().S(`,`)
//line app/vlselect/logsql/stats_query_response.qtpl:32
	qw422016.N().Q(r.Value)
//line app/vlselect/logsql/stats_query_response.qtpl:32
	qw422016.N().S(`]}`)
//line app/vlselect/logsql/stats_query_response.qtpl:34
}

//line app/vlselect/logsql/stats_query_response.qtpl:34
func writeformatStatsRow(qq422016 qtio422016.Writer, r *statsRow) {
//line app/vlselect/logsql/stats_query_response.qtpl:34
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vlselect/logsql/stats_query_response.qtpl:34
	streamformatStatsRow(qw422016, r)
//line app/vlselect/logsql/stats_query_response.qtpl:34
	qt422016.ReleaseWriter(qw422016)
//line app/vlselect/logsql/stats_query_response.qtpl:34
}

//line app/vlselect/logsql/stats_query_response.qtpl:34
func formatStatsRow(r *statsRow) string {
//line app/vlselect/logsql/stats_query_response.qtpl:34
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vlselect/logsql/stats_query_response.qtpl:34
	writeformatStatsRow(qb422016, r)
//line app/vlselect/logsql/stats_query_response.qtpl:34
	qs422016 := string(qb422016.B)
//line app/vlselect/logsql/stats_query_response.qtpl:34
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vlselect/logsql/stats_query_response.qtpl:34
	return qs422016
//line app/vlselect/logsql/stats_query_response.qtpl:34
}
