Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MBetterc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mbetter
MBetterc
Commits
3fdad329
Commit
3fdad329
authored
May 14, 2026
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify sync carryover reporting
parent
27b5028b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
2 deletions
+75
-2
client.py
mbetterclient/api_client/client.py
+1
-1
test_reports_sync_summary.py
test_reports_sync_summary.py
+74
-1
No files found.
mbetterclient/api_client/client.py
View file @
3fdad329
...
...
@@ -1155,7 +1155,7 @@ class ReportsSyncResponseHandler(ResponseHandler):
'extraction_stats'
:
[],
'cap_compensation_balance'
:
cap_compensation_balance
,
'global_carryover_balance'
:
cap_compensation_balance
,
'summary'
:
self
.
_calculate_summary
(
bets_to_sync
,
stats
),
# Use bets_to_sync which have bet_details loaded
'summary'
:
self
.
_calculate_summary
(
bets_to_sync
,
stats
_to_sync
),
'is_incremental'
:
True
,
# Flag to indicate this is an incremental sync
'sync_type'
:
'incremental'
if
last_sync_time
else
'full'
}
...
...
test_reports_sync_summary.py
View file @
3fdad329
from
pathlib
import
Path
from
types
import
SimpleNamespace
from
datetime
import
datetime
,
date
from
mbetterclient.api_client.client
import
ReportsSyncResponseHandler
from
mbetterclient.core.message_bus
import
MessageBus
from
mbetterclient.database.manager
import
DatabaseManager
from
mbetterclient.database.models
import
BetDetailModel
,
BetModel
from
mbetterclient.database.models
import
BetDetailModel
,
BetModel
,
MatchModel
,
ExtractionStatsModel
,
PersistentRedistributionAdjustmentModel
def
_build_handler
(
tmp_path
:
Path
):
...
...
@@ -57,3 +58,75 @@ def test_calculate_summary_payload_can_carry_global_balance_separately(tmp_path)
assert
summary
[
'total_matches'
]
==
0
finally
:
db_manager
.
close
()
def
test_collect_report_data_separates_daily_summary_and_global_carryover
(
tmp_path
):
handler
,
db_manager
=
_build_handler
(
tmp_path
)
handler
.
query_server_last_sync
=
lambda
client_id
=
None
:
None
handler
.
needs_recovery
=
lambda
server_info
:
(
False
,
False
)
session
=
db_manager
.
get_session
()
try
:
session
.
add
(
PersistentRedistributionAdjustmentModel
(
date
=
date
(
1970
,
1
,
1
),
accumulated_shortfall
=-
33.0
,
total_payin
=
200.0
,
total_redistributed
=
233.0
,
cap_percentage
=
70.0
,
))
bet
=
BetModel
(
uuid
=
'bet-collect-1'
,
fixture_id
=
'fixture-1'
,
paid
=
True
,
paid_out
=
False
,
bet_datetime
=
datetime
.
utcnow
())
session
.
add
(
bet
)
session
.
flush
()
match
=
MatchModel
(
match_number
=
1
,
fighter1_township
=
'A'
,
fighter2_township
=
'B'
,
venue_kampala_township
=
'Kampala'
,
filename
=
'fixture.txt'
,
file_sha1sum
=
'fixture-sha1'
,
fixture_id
=
'fixture-1'
,
active_status
=
True
,
status
=
'done'
,
start_time
=
datetime
.
utcnow
(),
accumulated_shortfall
=-
20.0
,
cap_percent
=
70.0
,
)
session
.
add
(
match
)
session
.
flush
()
session
.
add
(
BetDetailModel
(
bet_id
=
'bet-collect-1'
,
match_id
=
match
.
id
,
match_number
=
1
,
outcome
=
'WIN1'
,
amount
=
25.0
,
win_amount
=
75.0
,
result
=
'win'
,
))
session
.
add
(
ExtractionStatsModel
(
match_id
=
match
.
id
,
fixture_id
=
'fixture-1'
,
match_datetime
=
match
.
start_time
,
total_bets
=
1
,
total_amount_collected
=
25.0
,
total_redistributed
=
75.0
,
actual_result
=
'WIN1'
,
result_breakdown
=
{},
under_bets
=
0
,
under_amount
=
0.0
,
over_bets
=
0
,
over_amount
=
0.0
,
extraction_result
=
'WIN1'
,
cap_applied
=
False
,
cap_percentage
=
None
,
))
session
.
commit
()
report_data
=
handler
.
collect_report_data
(
'today'
)
assert
report_data
[
'summary'
][
'total_payin'
]
==
25.0
assert
report_data
[
'summary'
][
'total_payout'
]
==
75.0
assert
report_data
[
'summary'
][
'global_carryover_balance'
]
==
-
33.0
assert
report_data
[
'cap_compensation_balance'
]
==
-
33.0
assert
report_data
[
'global_carryover_balance'
]
==
-
33.0
finally
:
session
.
close
()
db_manager
.
close
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment