diff --git a/db/db.go b/db/db.go index 0d04078c0..461db5135 100644 --- a/db/db.go +++ b/db/db.go @@ -522,9 +522,12 @@ func (db database) GetBountiesCount(r *http.Request) int64 { open := keys.Get("Open") assingned := keys.Get("Assigned") paid := keys.Get("Paid") + completed := keys.Get("Completed") + openQuery := "" assignedQuery := "" paidQuery := "" + completedQuery := "" if open != "" && open == "true" { openQuery = "AND assignee = '' AND paid != true" @@ -537,6 +540,13 @@ func (db database) GetBountiesCount(r *http.Request) int64 { assignedQuery = "AND assignee != '' AND paid = false" } } + if completed != "" && completed == "true" { + if open != "" && open == "true" { + completedQuery = "OR assignee != '' AND completed = true AND paid = false" + } else { + completedQuery = "AND assignee != '' AND completed = true AND paid = false" + } + } if paid != "" && paid == "true" { if open != "" && open == "true" || assingned != "" && assingned == "true" { paidQuery = "OR paid = true" @@ -550,7 +560,7 @@ func (db database) GetBountiesCount(r *http.Request) int64 { var count int64 query := "SELECT COUNT(*) FROM bounty WHERE show != false" - allQuery := query + " " + openQuery + " " + assignedQuery + " " + paidQuery + allQuery := query + " " + openQuery + " " + assignedQuery + " " + completedQuery + " " + paidQuery db.db.Raw(allQuery).Scan(&count) return count } @@ -579,6 +589,7 @@ func (db database) GetWorkspaceBounties(r *http.Request, org_uuid string) []Boun offset, limit, sortBy, direction, search := utils.GetPaginationParams(r) open := keys.Get("Open") assingned := keys.Get("Assigned") + completed := keys.Get("Completed") paid := keys.Get("Paid") languages := keys.Get("languages") languageArray := strings.Split(languages, ",") @@ -614,6 +625,9 @@ func (db database) GetWorkspaceBounties(r *http.Request, org_uuid string) []Boun if assingned == "true" { statusConditions = append(statusConditions, "assignee != '' AND paid = false") } + if completed == "true" { + statusConditions = append(statusConditions, "assignee != '' AND completed = true AND paid = false") + } if paid == "true" { statusConditions = append(statusConditions, "paid = true") } @@ -662,6 +676,7 @@ func (db database) GetWorkspaceBountiesCount(r *http.Request, org_uuid string) i search := keys.Get("search") open := keys.Get("Open") assingned := keys.Get("Assigned") + completed := keys.Get("Completed") paid := keys.Get("Paid") languages := keys.Get("languages") languageArray := strings.Split(languages, ",") @@ -682,6 +697,9 @@ func (db database) GetWorkspaceBountiesCount(r *http.Request, org_uuid string) i if assingned == "true" { statusConditions = append(statusConditions, "assignee != '' AND paid = false") } + if completed == "true" { + statusConditions = append(statusConditions, "assignee != '' AND completed = true AND paid = false") + } if paid == "true" { statusConditions = append(statusConditions, "paid = true") } @@ -901,6 +919,7 @@ func (db database) GetPreviousBountyByCreated(r *http.Request) (uint, error) { open := keys.Get("Open") assingned := keys.Get("Assigned") + completed := keys.Get("Completed") paid := keys.Get("Paid") languages := keys.Get("languages") languageArray := strings.Split(languages, ",") @@ -921,6 +940,9 @@ func (db database) GetPreviousBountyByCreated(r *http.Request) (uint, error) { if assingned == "true" { statusConditions = append(statusConditions, "assignee != '' AND paid = false") } + if completed == "true" { + statusConditions = append(statusConditions, "assignee != '' AND completed = true AND paid = false") + } if paid == "true" { statusConditions = append(statusConditions, "paid = true") } @@ -963,6 +985,7 @@ func (db database) GetNextWorkspaceBountyByCreated(r *http.Request) (uint, error open := keys.Get("Open") assingned := keys.Get("Assigned") + completed := keys.Get("Completed") paid := keys.Get("Paid") languages := keys.Get("languages") languageArray := strings.Split(languages, ",") @@ -983,6 +1006,9 @@ func (db database) GetNextWorkspaceBountyByCreated(r *http.Request) (uint, error if assingned == "true" { statusConditions = append(statusConditions, "assignee != '' AND paid = false") } + if completed == "true" { + statusConditions = append(statusConditions, "assignee != '' AND completed = true AND paid = false") + } if paid == "true" { statusConditions = append(statusConditions, "paid = true") } @@ -1025,6 +1051,7 @@ func (db database) GetPreviousWorkspaceBountyByCreated(r *http.Request) (uint, e open := keys.Get("Open") assingned := keys.Get("Assigned") + completed := keys.Get("Completed") paid := keys.Get("Paid") languages := keys.Get("languages") languageArray := strings.Split(languages, ",") @@ -1045,6 +1072,9 @@ func (db database) GetPreviousWorkspaceBountyByCreated(r *http.Request) (uint, e if assingned == "true" { statusConditions = append(statusConditions, "assignee != '' AND paid = false") } + if completed == "true" { + statusConditions = append(statusConditions, "assignee != '' AND completed = true AND paid = false") + } if paid == "true" { statusConditions = append(statusConditions, "paid = true") } @@ -1101,6 +1131,7 @@ func (db database) GetAllBounties(r *http.Request) []Bounty { offset, limit, sortBy, direction, search := utils.GetPaginationParams(r) open := keys.Get("Open") assingned := keys.Get("Assigned") + completed := keys.Get("Completed") paid := keys.Get("Paid") orgUuid := keys.Get("org_uuid") languages := keys.Get("languages") @@ -1135,6 +1166,9 @@ func (db database) GetAllBounties(r *http.Request) []Bounty { if assingned == "true" { statusConditions = append(statusConditions, "assignee != '' AND paid = false") } + if completed == "true" { + statusConditions = append(statusConditions, "assignee != '' AND completed = true AND paid = false") + } if paid == "true" { statusConditions = append(statusConditions, "paid = true") }