- 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.
134 lines
2.9 KiB
Go
134 lines
2.9 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: event_history.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const GetAllEventHistory = `-- name: GetAllEventHistory :many
|
|
SELECT id, event_id, status, created_at
|
|
FROM event_history
|
|
WHERE (
|
|
event_id = $1
|
|
OR $1 IS NULL
|
|
)
|
|
AND (
|
|
created_at > $2
|
|
OR $2 IS NULL
|
|
)
|
|
AND (
|
|
created_at < $3
|
|
OR $3 IS NULL
|
|
)
|
|
`
|
|
|
|
type GetAllEventHistoryParams struct {
|
|
EventID pgtype.Int8 `json:"event_id"`
|
|
CreatedBefore pgtype.Timestamp `json:"created_before"`
|
|
CreatedAfter pgtype.Timestamp `json:"created_after"`
|
|
}
|
|
|
|
func (q *Queries) GetAllEventHistory(ctx context.Context, arg GetAllEventHistoryParams) ([]EventHistory, error) {
|
|
rows, err := q.db.Query(ctx, GetAllEventHistory, arg.EventID, arg.CreatedBefore, arg.CreatedAfter)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []EventHistory
|
|
for rows.Next() {
|
|
var i EventHistory
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetInitialEventPerDay = `-- name: GetInitialEventPerDay :many
|
|
SELECT DISTINCT ON (DATE_TRUNC('day', created_at)) id, event_id, status, created_at
|
|
FROM event_history
|
|
WHERE (
|
|
event_id = $1
|
|
OR $1 IS NULL
|
|
)
|
|
AND (
|
|
created_at > $2
|
|
OR $2 IS NULL
|
|
)
|
|
AND (
|
|
created_at < $3
|
|
OR $3 IS NULL
|
|
)
|
|
ORDER BY DATE_TRUNC('day', created_at),
|
|
created_at ASC
|
|
`
|
|
|
|
type GetInitialEventPerDayParams struct {
|
|
EventID pgtype.Int8 `json:"event_id"`
|
|
CreatedBefore pgtype.Timestamp `json:"created_before"`
|
|
CreatedAfter pgtype.Timestamp `json:"created_after"`
|
|
}
|
|
|
|
func (q *Queries) GetInitialEventPerDay(ctx context.Context, arg GetInitialEventPerDayParams) ([]EventHistory, error) {
|
|
rows, err := q.db.Query(ctx, GetInitialEventPerDay, arg.EventID, arg.CreatedBefore, arg.CreatedAfter)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []EventHistory
|
|
for rows.Next() {
|
|
var i EventHistory
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const InsertEventHistory = `-- name: InsertEventHistory :one
|
|
INSERT INTO event_history (event_id, status)
|
|
VALUES ($1, $2)
|
|
RETURNING id, event_id, status, created_at
|
|
`
|
|
|
|
type InsertEventHistoryParams struct {
|
|
EventID int64 `json:"event_id"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
func (q *Queries) InsertEventHistory(ctx context.Context, arg InsertEventHistoryParams) (EventHistory, error) {
|
|
row := q.db.QueryRow(ctx, InsertEventHistory, arg.EventID, arg.Status)
|
|
var i EventHistory
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|