Skip to content

Commit

Permalink
auto: autocommit
Browse files Browse the repository at this point in the history
  • Loading branch information
pibragimov committed May 2, 2024
1 parent 0925cdd commit eb6745f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,3 @@
Telegram client utils for making telegram more fun!


### TODO
- [ ] Clickhouse
- [ ] Full ru localization
- [ ] Refactor mongo repository
- [ ] Save kandinsky images
- [ ] Precommit hooks
- [ ] Better golint
- [ ] Docker-build from github actions
- [ ] Revork errors to go-fast-errors
- [ ] Add https://github.com/dominikbraun/graph
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.11.58
v1.11.59
35 changes: 34 additions & 1 deletion core/repository/mongo_repository/member_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,40 @@ func (r *Repository) GetUsersInChat(ctx context.Context, chatId int64) (UsersInC
"tg_username": "$user.tg_username",
"tg_name": "$user.tg_name",
"is_bot": "$user.is_bot",
// "tg_chat_id": 1,
},
},
)
if err != nil {
return nil, errors.WithStack(err)
}

return usersInChat, nil
}

func (r *Repository) GetUsersInChatOnlyActive(
ctx context.Context,
chatId int64,
) (UsersInChat, error) {
usersInChat := make(UsersInChat, 0, 100)

err := r.memberCollection.SimpleAggregateWithCtx(
ctx,
&usersInChat,
builder.Lookup(r.userCollection.Name(), "tg_user_id", "tg_id", "user"),
bson.M{operator.Match: bson.M{"tg_chat_id": chatId}},
bson.M{operator.Unwind: "$user"},
bson.M{
operator.Project: bson.M{
"status": 1,
"tg_id": "$user.tg_id",
"tg_username": "$user.tg_username",
"tg_name": "$user.tg_name",
"is_bot": "$user.is_bot",
},
},
bson.M{
operator.Match: bson.M{
"status": bson.M{operator.In: []MemberStatus{Plain, Creator, Admin}},
},
},
)
Expand Down
4 changes: 2 additions & 2 deletions core/service/analitics/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (r *Service) analiseUserChat(
return AnaliseReport{}, nil
}

usersInChat, err := r.mongoRepository.GetUsersInChat(ctx, input.TgChatId)
usersInChat, err := r.mongoRepository.GetUsersInChatOnlyActive(ctx, input.TgChatId)
if err != nil {
return AnaliseReport{}, errors.Wrap(
err,
Expand Down Expand Up @@ -236,7 +236,7 @@ func (r *Service) analiseWholeChat(
ctx context.Context,
input *AnaliseChatInput,
) (AnaliseReport, error) {
usersInChat, err := r.mongoRepository.GetUsersInChat(ctx, input.TgChatId)
usersInChat, err := r.mongoRepository.GetUsersInChatOnlyActive(ctx, input.TgChatId)
if err != nil {
return AnaliseReport{}, errors.Wrap(
err,
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
fun_storage__mongo_db_url: "mongodb://mongodb:27017"
fun_storage__clickhouse_url: "clickhouse:9000"
fun_ds_supplier_url: "http://ds:8000"
image: ghcr.io/teadove/fun-telegram:v1.11.58
image: ghcr.io/teadove/fun-telegram:v1.11.59
volumes:
- ".mtproto:/.mtproto"
- ".env:/.env"
Expand Down

0 comments on commit eb6745f

Please sign in to comment.