File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -41,11 +41,19 @@ export const scoreHandler = async (ctx: Context, botState: BotState) => {
4141 "🔴 — высокая нагрузка\n\n" ;
4242
4343 const formatted = scores
44- . filter ( ( s ) => s . score !== null )
45- . sort ( ( a , b ) => b . score ! - a . score ! )
44+ . sort ( ( a , b ) => {
45+ if ( a . score === null ) return 1 ;
46+ if ( b . score === null ) return - 1 ;
47+ return b . score - a . score ;
48+ } )
4649 . map ( ( s ) => {
47- const score = s . score ! ;
50+ if ( s . score === null ) {
51+ return `🔴 <b>Offline - ${ s . hostname } </b> (${ s . env } )\n⛔ Нода недоступна\n` ;
52+ }
53+
54+ const score = s . score ;
4855 const emoji = score < 0.4 ? "🟢" : score < 0.75 ? "🟡" : "🔴" ;
56+
4957 if ( s . details ) {
5058 const bandwidthCurrentMbps = (
5159 s . details . bandwidth / 1_000_000
@@ -54,9 +62,9 @@ export const scoreHandler = async (ctx: Context, botState: BotState) => {
5462 1 ,
5563 ) ;
5664
57- return `${ emoji } <b>${ s . status } - ${ s . hostname } </b> (${ s . env } ) \n Используется : ${ bandwidthCurrentMbps } /${ bandwidthMaxMbps } Mbps \n Нагрузка : ${ ( score * 100 ) . toFixed ( 1 ) } / 100%\n` ;
65+ return `${ emoji } <b>${ s . status } - ${ s . label } </b> (${ s . env } ) \nИспользуется : ${ bandwidthCurrentMbps } /${ bandwidthMaxMbps } Mbps \nНагрузка : ${ ( score * 100 ) . toFixed ( 1 ) } / 100%\n` ;
5866 } else {
59- return `${ emoji } <b>${ s . status } - ${ s . hostname } </b> (${ s . env } ) \n Нагрузка : ${ ( score * 100 ) . toFixed ( 1 ) } / 100% \n Данные по полосе отсутствуют` ;
67+ return `${ emoji } <b>${ s . status } - ${ s . label } </b> (${ s . env } ) \nНагрузка : ${ ( score * 100 ) . toFixed ( 1 ) } / 100% \nДанные по полосе отсутствуют` ;
6068 }
6169 } )
6270 . join ( "\n" ) ;
You can’t perform that action at this time.
0 commit comments