Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular Import Between MarketBetsDisplayHandler() and GetPublicResponseMarketByID() #50

Open
pwdel opened this issue Feb 6, 2024 · 0 comments

Comments

@pwdel
Copy link
Member

pwdel commented Feb 6, 2024

In MarketBetsDisplayHandler()...

When we go to processBetsForDisplay we have to enter the time that the market was created at. In order to do this we have to make a query to the database. What would be nicer is to use the pre-built GetPublicResponseMarketByID() however this results in a circular import.

	// Database connection
	db := util.GetDB()

	// Fetch bets for the market
	bets := GetBetsForMarket(marketIDUint)

	// feed in the time created
	// note we are not using GetPublicResponseMarketByID because of circular import
	var market models.Market
	result := db.Where("ID = ?", marketIdStr).First(&market)
	if result.Error != nil {
		// Handle error, for example:
		if errors.Is(result.Error, gorm.ErrRecordNotFound) {
			// Market not found
		} else {
			// Other error fetching market
		}
		return // Make sure to return or appropriately handle the error
	}

	// Process bets and calculate market probability at the time of each bet
	betsDisplayInfo := processBetsForDisplay(market.CreatedAt, bets, db)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant