- Added new notification handling in the wallet service to notify admins when wallet balances are low or insufficient. - Created a new file for wallet notifications and moved relevant functions from the wallet service to this new file. - Updated the wallet service to publish wallet events including wallet type. - Refactored the client code to improve readability and maintainability. - Enhanced the bet handler to support pagination and status filtering for bets. - Updated routes and handlers for user search functionality to improve clarity and organization. - Modified cron job scheduling to comment out unused jobs for clarity. - Updated the WebSocket broadcast to include wallet type in notifications. - Adjusted the makefile to include Kafka in the docker-compose setup for local development.
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db"
|
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
func (s *Store) CreateResultLog(ctx context.Context, result domain.CreateResultLog) (domain.ResultLog, error) {
|
|
dbResult, err := s.queries.CreateResultLog(ctx, domain.ConvertCreateResultLog(result))
|
|
if err != nil {
|
|
return domain.ResultLog{}, err
|
|
}
|
|
return domain.ConvertDBResultLog(dbResult), nil
|
|
}
|
|
|
|
func (s *Store) GetAllResultLog(ctx context.Context, filter domain.ResultLogFilter) ([]domain.ResultLog, error) {
|
|
dbResultLogs, err := s.queries.GetAllResultLog(ctx, dbgen.GetAllResultLogParams{
|
|
CreatedBefore: pgtype.Timestamp{
|
|
Time: filter.CreatedBefore.Value,
|
|
Valid: filter.CreatedBefore.Valid,
|
|
},
|
|
CreatedAfter: pgtype.Timestamp{
|
|
Time: filter.CreatedAfter.Value,
|
|
Valid: filter.CreatedAfter.Valid,
|
|
},
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
result := make([]domain.ResultLog, 0, len(dbResultLogs))
|
|
for _, dbResultLog := range dbResultLogs {
|
|
result = append(result, domain.ConvertDBResultLog(dbResultLog))
|
|
}
|
|
return result, nil
|
|
}
|