when we switch to markets page, after enabling a match in matches page, it is not present
we have to manually refresh whole markets page to get the match to be shown
same if we disable something on matches page, then visit markets page, the match is still here
fix it,
just do this , whenever we visit the markets page just fetch the enabled matches, then after that keep fetching enabled matches again at interval of 5 seconds
You're right! The markets page needs to fetch enabled matches when we visit it and then keep polling. Let me fix the use-markets.ts hook to properly handle this.
The key changes I made:
pollInterval: 5000 to the GET_ENABLED_MATCHES query - this will fetch enabled matches every 5 secondsfetchPolicy: 'cache-and-network' to both queries - this ensures fresh data is fetched when the component mounts or when a match is selectednotifyOnNetworkStatusChange: false to prevent unnecessary re-renders during pollingNow the markets page will:
This should solve the issue where matches enabled/disabled on the matches page weren't immediately visible on the markets page.
line values.-2.5, -1.5, +0.5, +1.5, etc.Current implementation fails for handicap markets as it uses over probability or average values.
Instead, use the Player 1 probability for the negative handicap line.
Sort based on absolute closeness to 50 percent, calculated as abs(probability - 50).
markets_priced NotificationWhen a markets_priced notification is received via PubSub:
MarketStore.The PubSub listener should:
markets_priced channel.matchId, immediately query all markets for that match (even if not selected).Compare newly fetched odds with the previously stored ones.
For each updated price:
All updates should happen dynamically, without requiring a page reload.
I'll help you fix the handicap market sorting and implement live UI updates with price movement indicators. Let me address both issues:
MarketStore to detect and track price changesPrice Movement Indicators:
markets_priced notificationsThe system now provides real-time market updates with visual price movement indicators, and the handicap sorting works correctly for both line value and probability-based sorting! 🚀
why do we need to subscribe in use-markets, if listener is always active, there is no need to subscribe
this is what should happen,
listener is active
notify come of markets_priced,
we fetch all the markets for that match, regardless of fact that the match is selected or not
there is no need to store all the markets at once
this is the flow
we go to markets page ,
we select a market,
after its selection, we send query to get all markets for that match,
we get all the markets and display the markets
now for a selected match, if markets are updated, we will receive a notification, we will then on the spot, dynamically update the market prices, without needing to full refresh the page , and show indicators according to update of prices , updating the market
we do not need market-store, delete that , we do not need to store all the markets
now if selected a match, and its markets are not fully generated yet, it will show no markets found which is correct, but as soon as we receive notification, we will give query to fetch all markets for that match , we will then on the spot, dynamically update the market prices, without needing to full refresh the page , updating the market
this is how notification is sent from the backend
public async Task PublishMarketsPriced(long matchId)
{
var json = JsonSerializer.Serialize(matchId);
using var conn = new NpgsqlConnection(_connectionString);
await conn.OpenAsync();
using var cmd = new NpgsqlCommand(
$"NOTIFY markets_priced, '{json.Replace("'", "''")}';",
conn
);
await cmd.ExecuteNonQueryAsync();
}
You can send messages while the preview loads