Skip to content

Commit

Permalink
feature: filter reviews (#96)
Browse files Browse the repository at this point in the history
feature: filter reviews
  • Loading branch information
masnann authored Dec 8, 2023
2 parents 9746fd4 + 01d2128 commit d5051cb
Show file tree
Hide file tree
Showing 10 changed files with 537 additions and 11 deletions.
17 changes: 12 additions & 5 deletions module/feature/challenge/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ func (h *ChallengeHandler) GetAllChallenges() echo.HandlerFunc {
search := c.QueryParam("search")
status := c.QueryParam("status")

if search != "" {
if search != "" && status != "" {
challenges, totalItems, err = h.service.GetChallengesBySearchAndStatus(page, perPage, search, status)
} else if search != "" {
challenges, totalItems, err = h.service.GetChallengeByTitle(page, perPage, search)
} else if status != "" {
challenges, totalItems, err = h.service.GetChallengeByStatus(pageConv, perPage, status)
challenges, totalItems, err = h.service.GetChallengeByStatus(page, perPage, status)
} else {
challenges, totalItems, err = h.service.GetAllChallenges(pageConv, perPage)
}
Expand Down Expand Up @@ -272,9 +274,14 @@ func (h *ChallengeHandler) GetAllSubmitChallengeForm() echo.HandlerFunc {
var totalItems int64
var err error
filterStatus := c.QueryParam("status")

if filterStatus != "" {
participants, totalItems, err = h.service.GetSubmitChallengeFormByStatus(pageConv, perPage, filterStatus)
filterDate := c.QueryParam("date")

if filterStatus != "" && filterDate != "" {
participants, totalItems, err = h.service.GetSubmitChallengeFormByStatusAndDate(page, perPage, filterStatus, filterDate)
} else if filterStatus != "" {
participants, totalItems, err = h.service.GetSubmitChallengeFormByStatus(page, perPage, filterStatus)
} else if filterDate != "" {
participants, totalItems, err = h.service.GetSubmitChallengeFormByDateRange(page, perPage, filterDate)
} else {
participants, totalItems, err = h.service.GetAllSubmitChallengeForm(pageConv, perPage)
}
Expand Down
10 changes: 10 additions & 0 deletions module/feature/challenge/interface.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package challenge

import (
"time"

"github.com/capstone-kelompok-7/backend-disappear/module/entities"
"github.com/capstone-kelompok-7/backend-disappear/module/feature/challenge/dto"
"github.com/labstack/echo/v4"
Expand All @@ -25,6 +27,11 @@ type RepositoryChallengeInterface interface {
GetSubmitChallengeFormById(id uint64) (*entities.ChallengeFormModels, error)
UpdateSubmitChallengeForm(id uint64, updatedStatus dto.UpdateChallengeFormStatusRequest) (*entities.ChallengeFormModels, error)
GetSubmitChallengeFormByUserAndChallenge(userID uint64) ([]*entities.ChallengeFormModels, error)
GetSubmitChallengeFormByDateRange(page, perpage int, startDate, endDate time.Time) ([]*entities.ChallengeFormModels, error)
GetTotalSubmitChallengeFormCountByDateRange(startDate, endDate time.Time) (int64, error)
GetSubmitChallengeFormByStatusAndDate(page, perPage int, filterStatus string, startDate, endDate time.Time) ([]*entities.ChallengeFormModels, error)
GetTotalSubmitChallengeFormCountByStatusAndDate(filterStatus string, startDate, endDate time.Time) (int64, error)
GetChallengesBySearchAndStatus(page, perPage int, search, status string) ([]*entities.ChallengeModels, int64, error)
}

type ServiceChallengeInterface interface {
Expand All @@ -43,6 +50,9 @@ type ServiceChallengeInterface interface {
GetSubmitChallengeFormByStatus(page, perPage int, status string) ([]*entities.ChallengeFormModels, int64, error)
GetSubmitChallengeFormById(id uint64) (*entities.ChallengeFormModels, error)
UpdateSubmitChallengeForm(id uint64, updatedStatus dto.UpdateChallengeFormStatusRequest) (*entities.ChallengeFormModels, error)
GetSubmitChallengeFormByDateRange(page, perPage int, filterType string) ([]*entities.ChallengeFormModels, int64, error)
GetSubmitChallengeFormByStatusAndDate(page, perPage int, filterStatus string, filterType string) ([]*entities.ChallengeFormModels, int64, error)
GetChallengesBySearchAndStatus(page, perPage int, search, status string) ([]*entities.ChallengeModels, int64, error)
}

type HandlerChallengeInterface interface {
Expand Down
135 changes: 135 additions & 0 deletions module/feature/challenge/mocks/RepositoryChallengeInterface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 99 additions & 0 deletions module/feature/challenge/mocks/ServiceChallengeInterface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d5051cb

Please sign in to comment.