Skip to content

Commit

Permalink
fix musiconly
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima committed Dec 31, 2023
1 parent 48b47b3 commit 7ad4e1b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 3 additions & 3 deletions backend/api/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func ParseQueryParams(params url.Values) *SearchCriteria {
}

category := params.Get("category")
_, err := strconv.ParseBool(category)
_, err := strconv.Atoi(category)
if err == nil {
sc.Category = category
}
Expand Down Expand Up @@ -96,8 +96,8 @@ func (sc *SearchCriteria) MakeWhere() string {
if sc.Horizonly {
conditions = append(conditions, "vertical = 0")
}
if sc.Musiconly {
conditions = append(conditions, "category = 10")
if sc.Category != "" {
conditions = append(conditions, "category = " + sc.Category)
}
if len(conditions) > 0 {
return "AND " + strings.Join(conditions, " AND ")
Expand Down
5 changes: 1 addition & 4 deletions frontend/static/js/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,9 @@ document.getElementById("random").onclick = function() {
if (viewsTo.includes("k")) {
viewsTo = viewsTo.split("k")[0] * 1000
}
if (viewsTo == "∞") {
viewsTo = null
}

fetch(
"/api/videos/random?" + `views=${viewsFrom}-${viewsTo}&years=${yearsRange[0]}-${yearsRange[1]}&horizonly=${horizonly}&musiconly=${musiconly}`,
"/api/videos/random?" + `views=${viewsFrom}-${viewsTo}&years=${yearsRange[0]}-${yearsRange[1]}&horizonly=${horizonly}` + musiconly ? '&category=10' : '',
{
headers: {"visitor": localStorage.getItem('visitor')}
}
Expand Down

0 comments on commit 7ad4e1b

Please sign in to comment.