Reduce debug message that were flooding the bus

parent 1e837e54
......@@ -3215,19 +3215,12 @@ class QtVideoPlayer(QObject):
def _on_position_changed(self, position: int, duration: int):
"""Handle position changes from player window"""
try:
# Send progress update via message bus
if duration > 0:
percentage = (position / duration) * 100
progress_message = MessageBuilder.video_progress(
sender=self.name,
position=position / 1000.0, # Convert to seconds
duration=duration / 1000.0, # Convert to seconds
percentage=percentage
)
self.message_bus.publish(progress_message, broadcast=True)
# Progress updates are now handled by the throttled periodic _send_progress_update method
# to prevent flooding the message bus with VIDEO_PROGRESS messages
pass
except Exception as e:
logger.error(f"Failed to send progress update: {e}")
logger.error(f"Failed to handle position change: {e}")
def _on_video_loaded(self, file_path: str):
"""Handle video loaded event"""
......
......@@ -814,8 +814,6 @@
}, 5000);
})();
// Test console override
console.log('TEST: Console override applied and buffering');
// Debug timing helper
function getTimestamp() {
......@@ -838,66 +836,49 @@
// Check if WebChannel is available
if (!window.overlay || typeof window.overlay.getCurrentData !== 'function') {
console.log('DEBUG: WebChannel not ready, retrying...');
if (retryCount < maxRetries) {
const delay = baseDelay * Math.pow(2, retryCount);
console.log(`DEBUG: Retrying in ${delay}ms (attempt ${retryCount + 1}/${maxRetries + 1})`);
setTimeout(() => {
fetchResultsData(retryCount + 1);
}, delay);
} else {
console.log('DEBUG: Max retries reached, using fallback data');
debugTime('Max retries reached for WebChannel connection');
showFallbackResults();
}
return;
}
console.log('DEBUG: WebChannel available, calling getCurrentData()');
// Call WebChannel method to get current overlay data
const currentDataJson = await window.overlay.getCurrentData();
console.log('DEBUG: WebChannel response received');
console.log('DEBUG: Raw response =', currentDataJson);
let data;
try {
data = JSON.parse(currentDataJson);
console.log('DEBUG: WebChannel response JSON parsed successfully');
console.log('DEBUG: WebChannel response data =', data);
} catch (parseError) {
console.log('DEBUG: Failed to parse WebChannel response as JSON');
throw new Error(`JSON parse error: ${parseError.message}`);
}
debugTime('Results data received via WebChannel');
if (data && (data.outcome || data.result)) {
console.log('DEBUG: WebChannel returned results data');
updateOverlayData(data);
} else {
console.log('DEBUG: WebChannel response did not contain results data');
debugTime('No results data in WebChannel response');
// Keep checking for data
setTimeout(() => fetchResultsData(0), 1000);
}
} catch (error) {
console.log('DEBUG: Exception caught in fetchResultsData');
console.log('DEBUG: Error message =', error.message);
console.log('DEBUG: Error stack =', error.stack);
debugTime(`Failed to fetch results data: ${error.message}`);
// Check if we should retry
if (retryCount < maxRetries) {
// Calculate delay with exponential backoff
const delay = baseDelay * Math.pow(2, retryCount);
console.log(`DEBUG: Retrying in ${delay}ms (attempt ${retryCount + 2}/${maxRetries + 1})`);
setTimeout(() => {
fetchResultsData(retryCount + 1);
}, delay);
} else {
console.log('DEBUG: Max retries reached, using fallback data');
debugTime('Max retries reached for results data fetch');
// Show fallback data instead of error message
showFallbackResults();
......@@ -922,9 +903,6 @@
// Fallback to console if WebChannel not available - use original console to avoid recursion
originalConsoleLog(`[RESULTS FALLBACK] ${message}`);
}
// Always log to console as well for browser debugging - use original to avoid recursion
originalConsoleLog(`🔍 DEBUG: ${message}`);
}
// Store original console.log before overriding
......@@ -934,17 +912,9 @@
function setupWebChannel() {
// Check if WebChannel is already set up by overlay.js
if (window.overlay) {
console.log('🔍 DEBUG: WebChannel already set up by overlay.js');
// Test WebChannel
if (window.overlay && window.overlay.log) {
window.overlay.log('TEST: WebChannel connection successful');
}
// Listen for data updates from Python
if (window.overlay.dataUpdated) {
window.overlay.dataUpdated.connect(function(data) {
console.log('🔍 DEBUG: Received data update from Python:', data);
if (data && (data.outcome || data.result)) {
updateOverlayData(data);
}
......@@ -968,15 +938,12 @@
if (typeof qt !== 'undefined' && qt.webChannelTransport) {
try {
new QWebChannel(qt.webChannelTransport, function(channel) {
console.log('🔍 DEBUG: WebChannel connected successfully (fallback)');
// Connect to overlay object
window.overlay = channel.objects.overlay;
// Listen for data updates from Python
if (window.overlay && window.overlay.dataUpdated) {
window.overlay.dataUpdated.connect(function(data) {
console.log('🔍 DEBUG: Received data update from Python:', data);
if (data && (data.outcome || data.result)) {
updateOverlayData(data);
}
......@@ -993,13 +960,9 @@
}
webChannelReady = true;
console.log('🔍 DEBUG: WebChannel ready for results data');
});
} catch (e) {
console.log('🔍 DEBUG: Failed to setup WebChannel:', e);
}
} else {
console.log('🔍 DEBUG: WebChannel not available, will retry');
}
}
......@@ -1007,7 +970,6 @@
// Show fallback results data when API is not available yet
function showFallbackResults() {
console.log('🔍 DEBUG: Showing fallback results data - API not available yet');
const fallbackData = {
outcome: 'WIN1',
under_over_result: 'OVER',
......@@ -1017,7 +979,6 @@
},
match_id: 1
};
console.log('🔍 DEBUG: Fallback results data loaded, processing');
updateOverlayData(fallbackData);
}
......@@ -1040,7 +1001,6 @@
// Function to update overlay data (called by Qt WebChannel)
function updateOverlayData(data) {
console.log('RESULTS TEMPLATE: updateOverlayData called with data:', data);
overlayData = data || {};
// Only update if we have valid data
......@@ -1051,7 +1011,6 @@
// Check if this is the same data we already processed (prevent duplicate processing)
const dataHash = JSON.stringify(data);
if (window.lastProcessedDataHash === dataHash) {
console.log('RESULTS TEMPLATE: Duplicate data received, ignoring');
return;
}
window.lastProcessedDataHash = dataHash;
......@@ -1062,7 +1021,6 @@
// Check if under/over result is provided separately
if (data.under_over_result) {
currentUnderOverResult = data.under_over_result;
console.log('RESULTS TEMPLATE: Under/over result provided separately:', currentUnderOverResult);
} else {
// Fallback: determine if main result is under/over
if (result === 'UNDER' || result === 'OVER') {
......@@ -1075,20 +1033,16 @@
if (data.match) {
currentMatch = data.match;
console.log('RESULTS TEMPLATE: Match data received:', data.match);
}
if (data.match_id) {
console.log('RESULTS TEMPLATE: Match ID received:', data.match_id);
// Fetch winning outcomes for this match
fetchWinningOutcomes(data.match_id);
// Check if results have already been shown for this match (handles overlay reloads)
const resultsShownKey = 'results_shown_' + data.match_id;
const alreadyShown = sessionStorage.getItem(resultsShownKey) === 'true';
console.log('RESULTS TEMPLATE: Results already shown for match?', alreadyShown);
if (alreadyShown) {
console.log('RESULTS TEMPLATE: Results already shown for this match, displaying immediately');
contentVisible = true;
showResultsPanel();
showResultsContent();
......@@ -1097,11 +1051,9 @@
}
// Prepare data and start 5-second timer to show results
console.log('RESULTS TEMPLATE: Results data received, preparing animation data');
prepareResultsAnimation();
} else {
console.log('RESULTS TEMPLATE: No valid data received, will retry fetching');
// Keep trying to fetch data
setTimeout(() => fetchResultsData(0), 1000);
}
......@@ -1124,8 +1076,6 @@
// Show blue background after 5 seconds from data receipt
setTimeout(() => {
if (!contentVisible) {
console.log('RESULTS TEMPLATE: Showing blue background after 5 seconds from data received');
// Mark results as shown in sessionStorage
if (overlayData && overlayData.match_id) {
sessionStorage.setItem('results_shown_' + overlayData.match_id, 'true');
......@@ -1136,7 +1086,6 @@
// Show data immediately after background appears
setTimeout(() => {
contentVisible = true;
console.log('RESULTS TEMPLATE: Showing data immediately after background');
showResultsContent();
}, 100); // Small delay to ensure background is visible first
}
......@@ -1145,19 +1094,14 @@
// Fetch winning outcomes for the match
function fetchWinningOutcomes(matchId) {
console.log('RESULTS TEMPLATE: fetchWinningOutcomes called for match:', matchId);
// Use Qt WebChannel to request winning outcomes data
if (window.overlay && window.overlay.getWinningOutcomes) {
console.log('RESULTS TEMPLATE: Qt WebChannel available, requesting winning outcomes');
try {
const outcomesJson = window.overlay.getWinningOutcomes(matchId);
const outcomesData = JSON.parse(outcomesJson);
console.log('RESULTS TEMPLATE: Received winning outcomes:', outcomesData);
winningOutcomes = outcomesData || [];
updateWinningBetsDisplay();
} catch (error) {
console.error('RESULTS TEMPLATE: Failed to get winning outcomes:', error);
// Fallback: show sample data for testing
winningOutcomes = [
{ outcome: 'WIN1', amount: 125.00 },
......@@ -1167,7 +1111,6 @@
updateWinningBetsDisplay();
}
} else {
console.warn('RESULTS TEMPLATE: Qt WebChannel not available for fetching winning outcomes');
// Fallback: show sample data for testing
winningOutcomes = [
{ outcome: 'WIN1', amount: 125.00 },
......@@ -1180,25 +1123,17 @@
// Show results panel with fade-in animation
function showResultsPanel() {
console.log('RESULTS TEMPLATE: showResultsPanel called');
const resultsPanel = document.getElementById('resultsPanel');
if (resultsPanel) {
console.log('RESULTS TEMPLATE: Adding visible class to results panel');
resultsPanel.classList.add('visible');
} else {
console.log('RESULTS TEMPLATE: ERROR - resultsPanel element not found');
}
}
// Show results content with animation after delay
function showResultsContent() {
console.log('RESULTS TEMPLATE: showResultsContent called');
const resultsContent = document.getElementById('resultsContent');
if (resultsContent) {
console.log('RESULTS TEMPLATE: Adding visible class to results content');
resultsContent.classList.add('visible');
} else {
console.log('RESULTS TEMPLATE: ERROR - resultsContent element not found');
}
}
......@@ -1209,12 +1144,10 @@
// Check if video has started playing (position > 0)
if (position > 0 && !videoStarted) {
videoStarted = true;
console.log('RESULTS TEMPLATE: Video started playing at position:', position);
}
// Check if we've reached 5 seconds and should show results
if (position >= 5 && !contentVisible && overlayData && (overlayData.outcome || overlayData.result)) {
console.log('RESULTS TEMPLATE: Video reached 5 seconds, showing results');
contentVisible = true;
showResultsPanel();
showResultsContent();
......@@ -1222,7 +1155,6 @@
// Throttle position logging to reduce message bus traffic
if (currentTime - lastPositionLogTime >= POSITION_LOG_THROTTLE_MS) {
console.log('RESULTS TEMPLATE: Video position:', position, 'duration:', duration);
lastPositionLogTime = currentTime;
}
}
......@@ -1340,19 +1272,15 @@
setupWebChannel();
// Show initial state
console.log('RESULTS TEMPLATE: DOM loaded, starting data fetch');
// Wait briefly for WebChannel to connect
setTimeout(() => {
console.log('🔍 DEBUG: Starting results data fetch via WebChannel');
// Fetch results data via WebChannel
debugTime('Fetching results data via WebChannel');
fetchResultsData();
// Set up periodic refresh every 30 seconds
setInterval(() => {
debugTime('Periodic refresh: fetching updated results data');
fetchResultsData(0); // Start with retry count 0 for periodic refreshes
}, 30000);
......@@ -1361,8 +1289,6 @@
if (!contentVisible) {
debugTime('No data received after 5 seconds - showing fallback');
showFallbackResults();
} else {
debugTime('Data was received before 5 second timeout');
}
}, 5000);
}, 50); // Wait 50ms for WebChannel setup
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment