MCPcopy
hub / github.com/MikeChongCan/scylla / api_v1_stats

Function api_v1_stats

scylla/web/server.py:117–142  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

115
116@app.route('/api/v1/stats')
117async def api_v1_stats(request: Request):
118 median_query: ProxyIP = ProxyIP.raw("""SELECT latency
119 FROM proxy_ips
120 WHERE is_valid = 1
121 ORDER BY latency
122 LIMIT 1
123 OFFSET (
124 SELECT COUNT(*) FROM proxy_ips WHERE is_valid = 1
125 ) / 2""").get()
126 median = median_query.latency
127
128 mean_query: ProxyIP = ProxyIP.raw("""SELECT AVG(latency) as latency
129 FROM proxy_ips
130 WHERE is_valid = 1 AND latency < 9999""").get()
131 mean = mean_query.latency
132
133 valid_count = _get_valid_proxies_query().count()
134
135 total_count = ProxyIP.select().count()
136
137 return json({
138 'median': median,
139 'valid_count': valid_count,
140 'total_count': total_count,
141 'mean': mean,
142 })
143
144
145def start_web_server(host='0.0.0.0', port=8899):

Callers

nothing calls this directly

Calls 2

_get_valid_proxies_queryFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected