1 |
|
-module(mongoose_graphql_stats_global). |
2 |
|
-behaviour(mongoose_graphql). |
3 |
|
|
4 |
|
-export([execute/4]). |
5 |
|
|
6 |
|
-import(mongoose_graphql_helper, [make_error/2]). |
7 |
|
|
8 |
|
-ignore_xref([execute/4]). |
9 |
|
|
10 |
|
-include("../mongoose_graphql_types.hrl"). |
11 |
|
-include("mongoose.hrl"). |
12 |
|
-include("jlib.hrl"). |
13 |
|
|
14 |
|
execute(_Ctx, globalStats, <<"uptimeSeconds">>, _Args) -> |
15 |
:-( |
globalStats(<<"uptimeseconds">>); |
16 |
|
execute(_Ctx, globalStats, <<"registeredUsers">>, _Args) -> |
17 |
:-( |
globalStats(<<"registeredusers">>); |
18 |
|
execute(_Ctx, globalStats, <<"onlineUsersNode">>, _Args) -> |
19 |
:-( |
globalStats(<<"onlineusersnode">>); |
20 |
|
execute(_Ctx, globalStats, <<"onlineUsers">>, _Args) -> |
21 |
:-( |
globalStats(<<"onlineusers">>); |
22 |
|
execute(_Ctx, globalStats, <<"incomingS2S">>, _Args) -> |
23 |
:-( |
stats_api:incoming_s2s_number(); |
24 |
|
execute(_Ctx, globalStats, <<"outgoingS2S">>, _Args) -> |
25 |
:-( |
stats_api:outgoing_s2s_number(). |
26 |
|
|
27 |
|
globalStats(Name) -> |
28 |
:-( |
case stats_api:stats(Name) of |
29 |
:-( |
{ok, _} = Result -> Result; |
30 |
:-( |
Error -> make_error(Error, #{}) |
31 |
|
end. |