Remove Repository and use Database instead
This commit is contained in:
@ -21,11 +21,11 @@ func (h *Handler) admin(c *gin.Context) {
|
||||
func (h *Handler) clearDatabase(c *gin.Context) {
|
||||
d := AdminData{}
|
||||
|
||||
if err := goose.Down(h.Service.LegacyDB, "schema"); err != nil {
|
||||
if err := goose.Down(h.Service.DB, "schema"); err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
||||
if err := goose.Up(h.Service.LegacyDB, "schema"); err != nil {
|
||||
if err := goose.Up(h.Service.DB, "schema"); err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ func (h *Handler) clearBudget(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
rows, err := h.Service.DB.DeleteAllAssignments(c.Request.Context(), budgetUUID)
|
||||
rows, err := h.Service.DeleteAllAssignments(c.Request.Context(), budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
@ -60,7 +60,7 @@ func (h *Handler) clearBudget(c *gin.Context) {
|
||||
|
||||
fmt.Printf("Deleted %d assignments\n", rows)
|
||||
|
||||
rows, err = h.Service.DB.DeleteAllTransactions(c.Request.Context(), budgetUUID)
|
||||
rows, err = h.Service.DeleteAllTransactions(c.Request.Context(), budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
@ -77,7 +77,7 @@ func (h *Handler) cleanNegativeBudget(c *gin.Context) {
|
||||
return
|
||||
}*/
|
||||
|
||||
/*min_date, err := h.Service.DB.GetFirstActivity(c.Request.Context(), budgetUUID)
|
||||
/*min_date, err := h.Service.GetFirstActivity(c.Request.Context(), budgetUUID)
|
||||
date := getFirstOfMonthTime(min_date)
|
||||
for {
|
||||
nextDate := date.AddDate(0, 1, 0)
|
||||
@ -86,7 +86,7 @@ func (h *Handler) cleanNegativeBudget(c *gin.Context) {
|
||||
ToDate: nextDate,
|
||||
FromDate: date,
|
||||
}
|
||||
categories, err := h.Service.DB.GetCategoriesWithBalance(c.Request.Context(), params)
|
||||
categories, err := h.Service.GetCategoriesWithBalance(c.Request.Context(), params)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
@ -104,7 +104,7 @@ func (h *Handler) cleanNegativeBudget(c *gin.Context) {
|
||||
Amount: negativeAvailable,
|
||||
CategoryID: category.ID,
|
||||
}
|
||||
h.Service.DB.CreateAssignment(c.Request.Context(), createAssignment)
|
||||
h.Service.CreateAssignment(c.Request.Context(), createAssignment)
|
||||
}
|
||||
|
||||
if nextDate.Before(time.Now()) {
|
||||
|
Reference in New Issue
Block a user