code.pablomurad.com

bbs-hammer

SSH BBS with forums, chat, door games, retro terminals and a weather service, written in Go

fix(radio): replace trending with just played
author
Pablo Murad
date
commit
75b16e440675135045aeb1893b1eeb2557318d7c
parent
51c41a75ed4599f806466922718457d18d5e0ead
changes
5 files +11 −11
@@ -422,7 +422,7 @@ `radio.pick`; it shows on the main menu, the bulletin, `/:radio` and the Commodore.   In the chat, `/np` tells the room the station you last opened and what it is playing.
   The tools are `radio.top`, `radio.search`, `radio.np`, `radio.fav` and `radio.pick`.
 
-  On the web, `/:radio` is the same directory to browse: the most played, trending and
+  On the web, `/:radio` is the same directory to browse: the most played, the just played and
   top voted, every station with filters by name, country, genre and language, 30 to a
   page, lists of all countries, genres and languages, and "surprise me" for a station at
   random. A station's page plays it right there when the stream is https. A station
@@ -199,7 +199,7 @@ p := pageStation(s.playableStation(ctx, radio.Station{UUID: pick.UUID, Name: pick.Name, URL: pick.URL, CountryCode: pick.CountryCode})) 		page.Pick, page.PickNote, page.PickBy = &p, pick.Note, pick.By
 	}
 	for _, sec := range []struct{ title, order string }{
-		{"MOST PLAYED", "popular"}, {"TRENDING", "trending"}, {"TOP VOTED", "votes"},
+		{"MOST PLAYED", "popular"}, {"JUST PLAYED", "recent"}, {"TOP VOTED", "votes"},
 	} {
 		list, err := s.radio.Search(ctx, radio.Query{Order: sec.order, Limit: radioShortList})
 		if err != nil || len(list) == 0 {
@@ -288,7 +288,7 @@ if v := f.Get(k); v != "" { 			page.Filters = append(page.Filters, radioChip{Label: strings.Replace(labels[k], "%s", v, 1) + " ×", Link: radioLinkTo(with(k, ""))})
 		}
 	}
-	for _, o := range []string{"popular", "trending", "votes", "name"} {
+	for _, o := range []string{"popular", "recent", "votes", "name"} {
 		v := with("order", o)
 		if o == "popular" {
 			v.Del("order")
@@ -237,14 +237,14 @@ func TestRadioHome(t *testing.T) {
 	api := newBrowseAPI(t, 100)
 	_, body := radioWeb(t, browseServer(t, api))(http.MethodGet, "/:radio")
-	for _, want := range []string{"MOST PLAYED", "TRENDING", "TOP VOTED", "Station 1", `href="/:radio/browse?order=trending"`,
+	for _, want := range []string{"MOST PLAYED", "JUST PLAYED", "TOP VOTED", "Station 1", `href="/:radio/browse?order=recent"`,
 		`href="/:radio/browse?country=BR"`, `href="/:radio/browse?tag=jazz"`, `href="/:radio/random"`, `name="q"`} {
 		if !strings.Contains(body, want) {
 			t.Errorf("home lacks %q", want)
 		}
 	}
-	if !api.saw("order=clicktrend") || !api.saw("order=votes") {
-		t.Error("home did not ask for trending and top voted")
+	if !api.saw("order=clicktimestamp") || !api.saw("order=votes") {
+		t.Error("home did not ask for the just played and the top voted")
 	}
 }
 
@@ -45,13 +45,13 @@ Name        string // contains, any case 	CountryCode string // two letters, ISO 3166-1
 	Tag         string
 	Language    string // as the directory names it, e.g. "portuguese"
-	Order       string // popular (default), trending, votes, name
+	Order       string // popular (default), recent (just played), votes, name
 	Offset      int    // skip this many, for the next page
 	Limit       int    // 1..50, default 20
 }
 
 // Orders a search can take, and how the directory calls them.
-var orders = map[string]string{"popular": "clickcount", "trending": "clicktrend", "votes": "votes", "name": "name"}
+var orders = map[string]string{"popular": "clickcount", "recent": "clicktimestamp", "votes": "votes", "name": "name"}
 
 // ValidOrder reports whether o is an order Search knows.
 func ValidOrder(o string) bool { _, ok := orders[o]; return ok }
@@ -182,14 +182,14 @@ got = append(got, r.URL.RawQuery) 		io.WriteString(w, "[]")
 	})
 	c := New(api.URL, "ua", nil)
-	c.Search(context.Background(), Query{Tag: "jazz", Language: "portuguese", Order: "trending", Offset: 30})
+	c.Search(context.Background(), Query{Tag: "jazz", Language: "portuguese", Order: "recent", Offset: 30})
 	c.Search(context.Background(), Query{Tag: "jazz", Order: "name"})
 	if len(got) != 2 {
 		t.Fatalf("%d requests", len(got))
 	}
-	for _, want := range []string{"order=clicktrend", "reverse=true", "language=portuguese", "offset=30"} {
+	for _, want := range []string{"order=clicktimestamp", "reverse=true", "language=portuguese", "offset=30"} {
 		if !strings.Contains(got[0], want) {
-			t.Errorf("trending query %q lacks %s", got[0], want)
+			t.Errorf("recent query %q lacks %s", got[0], want)
 		}
 	}
 	if !strings.Contains(got[1], "order=name") || strings.Contains(got[1], "reverse=true") || strings.Contains(got[1], "offset=") {