INFRA-2887 : Upsert users cron refactor (#412)

* INFRA-2887 : Upsert users cron refactor

* INFRA-2887 : Review changes

* INFRA-2887 : added UT's

* INFRA-2887 : Second round review changes

* INFRA-2887 : Add default ack

* INFRA-2887 : Add default ack

* INFRA-2887 : make flow async
This commit is contained in:
Vijay Joshi
2024-04-02 16:25:34 +05:30
committed by GitHub
parent 0d613a4bfb
commit 8cd72b46a3
18 changed files with 317 additions and 128 deletions

View File

@@ -0,0 +1,22 @@
package handler
import (
"github.com/gin-gonic/gin"
common "houston/service/response/common"
userService "houston/service/user"
"net/http"
)
type UserHandler struct {
gin *gin.Engine
service userService.UserService
}
func NewUserHandler(gin *gin.Engine, service userService.UserService) *UserHandler {
return &UserHandler{gin: gin, service: service}
}
func (handler *UserHandler) HandleUpsertHoustonUsers(c *gin.Context) {
handler.service.UpsertUsers()
c.JSON(http.StatusOK, common.SuccessResponse("Acknowledged request to upsert users", http.StatusOK))
}

View File

@@ -290,8 +290,11 @@ func (s *Server) usersHandler(houstonGroup *gin.RouterGroup) {
houstonGroup.GET("/users/:id", usersHandler.GetUserInfo)
houstonGroup.GET("/users", usersHandler.GetUsersInConversation)
houstonGroup.GET("/users/update", usersHandler.UpdateHoustonUsers)
houstonGroup.GET("/bots", usersHandler.GetAllHoustonUserBots)
usersHandlerV2 := handler.NewUserHandler(s.gin, appcontext.GetUserService())
houstonGroup.PUT("/users", usersHandlerV2.HandleUpsertHoustonUsers)
}
func (s *Server) filtersHandler(houstonGroup *gin.RouterGroup) {
filtersHandler := service.NewFilterService(s.gin, s.db)