Yimaru-BackEnd/gen/db/virtual_report.sql.go

722 lines
20 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: virtual_report.sql
package dbgen
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const CreateCompanyReport = `-- name: CreateCompanyReport :one
INSERT INTO virtual_game_company_reports (
company_id, provider_id,
report_date, report_type,
total_bet_amount, total_win_amount, created_at
)
VALUES ($1, $2, $3, $4, $5, $6, NOW())
RETURNING id, company_id, provider_id, report_date, report_type, total_bet_amount, total_win_amount, net_profit, profit_margin, created_at, updated_at
`
type CreateCompanyReportParams struct {
CompanyID int64 `json:"company_id"`
ProviderID string `json:"provider_id"`
ReportDate pgtype.Date `json:"report_date"`
ReportType string `json:"report_type"`
TotalBetAmount pgtype.Numeric `json:"total_bet_amount"`
TotalWinAmount pgtype.Numeric `json:"total_win_amount"`
}
func (q *Queries) CreateCompanyReport(ctx context.Context, arg CreateCompanyReportParams) (VirtualGameCompanyReport, error) {
row := q.db.QueryRow(ctx, CreateCompanyReport,
arg.CompanyID,
arg.ProviderID,
arg.ReportDate,
arg.ReportType,
arg.TotalBetAmount,
arg.TotalWinAmount,
)
var i VirtualGameCompanyReport
err := row.Scan(
&i.ID,
&i.CompanyID,
&i.ProviderID,
&i.ReportDate,
&i.ReportType,
&i.TotalBetAmount,
&i.TotalWinAmount,
&i.NetProfit,
&i.ProfitMargin,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const CreateFinancialReport = `-- name: CreateFinancialReport :one
INSERT INTO virtual_game_financial_reports (
game_id, provider_id, report_date, report_type,
total_bets, total_wins, created_at
) VALUES ($1, $2, $3, $4, $5, $6, NOW())
RETURNING id, game_id, provider_id, report_date, report_type, total_bets, total_wins, ggr, rtp, created_at, updated_at
`
type CreateFinancialReportParams struct {
GameID string `json:"game_id"`
ProviderID string `json:"provider_id"`
ReportDate pgtype.Date `json:"report_date"`
ReportType string `json:"report_type"`
TotalBets pgtype.Numeric `json:"total_bets"`
TotalWins pgtype.Numeric `json:"total_wins"`
}
func (q *Queries) CreateFinancialReport(ctx context.Context, arg CreateFinancialReportParams) (VirtualGameFinancialReport, error) {
row := q.db.QueryRow(ctx, CreateFinancialReport,
arg.GameID,
arg.ProviderID,
arg.ReportDate,
arg.ReportType,
arg.TotalBets,
arg.TotalWins,
)
var i VirtualGameFinancialReport
err := row.Scan(
&i.ID,
&i.GameID,
&i.ProviderID,
&i.ReportDate,
&i.ReportType,
&i.TotalBets,
&i.TotalWins,
&i.Ggr,
&i.Rtp,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const CreatePlayerActivityReport = `-- name: CreatePlayerActivityReport :one
INSERT INTO virtual_game_player_activity_reports (
user_id, report_date, report_type,
total_deposits, total_withdrawals,
total_bet_amount, total_win_amount,
rounds_played, created_at
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, NOW())
RETURNING id, user_id, report_date, report_type, total_deposits, total_withdrawals, net_contribution, total_bet_amount, total_win_amount, net_result, rounds_played, avg_bet_size, created_at, updated_at
`
type CreatePlayerActivityReportParams struct {
UserID int64 `json:"user_id"`
ReportDate pgtype.Date `json:"report_date"`
ReportType string `json:"report_type"`
TotalDeposits pgtype.Numeric `json:"total_deposits"`
TotalWithdrawals pgtype.Numeric `json:"total_withdrawals"`
TotalBetAmount pgtype.Numeric `json:"total_bet_amount"`
TotalWinAmount pgtype.Numeric `json:"total_win_amount"`
RoundsPlayed pgtype.Int8 `json:"rounds_played"`
}
func (q *Queries) CreatePlayerActivityReport(ctx context.Context, arg CreatePlayerActivityReportParams) (VirtualGamePlayerActivityReport, error) {
row := q.db.QueryRow(ctx, CreatePlayerActivityReport,
arg.UserID,
arg.ReportDate,
arg.ReportType,
arg.TotalDeposits,
arg.TotalWithdrawals,
arg.TotalBetAmount,
arg.TotalWinAmount,
arg.RoundsPlayed,
)
var i VirtualGamePlayerActivityReport
err := row.Scan(
&i.ID,
&i.UserID,
&i.ReportDate,
&i.ReportType,
&i.TotalDeposits,
&i.TotalWithdrawals,
&i.NetContribution,
&i.TotalBetAmount,
&i.TotalWinAmount,
&i.NetResult,
&i.RoundsPlayed,
&i.AvgBetSize,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const DeleteFinancialReport = `-- name: DeleteFinancialReport :exec
DELETE FROM virtual_game_financial_reports
WHERE id = $1
`
func (q *Queries) DeleteFinancialReport(ctx context.Context, id int64) error {
_, err := q.db.Exec(ctx, DeleteFinancialReport, id)
return err
}
const DeletePlayerActivityReport = `-- name: DeletePlayerActivityReport :exec
DELETE FROM virtual_game_player_activity_reports
WHERE id = $1
`
func (q *Queries) DeletePlayerActivityReport(ctx context.Context, id int64) error {
_, err := q.db.Exec(ctx, DeletePlayerActivityReport, id)
return err
}
const GetCompanyProfitTrend = `-- name: GetCompanyProfitTrend :many
SELECT report_date, SUM(net_profit) AS total_profit
FROM virtual_game_company_reports
WHERE company_id = $1
AND provider_id = $2
AND report_date BETWEEN $3 AND $4
GROUP BY report_date
ORDER BY report_date
`
type GetCompanyProfitTrendParams struct {
CompanyID int64 `json:"company_id"`
ProviderID string `json:"provider_id"`
ReportDate pgtype.Date `json:"report_date"`
ReportDate_2 pgtype.Date `json:"report_date_2"`
}
type GetCompanyProfitTrendRow struct {
ReportDate pgtype.Date `json:"report_date"`
TotalProfit int64 `json:"total_profit"`
}
func (q *Queries) GetCompanyProfitTrend(ctx context.Context, arg GetCompanyProfitTrendParams) ([]GetCompanyProfitTrendRow, error) {
rows, err := q.db.Query(ctx, GetCompanyProfitTrend,
arg.CompanyID,
arg.ProviderID,
arg.ReportDate,
arg.ReportDate_2,
)
if err != nil {
return nil, err
}
defer rows.Close()
var items []GetCompanyProfitTrendRow
for rows.Next() {
var i GetCompanyProfitTrendRow
if err := rows.Scan(&i.ReportDate, &i.TotalProfit); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const GetCompanyReportByID = `-- name: GetCompanyReportByID :one
SELECT id, company_id, provider_id, report_date, report_type, total_bet_amount, total_win_amount, net_profit, profit_margin, created_at, updated_at FROM virtual_game_company_reports
WHERE id = $1
`
func (q *Queries) GetCompanyReportByID(ctx context.Context, id int64) (VirtualGameCompanyReport, error) {
row := q.db.QueryRow(ctx, GetCompanyReportByID, id)
var i VirtualGameCompanyReport
err := row.Scan(
&i.ID,
&i.CompanyID,
&i.ProviderID,
&i.ReportDate,
&i.ReportType,
&i.TotalBetAmount,
&i.TotalWinAmount,
&i.NetProfit,
&i.ProfitMargin,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const GetCompanyReportsInRange = `-- name: GetCompanyReportsInRange :many
SELECT id, company_id, provider_id, report_date, report_type, total_bet_amount, total_win_amount, net_profit, profit_margin, created_at, updated_at FROM virtual_game_company_reports
WHERE company_id = $1
AND provider_id = $2
AND report_date BETWEEN $3 AND $4
ORDER BY report_date
`
type GetCompanyReportsInRangeParams struct {
CompanyID int64 `json:"company_id"`
ProviderID string `json:"provider_id"`
ReportDate pgtype.Date `json:"report_date"`
ReportDate_2 pgtype.Date `json:"report_date_2"`
}
func (q *Queries) GetCompanyReportsInRange(ctx context.Context, arg GetCompanyReportsInRangeParams) ([]VirtualGameCompanyReport, error) {
rows, err := q.db.Query(ctx, GetCompanyReportsInRange,
arg.CompanyID,
arg.ProviderID,
arg.ReportDate,
arg.ReportDate_2,
)
if err != nil {
return nil, err
}
defer rows.Close()
var items []VirtualGameCompanyReport
for rows.Next() {
var i VirtualGameCompanyReport
if err := rows.Scan(
&i.ID,
&i.CompanyID,
&i.ProviderID,
&i.ReportDate,
&i.ReportType,
&i.TotalBetAmount,
&i.TotalWinAmount,
&i.NetProfit,
&i.ProfitMargin,
&i.CreatedAt,
&i.UpdatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const GetDailyFinancialReports = `-- name: GetDailyFinancialReports :many
SELECT id, game_id, provider_id, report_date, report_type, total_bets, total_wins, ggr, rtp, created_at, updated_at FROM virtual_game_financial_reports
WHERE report_date = $1
AND report_type = 'daily'
`
func (q *Queries) GetDailyFinancialReports(ctx context.Context, reportDate pgtype.Date) ([]VirtualGameFinancialReport, error) {
rows, err := q.db.Query(ctx, GetDailyFinancialReports, reportDate)
if err != nil {
return nil, err
}
defer rows.Close()
var items []VirtualGameFinancialReport
for rows.Next() {
var i VirtualGameFinancialReport
if err := rows.Scan(
&i.ID,
&i.GameID,
&i.ProviderID,
&i.ReportDate,
&i.ReportType,
&i.TotalBets,
&i.TotalWins,
&i.Ggr,
&i.Rtp,
&i.CreatedAt,
&i.UpdatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const GetFinancialReportByID = `-- name: GetFinancialReportByID :one
SELECT id, game_id, provider_id, report_date, report_type, total_bets, total_wins, ggr, rtp, created_at, updated_at FROM virtual_game_financial_reports
WHERE id = $1
`
func (q *Queries) GetFinancialReportByID(ctx context.Context, id int64) (VirtualGameFinancialReport, error) {
row := q.db.QueryRow(ctx, GetFinancialReportByID, id)
var i VirtualGameFinancialReport
err := row.Scan(
&i.ID,
&i.GameID,
&i.ProviderID,
&i.ReportDate,
&i.ReportType,
&i.TotalBets,
&i.TotalWins,
&i.Ggr,
&i.Rtp,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const GetFinancialReportsForGame = `-- name: GetFinancialReportsForGame :many
SELECT id, game_id, provider_id, report_date, report_type, total_bets, total_wins, ggr, rtp, created_at, updated_at FROM virtual_game_financial_reports
WHERE game_id = $1
AND provider_id = $2
AND report_date BETWEEN $3 AND $4
ORDER BY report_date
`
type GetFinancialReportsForGameParams struct {
GameID string `json:"game_id"`
ProviderID string `json:"provider_id"`
ReportDate pgtype.Date `json:"report_date"`
ReportDate_2 pgtype.Date `json:"report_date_2"`
}
func (q *Queries) GetFinancialReportsForGame(ctx context.Context, arg GetFinancialReportsForGameParams) ([]VirtualGameFinancialReport, error) {
rows, err := q.db.Query(ctx, GetFinancialReportsForGame,
arg.GameID,
arg.ProviderID,
arg.ReportDate,
arg.ReportDate_2,
)
if err != nil {
return nil, err
}
defer rows.Close()
var items []VirtualGameFinancialReport
for rows.Next() {
var i VirtualGameFinancialReport
if err := rows.Scan(
&i.ID,
&i.GameID,
&i.ProviderID,
&i.ReportDate,
&i.ReportType,
&i.TotalBets,
&i.TotalWins,
&i.Ggr,
&i.Rtp,
&i.CreatedAt,
&i.UpdatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const GetPlayerActivityByDate = `-- name: GetPlayerActivityByDate :one
SELECT id, user_id, report_date, report_type, total_deposits, total_withdrawals, net_contribution, total_bet_amount, total_win_amount, net_result, rounds_played, avg_bet_size, created_at, updated_at FROM virtual_game_player_activity_reports
WHERE user_id = $1
AND report_date = $2
AND report_type = $3
`
type GetPlayerActivityByDateParams struct {
UserID int64 `json:"user_id"`
ReportDate pgtype.Date `json:"report_date"`
ReportType string `json:"report_type"`
}
func (q *Queries) GetPlayerActivityByDate(ctx context.Context, arg GetPlayerActivityByDateParams) (VirtualGamePlayerActivityReport, error) {
row := q.db.QueryRow(ctx, GetPlayerActivityByDate, arg.UserID, arg.ReportDate, arg.ReportType)
var i VirtualGamePlayerActivityReport
err := row.Scan(
&i.ID,
&i.UserID,
&i.ReportDate,
&i.ReportType,
&i.TotalDeposits,
&i.TotalWithdrawals,
&i.NetContribution,
&i.TotalBetAmount,
&i.TotalWinAmount,
&i.NetResult,
&i.RoundsPlayed,
&i.AvgBetSize,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const GetPlayerActivityByID = `-- name: GetPlayerActivityByID :one
SELECT id, user_id, report_date, report_type, total_deposits, total_withdrawals, net_contribution, total_bet_amount, total_win_amount, net_result, rounds_played, avg_bet_size, created_at, updated_at FROM virtual_game_player_activity_reports
WHERE id = $1
`
func (q *Queries) GetPlayerActivityByID(ctx context.Context, id int64) (VirtualGamePlayerActivityReport, error) {
row := q.db.QueryRow(ctx, GetPlayerActivityByID, id)
var i VirtualGamePlayerActivityReport
err := row.Scan(
&i.ID,
&i.UserID,
&i.ReportDate,
&i.ReportType,
&i.TotalDeposits,
&i.TotalWithdrawals,
&i.NetContribution,
&i.TotalBetAmount,
&i.TotalWinAmount,
&i.NetResult,
&i.RoundsPlayed,
&i.AvgBetSize,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const GetPlayerActivityRange = `-- name: GetPlayerActivityRange :many
SELECT id, user_id, report_date, report_type, total_deposits, total_withdrawals, net_contribution, total_bet_amount, total_win_amount, net_result, rounds_played, avg_bet_size, created_at, updated_at FROM virtual_game_player_activity_reports
WHERE user_id = $1
AND report_date BETWEEN $2 AND $3
ORDER BY report_date
`
type GetPlayerActivityRangeParams struct {
UserID int64 `json:"user_id"`
ReportDate pgtype.Date `json:"report_date"`
ReportDate_2 pgtype.Date `json:"report_date_2"`
}
func (q *Queries) GetPlayerActivityRange(ctx context.Context, arg GetPlayerActivityRangeParams) ([]VirtualGamePlayerActivityReport, error) {
rows, err := q.db.Query(ctx, GetPlayerActivityRange, arg.UserID, arg.ReportDate, arg.ReportDate_2)
if err != nil {
return nil, err
}
defer rows.Close()
var items []VirtualGamePlayerActivityReport
for rows.Next() {
var i VirtualGamePlayerActivityReport
if err := rows.Scan(
&i.ID,
&i.UserID,
&i.ReportDate,
&i.ReportType,
&i.TotalDeposits,
&i.TotalWithdrawals,
&i.NetContribution,
&i.TotalBetAmount,
&i.TotalWinAmount,
&i.NetResult,
&i.RoundsPlayed,
&i.AvgBetSize,
&i.CreatedAt,
&i.UpdatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const GetTopPlayersByNetResult = `-- name: GetTopPlayersByNetResult :many
SELECT user_id, SUM(net_result) AS total_net
FROM virtual_game_player_activity_reports
WHERE report_date BETWEEN $1 AND $2
GROUP BY user_id
ORDER BY total_net DESC
LIMIT $3
`
type GetTopPlayersByNetResultParams struct {
ReportDate pgtype.Date `json:"report_date"`
ReportDate_2 pgtype.Date `json:"report_date_2"`
Limit int32 `json:"limit"`
}
type GetTopPlayersByNetResultRow struct {
UserID int64 `json:"user_id"`
TotalNet int64 `json:"total_net"`
}
func (q *Queries) GetTopPlayersByNetResult(ctx context.Context, arg GetTopPlayersByNetResultParams) ([]GetTopPlayersByNetResultRow, error) {
rows, err := q.db.Query(ctx, GetTopPlayersByNetResult, arg.ReportDate, arg.ReportDate_2, arg.Limit)
if err != nil {
return nil, err
}
defer rows.Close()
var items []GetTopPlayersByNetResultRow
for rows.Next() {
var i GetTopPlayersByNetResultRow
if err := rows.Scan(&i.UserID, &i.TotalNet); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const UpsertCompanyReport = `-- name: UpsertCompanyReport :one
INSERT INTO virtual_game_company_reports (
company_id, provider_id,
report_date, report_type,
total_bet_amount, total_win_amount,
created_at, updated_at
)
VALUES ($1, $2, $3, $4, $5, $6, NOW(), NOW())
ON CONFLICT (company_id, provider_id, report_date, report_type)
DO UPDATE SET
total_bet_amount = EXCLUDED.total_bet_amount,
total_win_amount = EXCLUDED.total_win_amount,
updated_at = NOW()
RETURNING id, company_id, provider_id, report_date, report_type, total_bet_amount, total_win_amount, net_profit, profit_margin, created_at, updated_at
`
type UpsertCompanyReportParams struct {
CompanyID int64 `json:"company_id"`
ProviderID string `json:"provider_id"`
ReportDate pgtype.Date `json:"report_date"`
ReportType string `json:"report_type"`
TotalBetAmount pgtype.Numeric `json:"total_bet_amount"`
TotalWinAmount pgtype.Numeric `json:"total_win_amount"`
}
func (q *Queries) UpsertCompanyReport(ctx context.Context, arg UpsertCompanyReportParams) (VirtualGameCompanyReport, error) {
row := q.db.QueryRow(ctx, UpsertCompanyReport,
arg.CompanyID,
arg.ProviderID,
arg.ReportDate,
arg.ReportType,
arg.TotalBetAmount,
arg.TotalWinAmount,
)
var i VirtualGameCompanyReport
err := row.Scan(
&i.ID,
&i.CompanyID,
&i.ProviderID,
&i.ReportDate,
&i.ReportType,
&i.TotalBetAmount,
&i.TotalWinAmount,
&i.NetProfit,
&i.ProfitMargin,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const UpsertFinancialReport = `-- name: UpsertFinancialReport :one
INSERT INTO virtual_game_financial_reports (
game_id, provider_id, report_date, report_type,
total_bets, total_wins, created_at, updated_at
)
VALUES ($1, $2, $3, $4, $5, $6, NOW(), NOW())
ON CONFLICT (game_id, provider_id, report_date, report_type)
DO UPDATE SET
total_bets = EXCLUDED.total_bets,
total_wins = EXCLUDED.total_wins,
updated_at = NOW()
RETURNING id, game_id, provider_id, report_date, report_type, total_bets, total_wins, ggr, rtp, created_at, updated_at
`
type UpsertFinancialReportParams struct {
GameID string `json:"game_id"`
ProviderID string `json:"provider_id"`
ReportDate pgtype.Date `json:"report_date"`
ReportType string `json:"report_type"`
TotalBets pgtype.Numeric `json:"total_bets"`
TotalWins pgtype.Numeric `json:"total_wins"`
}
func (q *Queries) UpsertFinancialReport(ctx context.Context, arg UpsertFinancialReportParams) (VirtualGameFinancialReport, error) {
row := q.db.QueryRow(ctx, UpsertFinancialReport,
arg.GameID,
arg.ProviderID,
arg.ReportDate,
arg.ReportType,
arg.TotalBets,
arg.TotalWins,
)
var i VirtualGameFinancialReport
err := row.Scan(
&i.ID,
&i.GameID,
&i.ProviderID,
&i.ReportDate,
&i.ReportType,
&i.TotalBets,
&i.TotalWins,
&i.Ggr,
&i.Rtp,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const UpsertPlayerActivityReport = `-- name: UpsertPlayerActivityReport :one
INSERT INTO virtual_game_player_activity_reports (
user_id, report_date, report_type,
total_deposits, total_withdrawals,
total_bet_amount, total_win_amount,
rounds_played, created_at, updated_at
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, NOW(), NOW())
ON CONFLICT (user_id, report_date, report_type)
DO UPDATE SET
total_deposits = EXCLUDED.total_deposits,
total_withdrawals = EXCLUDED.total_withdrawals,
total_bet_amount = EXCLUDED.total_bet_amount,
total_win_amount = EXCLUDED.total_win_amount,
rounds_played = EXCLUDED.rounds_played,
updated_at = NOW()
RETURNING id, user_id, report_date, report_type, total_deposits, total_withdrawals, net_contribution, total_bet_amount, total_win_amount, net_result, rounds_played, avg_bet_size, created_at, updated_at
`
type UpsertPlayerActivityReportParams struct {
UserID int64 `json:"user_id"`
ReportDate pgtype.Date `json:"report_date"`
ReportType string `json:"report_type"`
TotalDeposits pgtype.Numeric `json:"total_deposits"`
TotalWithdrawals pgtype.Numeric `json:"total_withdrawals"`
TotalBetAmount pgtype.Numeric `json:"total_bet_amount"`
TotalWinAmount pgtype.Numeric `json:"total_win_amount"`
RoundsPlayed pgtype.Int8 `json:"rounds_played"`
}
func (q *Queries) UpsertPlayerActivityReport(ctx context.Context, arg UpsertPlayerActivityReportParams) (VirtualGamePlayerActivityReport, error) {
row := q.db.QueryRow(ctx, UpsertPlayerActivityReport,
arg.UserID,
arg.ReportDate,
arg.ReportType,
arg.TotalDeposits,
arg.TotalWithdrawals,
arg.TotalBetAmount,
arg.TotalWinAmount,
arg.RoundsPlayed,
)
var i VirtualGamePlayerActivityReport
err := row.Scan(
&i.ID,
&i.UserID,
&i.ReportDate,
&i.ReportType,
&i.TotalDeposits,
&i.TotalWithdrawals,
&i.NetContribution,
&i.TotalBetAmount,
&i.TotalWinAmount,
&i.NetResult,
&i.RoundsPlayed,
&i.AvgBetSize,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}