-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* readme Signed-off-by: hanzhixiao <[email protected]> * rebase Signed-off-by: hanzhixiao <[email protected]> * statistic api Signed-off-by: hanzhixiao <[email protected]> --------- Signed-off-by: hanzhixiao <[email protected]>
- Loading branch information
1 parent
267dd86
commit 9158897
Showing
11 changed files
with
765 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package chat | ||
|
||
import ( | ||
"context" | ||
"github.com/OpenIMSDK/chat/pkg/proto/chat" | ||
"github.com/OpenIMSDK/tools/errs" | ||
"time" | ||
) | ||
|
||
func (o *chatSvr) NewUserCount(ctx context.Context, req *chat.NewUserCountReq) (*chat.NewUserCountResp, error) { | ||
resp := &chat.NewUserCountResp{} | ||
if req.Start > req.End { | ||
return nil, errs.ErrArgs.Wrap("start > end") | ||
} | ||
total, err := o.Database.NewUserCountTotal(ctx, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
start := time.UnixMilli(req.Start) | ||
before, err := o.Database.NewUserCountTotal(ctx, &start) | ||
if err != nil { | ||
return nil, err | ||
} | ||
end := time.UnixMilli(req.End) | ||
count, err := o.Database.NewUserCountRangeEverydayTotal(ctx, &start, &end) | ||
if err != nil { | ||
return nil, err | ||
} | ||
resp.Total = total | ||
resp.Before = before | ||
resp.Count = count | ||
return resp, nil | ||
} | ||
func (o *chatSvr) UserLoginCount(ctx context.Context, req *chat.UserLoginCountReq) (*chat.UserLoginCountResp, error) { | ||
resp := &chat.UserLoginCountResp{} | ||
if req.Start > req.End { | ||
return nil, errs.ErrArgs.Wrap("start > end") | ||
} | ||
total, err := o.Database.UserLoginCountTotal(ctx, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
start := time.UnixMilli(req.Start) | ||
before, err := o.Database.UserLoginCountTotal(ctx, &start) | ||
if err != nil { | ||
return nil, err | ||
} | ||
end := time.UnixMilli(req.End) | ||
count, err := o.Database.UserLoginCountRangeEverydayTotal(ctx, &start, &end) | ||
if err != nil { | ||
return nil, err | ||
} | ||
resp.Total = total | ||
resp.Before = before | ||
resp.Count = count | ||
return resp, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.