1
1
{% extends "base.html" %}
2
2
{% load static %}
3
+ {% load custom_tags %}
4
+ {% load humanize %}
3
5
{% block title %}
4
6
Service Status
5
7
{% endblock title %}
@@ -78,7 +80,7 @@ <h3 class="text-xl font-semibold mb-4">OpenAI API</h3>
78
80
<!-- GitHub API Status -->
79
81
< div class ="bg-white rounded-lg shadow-sm p-6 border border-[#e74c3c] ">
80
82
< h3 class ="text-xl font-semibold mb-4 "> GitHub API</ h3 >
81
- < div class ="flex items-center ">
83
+ < div class ="flex items-center mb-4 ">
82
84
< div class ="w-3 h-3 rounded-full mr-3 {% if status.github == None %}bg-gray-400{% elif status.github %}bg-green-500{% else %}bg-red-500{% endif %} ">
83
85
</ div >
84
86
{% if status.github == None %}
@@ -89,6 +91,97 @@ <h3 class="text-xl font-semibold mb-4">GitHub API</h3>
89
91
< span class ="text-red-600 "> Not Operational</ span >
90
92
{% endif %}
91
93
</ div >
94
+ {% if status.github_rate_limit %}
95
+ < div class ="mt-4 ">
96
+ < h4 class ="text-lg font-semibold mb-2 "> Rate Limits</ h4 >
97
+ <!-- Core Rate Limit -->
98
+ < div class ="mb-4 ">
99
+ < h5 class ="font-medium "> Core API</ h5 >
100
+ < div class ="grid grid-cols-2 gap-2 mt-2 ">
101
+ < div >
102
+ < span class ="text-gray-600 "> Remaining:</ span >
103
+ < span class ="font-medium ml-1 "> {{ status.github_rate_limit.core.remaining }} / {{ status.github_rate_limit.core.limit }}</ span >
104
+ </ div >
105
+ < div >
106
+ < span class ="text-gray-600 "> Used:</ span >
107
+ < span class ="font-medium ml-1 "> {{ status.github_rate_limit.core.used }}</ span >
108
+ </ div >
109
+ </ div >
110
+ <!-- Progress Bar -->
111
+ {% with remaining=status.github_rate_limit.core.remaining|default:0 limit=status.github_rate_limit.core.limit|default:1 %}
112
+ {% with percentage=remaining|div:limit|multiply:100|floatformat:0 %}
113
+ < div class ="w-full bg-gray-200 rounded-full h-2.5 mt-2 ">
114
+ < div class ="bg-[#e74c3c] h-2.5 rounded-full "
115
+ style ="width: {{ percentage }}% "> </ div >
116
+ </ div >
117
+ < div class ="text-xs text-gray-500 mt-1 ">
118
+ Reset in:
119
+ {% if status.github_rate_limit.core.reset %}
120
+ {% with reset_time=status.github_rate_limit.core.reset|timestamp_to_datetime %}{{ reset_time|timeuntil }}{% endwith %}
121
+ {% else %}
122
+ Unknown
123
+ {% endif %}
124
+ </ div >
125
+ {% endwith %}
126
+ {% endwith %}
127
+ </ div >
128
+ <!-- Search Rate Limit -->
129
+ < div class ="mb-4 ">
130
+ < h5 class ="font-medium "> Search API</ h5 >
131
+ < div class ="grid grid-cols-2 gap-2 mt-2 ">
132
+ < div >
133
+ < span class ="text-gray-600 "> Remaining:</ span >
134
+ < span class ="font-medium ml-1 "> {{ status.github_rate_limit.search.remaining }} / {{ status.github_rate_limit.search.limit }}</ span >
135
+ </ div >
136
+ < div >
137
+ < span class ="text-gray-600 "> Used:</ span >
138
+ < span class ="font-medium ml-1 "> {{ status.github_rate_limit.search.used }}</ span >
139
+ </ div >
140
+ </ div >
141
+ <!-- Progress Bar -->
142
+ {% with remaining=status.github_rate_limit.search.remaining|default:0 limit=status.github_rate_limit.search.limit|default:1 %}
143
+ {% with percentage=remaining|div:limit|multiply:100|floatformat:0 %}
144
+ < div class ="w-full bg-gray-200 rounded-full h-2.5 mt-2 ">
145
+ < div class ="bg-[#e74c3c] h-2.5 rounded-full "
146
+ style ="width: {{ percentage }}% "> </ div >
147
+ </ div >
148
+ {% endwith %}
149
+ {% endwith %}
150
+ </ div >
151
+ <!-- GraphQL Rate Limit -->
152
+ < div >
153
+ < h5 class ="font-medium "> GraphQL API</ h5 >
154
+ < div class ="grid grid-cols-2 gap-2 mt-2 ">
155
+ < div >
156
+ < span class ="text-gray-600 "> Remaining:</ span >
157
+ < span class ="font-medium ml-1 "> {{ status.github_rate_limit.graphql.remaining }} / {{ status.github_rate_limit.graphql.limit }}</ span >
158
+ </ div >
159
+ < div >
160
+ < span class ="text-gray-600 "> Used:</ span >
161
+ < span class ="font-medium ml-1 "> {{ status.github_rate_limit.graphql.used }}</ span >
162
+ </ div >
163
+ </ div >
164
+ <!-- Progress Bar -->
165
+ {% with remaining=status.github_rate_limit.graphql.remaining|default:0 limit=status.github_rate_limit.graphql.limit|default:1 %}
166
+ {% with percentage=remaining|div:limit|multiply:100|floatformat:0 %}
167
+ < div class ="w-full bg-gray-200 rounded-full h-2.5 mt-2 ">
168
+ < div class ="bg-[#e74c3c] h-2.5 rounded-full "
169
+ style ="width: {{ percentage }}% "> </ div >
170
+ </ div >
171
+ {% endwith %}
172
+ {% endwith %}
173
+ </ div >
174
+ </ div >
175
+ <!-- API Usage History -->
176
+ {% if status.github_api_history %}
177
+ < div class ="mt-6 ">
178
+ < h4 class ="text-lg font-semibold mb-2 "> API Usage History</ h4 >
179
+ < div class ="w-full h-64 ">
180
+ < canvas id ="githubApiChart "> </ canvas >
181
+ </ div >
182
+ </ div >
183
+ {% endif %}
184
+ {% endif %}
92
185
</ div >
93
186
<!-- Top Memory Consumers -->
94
187
< div class ="bg-white rounded-lg shadow-sm p-6 border border-[#e74c3c] ">
@@ -249,36 +342,91 @@ <h4 class="text-lg font-semibold mb-4">Recent Activities</h4>
249
342
responsive : true ,
250
343
maintainAspectRatio : false ,
251
344
scales : {
252
- x : {
253
- stacked : false ,
254
- title : {
255
- display : true ,
256
- text : 'Date'
257
- }
258
- } ,
259
345
y : {
260
- stacked : false ,
261
- beginAtZero : true ,
262
- title : {
263
- display : true ,
264
- text : 'Number of Activities'
265
- }
266
- }
267
- } ,
268
- plugins : {
269
- title : {
270
- display : true ,
271
- text : 'Slack Bot Activities (Last 30 Days)' ,
272
- font : {
273
- size : 16
274
- }
275
- } ,
276
- legend : {
277
- position : 'bottom'
346
+ beginAtZero : true
278
347
}
279
348
}
280
349
}
281
350
} ) ;
351
+
352
+ // GitHub API Usage History Chart
353
+ const githubApiChartElement = document . getElementById ( 'githubApiChart' ) ;
354
+ if ( githubApiChartElement ) {
355
+ let githubApiHistory = [ ] ;
356
+ try {
357
+ githubApiHistory = JSON . parse ( '{{ status.github_api_history|escapejs|default:"[]" }}' ) ;
358
+ } catch ( e ) {
359
+ console . error ( 'Error parsing GitHub API history:' , e ) ;
360
+ }
361
+
362
+ if ( githubApiHistory && githubApiHistory . length > 0 ) {
363
+ // Format the data for the chart
364
+ const timestamps = githubApiHistory . map ( entry => entry . timestamp ) ;
365
+ const remaining = githubApiHistory . map ( entry => parseInt ( entry . remaining ) || 0 ) ;
366
+ const used = githubApiHistory . map ( entry => parseInt ( entry . used ) || 0 ) ;
367
+
368
+ new Chart ( githubApiChartElement , {
369
+ type : 'line' ,
370
+ data : {
371
+ labels : timestamps ,
372
+ datasets : [
373
+ {
374
+ label : 'Remaining' ,
375
+ data : remaining ,
376
+ backgroundColor : 'rgba(231, 76, 60, 0.2)' ,
377
+ borderColor : '#e74c3c' ,
378
+ borderWidth : 2 ,
379
+ tension : 0.1 ,
380
+ fill : true
381
+ } ,
382
+ {
383
+ label : 'Used' ,
384
+ data : used ,
385
+ backgroundColor : 'rgba(52, 152, 219, 0.2)' ,
386
+ borderColor : '#3498db' ,
387
+ borderWidth : 2 ,
388
+ tension : 0.1 ,
389
+ fill : true
390
+ }
391
+ ]
392
+ } ,
393
+ options : {
394
+ responsive : true ,
395
+ maintainAspectRatio : false ,
396
+ scales : {
397
+ y : {
398
+ beginAtZero : true ,
399
+ title : {
400
+ display : true ,
401
+ text : 'API Calls'
402
+ }
403
+ } ,
404
+ x : {
405
+ title : {
406
+ display : true ,
407
+ text : 'Time'
408
+ }
409
+ }
410
+ } ,
411
+ plugins : {
412
+ title : {
413
+ display : true ,
414
+ text : 'GitHub API Usage History'
415
+ } ,
416
+ tooltip : {
417
+ callbacks : {
418
+ label : function ( context ) {
419
+ const label = context . dataset . label || '' ;
420
+ const value = context . parsed . y ;
421
+ return `${ label } : ${ value } ` ;
422
+ }
423
+ }
424
+ }
425
+ }
426
+ }
427
+ } ) ;
428
+ }
429
+ }
282
430
} ) ;
283
431
</ script >
284
- {% endblock %}
432
+ {% endblock extra_js %}
0 commit comments