Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

October updates #290

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions internal/api/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,33 +171,40 @@ var endpointMethodSupports = map[string]map[string]bool{
"PATCH": true,
"DELETE": false,
},
"/subscriptions": {
"/channels/followed": {
"GET": true,
"POST": false,
"PUT": false,
"PATCH": false,
"DELETE": false,
},
"/tags/streams": {
"/channels/followers": {
"GET": true,
"POST": false,
"PUT": false,
"PATCH": false,
"DELETE": false,
},
"/streams/tags": {
"/subscriptions": {
"GET": true,
"POST": false,
"PUT": true,
"PUT": false,
"PATCH": false,
"DELETE": false,
},
"/users/follows": {
"/tags/streams": {
"GET": true,
"POST": true,
"POST": false,
"PUT": false,
"PATCH": false,
"DELETE": true,
"DELETE": false,
},
"/streams/tags": {
"GET": true,
"POST": false,
"PUT": true,
"PATCH": false,
"DELETE": false,
},
"/users/extensions/list": {
"GET": true,
Expand Down
2 changes: 1 addition & 1 deletion internal/database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func TestUsers(t *testing.T) {
err = q.AddFollow(urp)
a.Nil(err)

dbr, err = q.GetFollows(urp)
dbr, err = q.GetFollows(urp, false)
a.Nil(err)
follows := dbr.Data.([]Follow)
a.GreaterOrEqual(len(follows), 1)
Expand Down
29 changes: 20 additions & 9 deletions internal/database/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ type User struct {
}

type Follow struct {
BroadcasterID string `db:"to_id" json:"to_id"`
BroadcasterLogin string `db:"to_login" json:"to_login"`
BroadcasterName string `db:"to_name" json:"to_name"`
ViewerID string `db:"from_id" json:"from_id"`
ViewerLogin string `db:"from_login" json:"from_login"`
ViewerName string `db:"from_name" json:"from_name"`
FollowedAt string `db:"created_at" json:"followed_at"`
BroadcasterID string `db:"to_id"`
BroadcasterLogin string `db:"to_login"`
BroadcasterName string `db:"to_name"`
ViewerID string `db:"from_id"`
ViewerLogin string `db:"from_login"`
ViewerName string `db:"from_name"`
FollowedAt string `db:"created_at"`
}

type UserRequestParams struct {
Expand Down Expand Up @@ -185,7 +185,10 @@ func (q *Query) AddFollow(p UserRequestParams) error {
return err
}

func (q *Query) GetFollows(p UserRequestParams) (*DBResponse, error) {
// "Total" returned depends on totalsFromUser bool.
// "true" will return the number of people the user from p.UserID currently follows.
// "false" will return the number of people the user from p.BroadcasterID currently follows.
func (q *Query) GetFollows(p UserRequestParams, totalsFromUser bool) (*DBResponse, error) {
db := q.DB
var r []Follow
var f Follow
Expand All @@ -203,8 +206,16 @@ func (q *Query) GetFollows(p UserRequestParams) (*DBResponse, error) {
}
r = append(r, f)
}

totalsP := UserRequestParams{}
if totalsFromUser {
totalsP.UserID = p.UserID
} else {
totalsP.BroadcasterID = p.BroadcasterID
}

var total int
rows, err = q.DB.NamedQuery(generateSQL("select count(*) from follows", p, SEP_AND), p)
rows, err = q.DB.NamedQuery(generateSQL("select count(*) from follows", totalsP, SEP_AND), totalsP)
for rows.Next() {
err := rows.Scan(&total)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/database/videos.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Clip struct {
CreatedAt string `db:"created_at" json:"created_at"`
Duration float64 `db:"duration" json:"duration"`
VodOffset int `db:"vod_offset" json:"vod_offset"`
IsFeatured bool `json:"is_featured"`
// calculated fields
URL string `json:"url"`
ThumbnailURL string `json:"thumbnail_url"`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package follow_v2
package follow

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package follow_v1
package follow

import (
"encoding/json"
Expand Down
129 changes: 0 additions & 129 deletions internal/events/types/follow_v1/follow_event.go

This file was deleted.

78 changes: 0 additions & 78 deletions internal/events/types/follow_v2/follow_event_test.go

This file was deleted.

14 changes: 10 additions & 4 deletions internal/events/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import (
"github.com/twitchdev/twitch-cli/internal/events/types/cheer"
"github.com/twitchdev/twitch-cli/internal/events/types/drop"
"github.com/twitchdev/twitch-cli/internal/events/types/extension_transaction"
"github.com/twitchdev/twitch-cli/internal/events/types/follow_v1"
"github.com/twitchdev/twitch-cli/internal/events/types/follow_v2"
"github.com/twitchdev/twitch-cli/internal/events/types/follow"
"github.com/twitchdev/twitch-cli/internal/events/types/gift"
"github.com/twitchdev/twitch-cli/internal/events/types/goal"
"github.com/twitchdev/twitch-cli/internal/events/types/hype_train"
Expand Down Expand Up @@ -51,8 +50,7 @@ func AllEvents() []events.MockEvent {
cheer.Event{},
drop.Event{},
extension_transaction.Event{},
follow_v1.Event{},
follow_v2.Event{},
follow.Event{},
gift.Event{},
goal.Event{},
hype_train.Event{},
Expand Down Expand Up @@ -153,3 +151,11 @@ func GetByTriggerAndTransportAndVersion(trigger string, transport string, versio
// Default error
return nil, errors.New("Invalid event")
}

// These events were removed from production
// This does not include any "beta" events, just old production versions
func RemovedEvents() map[string]string {
return map[string]string{
"channel.follow": "1",
}
}
Loading