Skip to content

Commit ba22e4c

Browse files
committed
GET /teams/channels includes missing fields; GET /videos corrected field names, and generates new video descriptions and types properly
1 parent f8f15cf commit ba22e4c

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

internal/database/videos.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Video struct {
1414
BroadcasterLogin string `db:"broadcaster_login" json:"user_login" dbi:"false"`
1515
BroadcasterName string `db:"broadcaster_name" json:"user_name" dbi:"false"`
1616
Title string `db:"title" json:"title"`
17-
VideoDescription string `db:"video_description" json:"video_description"`
17+
VideoDescription string `db:"video_description" json:"description"`
1818
CreatedAt string `db:"created_at" json:"created_at"`
1919
PublishedAt string `db:"published_at" json:"published_at"`
2020
Viewable string `db:"viewable" json:"viewable"`
@@ -98,6 +98,10 @@ func (q *Query) GetVideos(v Video, period string, sort string) (*DBResponse, err
9898
return nil, err
9999
}
100100
r[i].MutedSegments = vms
101+
102+
if r[i].Type == "" {
103+
r[i].Type = "archive"
104+
}
101105
}
102106

103107
dbr := DBResponse{

internal/mock_api/endpoints/teams/channel_teams.go

+17
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ type ChannelTeamResponse struct {
3838
ThumbnailURL string `json:"thumbnail_url"`
3939
TeamName string `json:"team_name"`
4040
TeamDisplayName string `json:"team_display_name"`
41+
BroadcasterID string `json:"broadcaster_id"`
42+
BroadcasterName string `json:"broadcaster_name"`
43+
BroadcasterLogin string `json:"broadcaster_login"`
4144
}
4245

4346
func (e ChannelTeams) Path() string { return "/teams/channel" }
@@ -68,6 +71,17 @@ func getChannelTeams(w http.ResponseWriter, r *http.Request) {
6871
return
6972
}
7073

74+
// Get user information
75+
userdbr, err := db.NewQuery(r, 1).GetUser(database.User{ID: r.URL.Query().Get("broadcaster_id")})
76+
if err != nil {
77+
mock_errors.WriteServerError(w, "error fetching user")
78+
return
79+
}
80+
broadcasterID := r.URL.Query().Get("broadcaster_id")
81+
broadcasterLogin := userdbr.UserLogin
82+
broadcasterName := userdbr.DisplayName
83+
84+
// Get team information
7185
dbr, err := db.NewQuery(r, 100).GetTeamByBroadcaster(r.URL.Query().Get("broadcaster_id"))
7286
if err != nil {
7387
mock_errors.WriteServerError(w, "error fetching team")
@@ -89,6 +103,9 @@ func getChannelTeams(w http.ResponseWriter, r *http.Request) {
89103
ThumbnailURL: t.ThumbnailURL,
90104
TeamName: t.TeamName,
91105
TeamDisplayName: t.TeamDisplayName,
106+
BroadcasterID: broadcasterID,
107+
BroadcasterLogin: broadcasterLogin,
108+
BroadcasterName: broadcasterName,
92109
})
93110
}
94111

internal/mock_api/generate/generate.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,14 @@ func generateUsers(ctx context.Context, count int) error {
461461
StreamID: &s.ID,
462462
BroadcasterID: s.Broacaster,
463463
Title: "Sample stream!",
464-
VideoDescription: "",
464+
VideoDescription: "Such an interesting stream today...",
465465
CreatedAt: util.GetTimestamp().Format(time.RFC3339),
466466
PublishedAt: util.GetTimestamp().Format(time.RFC3339),
467467
Viewable: "public",
468468
ViewCount: 0,
469469
Duration: "1h0m0s",
470470
VideoLanguage: "en",
471+
Type: "archive",
471472
}
472473
err := db.NewQuery(nil, 100).InsertVideo(v)
473474
if err != nil {

0 commit comments

Comments
 (0)