mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-19 14:04:08 +01:00
Merge branch 'feature-inventory' of https://github.com/ForFarmTeam/ForFarm into feature-inventory
This commit is contained in:
commit
ac994f3d39
@ -20,6 +20,7 @@ import (
|
||||
"github.com/forfarm/backend/internal/domain"
|
||||
m "github.com/forfarm/backend/internal/middlewares"
|
||||
"github.com/forfarm/backend/internal/repository"
|
||||
"github.com/forfarm/backend/internal/services"
|
||||
"github.com/forfarm/backend/internal/services/weather"
|
||||
"github.com/forfarm/backend/internal/utilities"
|
||||
)
|
||||
@ -39,12 +40,12 @@ type api struct {
|
||||
knowledgeHubRepo domain.KnowledgeHubRepository
|
||||
|
||||
weatherFetcher domain.WeatherFetcher
|
||||
|
||||
chatService *services.ChatService
|
||||
}
|
||||
|
||||
var weatherFetcherInstance domain.WeatherFetcher
|
||||
|
||||
func GetWeatherFetcher() domain.WeatherFetcher {
|
||||
return weatherFetcherInstance
|
||||
func (a *api) GetWeatherFetcher() domain.WeatherFetcher {
|
||||
return a.weatherFetcher
|
||||
}
|
||||
|
||||
func NewAPI(
|
||||
@ -76,7 +77,12 @@ func NewAPI(
|
||||
cleanupInterval = 5 * time.Minute
|
||||
}
|
||||
cachedWeatherFetcher := weather.NewCachedWeatherFetcher(owmFetcher, cacheTTL, cleanupInterval, logger)
|
||||
weatherFetcherInstance = cachedWeatherFetcher
|
||||
|
||||
chatService, chatErr := services.NewChatService(logger, analyticsRepo, farmRepo, croplandRepo, inventoryRepo, plantRepository)
|
||||
if chatErr != nil {
|
||||
logger.Error("Failed to initialize ChatService", "error", chatErr)
|
||||
chatService = nil
|
||||
}
|
||||
|
||||
return &api{
|
||||
logger: logger,
|
||||
@ -92,6 +98,8 @@ func NewAPI(
|
||||
analyticsRepo: analyticsRepo,
|
||||
knowledgeHubRepo: knowledgeHubRepository,
|
||||
weatherFetcher: cachedWeatherFetcher,
|
||||
|
||||
chatService: chatService,
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,6 +142,7 @@ func (a *api) Routes() *chi.Mux {
|
||||
a.registerPlantRoutes(r, api)
|
||||
a.registerKnowledgeHubRoutes(r, api)
|
||||
a.registerOauthRoutes(r, api)
|
||||
a.registerChatRoutes(r, api)
|
||||
a.registerInventoryRoutes(r, api)
|
||||
})
|
||||
|
||||
@ -142,7 +151,6 @@ func (a *api) Routes() *chi.Mux {
|
||||
a.registerHelloRoutes(r, api)
|
||||
a.registerFarmRoutes(r, api)
|
||||
a.registerUserRoutes(r, api)
|
||||
a.registerInventoryRoutes(r, api)
|
||||
a.registerAnalyticsRoutes(r, api)
|
||||
})
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user