Skip to content

Commit

Permalink
Finished admin stats endpoint in graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
icellan committed May 2, 2022
1 parent b0888fe commit 7e3d0c0
Show file tree
Hide file tree
Showing 3 changed files with 418 additions and 47 deletions.
9 changes: 8 additions & 1 deletion graph/admin.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
# https://gqlgen.com/getting-started/

type AdminStats {
id: String
balance: Int64
destinations: Int64
transactions: Int64
paymails: Int64
utxos: Int64
xpubs: Int64
transactions_per_day: Map
utxos_per_type: Map
}

extend type Query {
Expand Down
13 changes: 1 addition & 12 deletions graph/admin.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ package graph

import (
"context"
"fmt"

"github.com/BuxOrg/bux"
"github.com/BuxOrg/bux-server/graph/generated"
"github.com/BuxOrg/bux/datastore"
)

func (r *adminStatsResolver) ID(ctx context.Context, obj *bux.AdminStats) (*string, error) {
panic(fmt.Errorf("not implemented"))
}

func (r *mutationResolver) AdminPaymailCreate(ctx context.Context, xpub string, address string, publicName *string, avatar *string, metadata bux.Metadata) (*bux.PaymailAddress, error) {
// including admin check
c, err := GetConfigFromContextAdmin(ctx)
Expand Down Expand Up @@ -84,7 +78,7 @@ func (r *queryResolver) AdminGetStats(ctx context.Context) (*bux.AdminStats, err
}

var accessKeys *bux.AdminStats
accessKeys, err = c.Services.Bux.GetStats(ctx, nil)
accessKeys, err = c.Services.Bux.GetStats(ctx, c.Services.Bux.DefaultModelOptions()...)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -374,8 +368,3 @@ func (r *queryResolver) AdminXpubsCount(ctx context.Context, metadata bux.Metada

return &count, nil
}

// AdminStats returns generated.AdminStatsResolver implementation.
func (r *Resolver) AdminStats() generated.AdminStatsResolver { return &adminStatsResolver{r} }

type adminStatsResolver struct{ *Resolver }
Loading

0 comments on commit 7e3d0c0

Please sign in to comment.