1 |
|
-module(mongoose_graphql_stats_domain). |
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, Domain, <<"registeredUsers">>, _Args) -> |
15 |
14 |
domainStats(<<"registeredusers">>, Domain); |
16 |
|
execute(_Ctx, Domain, <<"onlineUsers">>, _Args) -> |
17 |
14 |
domainStats(<<"onlineusers">>, Domain). |
18 |
|
|
19 |
|
domainStats(Name, Domain) -> |
20 |
28 |
case stats_api:stats(Name, Domain) of |
21 |
28 |
{ok, _} = Result -> Result; |
22 |
:-( |
Error -> make_error(Error, #{domain => Domain}) |
23 |
|
end. |