Skip to content

Commit

Permalink
some unit tests + polls/predictions
Browse files Browse the repository at this point in the history
  • Loading branch information
lleadbet committed Jun 11, 2021
1 parent 5083c74 commit 8f129fd
Show file tree
Hide file tree
Showing 61 changed files with 1,925 additions and 426 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ twitch-cli

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*.html

# Editor configs
.vsvode/
Expand Down
1 change: 0 additions & 1 deletion go.mod
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/fatih/color v1.10.0
github.com/hokaccha/go-prettyjson v0.0.0-20201222001619-a42f9ac2ec8e // indirect
github.com/jmoiron/sqlx v1.3.3
github.com/karalabe/xgo v0.0.0-20191115072854-c5ccff8648a7 // indirect
github.com/manifoldco/promptui v0.8.0
github.com/mattn/go-sqlite3 v1.14.7
github.com/mitchellh/go-homedir v1.1.0
Expand Down
17 changes: 12 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqCl
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
Expand All @@ -26,9 +27,11 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
Expand All @@ -52,6 +55,7 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
Expand All @@ -74,6 +78,7 @@ github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OI
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
Expand Down Expand Up @@ -109,19 +114,21 @@ github.com/jmoiron/sqlx v1.3.3/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXL
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a h1:FaWFmfWdAUKbSCtOU2QjDaorUexogfaMgbipgYATUMU=
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/karalabe/xgo v0.0.0-20191115072854-c5ccff8648a7 h1:AYzjK/SHz6m6mg5iuFwkrAhCc14jvCpW9d6frC9iDPE=
github.com/karalabe/xgo v0.0.0-20191115072854-c5ccff8648a7/go.mod h1:iYGcTYIPUvEWhFo6aKUuLchs+AV4ssYdyuBbQJZGcBk=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a h1:weJVJJRzAJBFRlAiJQROKQs8oC9vOxvm4rZmBBk0ONw=
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
Expand All @@ -136,8 +143,6 @@ github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-sqlite3 v1.14.5 h1:1IdxlwTNazvbKJQSxoJ5/9ECbEeaTTyeU7sEAZ5KKTQ=
github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.7 h1:fxWBnXkxfM6sRiuH3bqJ4CfzZojMOLVc0UTsTglEghA=
github.com/mattn/go-sqlite3 v1.14.7/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
Expand Down Expand Up @@ -181,7 +186,9 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
Expand All @@ -200,7 +207,6 @@ github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5q
github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk=
github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down Expand Up @@ -326,6 +332,7 @@ google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiq
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
Expand Down
2 changes: 0 additions & 2 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ func NewRequest(method string, path string, queryParameters []string, body []byt
break
}

// log.Printf("%v", apiResponse)
if autopaginate == false {
data.Pagination.Cursor = apiResponse.Pagination.Cursor
break
Expand All @@ -123,7 +122,6 @@ func NewRequest(method string, path string, queryParameters []string, body []byt
}

if data.Data == nil {
log.Println("here")
data.Data = make([]interface{}, 0)
}
// handle json marshalling better; returns empty slice vs. null
Expand Down
4 changes: 2 additions & 2 deletions internal/api/api_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"net/http/httptest"
"testing"

"github.com/twitchdev/twitch-cli/internal/util"
"github.com/twitchdev/twitch-cli/test_setup"
)

func TestApiRequest(t *testing.T) {
a := util.SetupTestEnv(t)
a := test_setup.SetupTestEnv(t)

var ok = "{\"status\":\"ok\"}"
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down
7 changes: 4 additions & 3 deletions internal/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/spf13/viper"
"github.com/twitchdev/twitch-cli/internal/util"
"github.com/twitchdev/twitch-cli/test_setup"
)

var params = apiRequestParameters{
Expand All @@ -19,7 +20,7 @@ var params = apiRequestParameters{
}

func TestNewRequest(t *testing.T) {
a := util.SetupTestEnv(t)
a := test_setup.SetupTestEnv(t)
viper.Set("clientid", "1111")
viper.Set("clientsecret", "2222")
viper.Set("accesstoken", "4567")
Expand Down Expand Up @@ -68,7 +69,7 @@ func TestNewRequest(t *testing.T) {
}

func TestValidOptions(t *testing.T) {
a := util.SetupTestEnv(t)
a := test_setup.SetupTestEnv(t)

get := ValidOptions("GET")
a.NotEmpty(get)
Expand All @@ -78,7 +79,7 @@ func TestValidOptions(t *testing.T) {
}

func TestGetClientInformation(t *testing.T) {
a := util.SetupTestEnv(t)
a := test_setup.SetupTestEnv(t)

viper.Set("clientid", "1111")
viper.Set("clientsecret", "2222")
Expand Down
4 changes: 2 additions & 2 deletions internal/api/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"testing"
"time"

"github.com/twitchdev/twitch-cli/internal/util"
"github.com/twitchdev/twitch-cli/test_setup"
"golang.org/x/time/rate"
)

func TestNewClient(t *testing.T) {
a := util.SetupTestEnv(t)
a := test_setup.SetupTestEnv(t)

var ok = "{\"status\":\"ok\"}"
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down
93 changes: 51 additions & 42 deletions internal/database/_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ create table categories(
id text not null primary key, category_name text not null
);
create table users(
id text not null primary key, user_login text not null,
display_name text not null, email text not null,
user_type text, broadcaster_type text,
user_description text, created_at text not null,
id text not null primary key,
user_login text not null,
display_name text not null,
email text not null,
user_type text,
broadcaster_type text,
user_description text,
created_at text not null,
category_id text,
modified_at text,
modified_at text,
stream_language text not null default 'en',
title text not null default '',
delay int not null default 0,
delay int not null default 0,
foreign key (category_id) references categories(id)
);
create table follows (
Expand All @@ -39,21 +43,21 @@ create table bans (
broadcaster_id text not null,
user_id text not null,
created_at text not null,
expires_at text,
expires_at text,
primary key (broadcaster_id, user_id),
foreign key (broadcaster_id) references users(id),
foreign key (user_id) references users(id)
);
create table ban_events (
id text not null primary key,
event_timestamp text not null,
event_type text not null,
event_version text not null default '1.0',
broadcaster_id text not null,
user_id text not null,
expires_at text,
foreign key (broadcaster_id) references users(id),
foreign key (user_id) references users(id)
id text not null primary key,
event_timestamp text not null,
event_type text not null,
event_version text not null default '1.0',
broadcaster_id text not null,
user_id text not null,
expires_at text,
foreign key (broadcaster_id) references users(id),
foreign key (user_id) references users(id)
);
create table moderators (
broadcaster_id text not null,
Expand All @@ -65,7 +69,7 @@ create table moderators (
);
create table moderator_actions (
id text not null primary key,
event_timestamp text not null,
event_timestamp text not null,
event_type text not null,
event_version text not null default '1.0',
broadcaster_id text not null,
Expand Down Expand Up @@ -108,12 +112,12 @@ create table channel_points_redemptions(
id text not null primary key,
reward_id text not null,
broadcaster_id text not null,
user_id text not null,
user_id text not null,
user_input text,
redemption_status text not null,
redeemed_at text,
foreign key (reward_id) references channel_points_rewards(id),
foreign key (broadcaster_id) references users(id),
foreign key (broadcaster_id) references users(id),
foreign key (user_id) references users(id)
);
create table streams(
Expand Down Expand Up @@ -160,12 +164,12 @@ create table videos(
view_count int not null default 0,
duration text not null,
video_language text not null default 'en',
category_id text,
category_id text,
type text default 'archive',
foreign key (stream_id) references streams(id),
foreign key (broadcaster_id) references users(id),
foreign key (category_id) references categories(id)
};
foreign key (broadcaster_id) references users(id),
foreign key (category_id) references categories(id)
);
create table stream_markers(
id text not null primary key,
video_id text not null,
Expand All @@ -189,7 +193,7 @@ create table subscriptions (
is_gift boolean not null default false,
gifter_id text,
tier text not null default '1000',
created_at text not null,
created_at text not null,
primary key (broadcaster_id, user_id),
foreign key (broadcaster_id) references users(id),
foreign key (user_id) references users(id),
Expand Down Expand Up @@ -229,7 +233,7 @@ create table polls (
status text not null,
duration int not null,
started_at text not null,
ended_at text not null,
ended_at text,
foreign key (broadcaster_id) references users(id)
);
create table poll_choices (
Expand All @@ -242,41 +246,46 @@ create table poll_choices (
foreign key (poll_id) references polls(id)
);
create table predictions (
id text not null,
id text not null primary key,
broadcaster_id text not null,
title text not null,
winning_outcome_id text,
prediction_window int,
status text not null,
created_at text not null,
ended_at text not null,
locked_at text not null,
ended_at text,
locked_at text,
foreign key (broadcaster_id) references users(id)
);
create table prediction_outcomes (
id text not null, title text not null,
users int not null default 0, channel_points int not null default 0,
color text not null
id text not null primary key,
title text not null,
users int not null default 0,
channel_points int not null default 0,
color text not null,
prediction_id text not null,
foreign key (prediction_id) references predictions(id)
);
create table prediction_predictions (
prediction_id text not null,
user_id text not null,
amount int not null,
color text not null,
outcome_id text not null,
primary key(prediction_id, user_id),
foreign key(user_id) references users(id),
foreign key(prediction_id) references predictions(id)
foreign key(prediction_id) references predictions(id),
foreign key(outcome_id) references prediction_outcomes(id)
);
create table clips (
id text not null primary key,
broadcaster_id text not null,
creator_id text not null,
video_id text not null,
game_id text not null,
title text not null,
broadcaster_id text not null,
creator_id text not null,
video_id text not null,
game_id text not null,
title text not null,
view_count int default 0,
created_at text not null,
duration real not null,
foreign key (broadcaster_id) references users(id),
created_at text not null,
duration real not null,
foreign key (broadcaster_id) references users(id),
foreign key (creator_id) references users(id)
);
);
1 change: 0 additions & 1 deletion internal/database/_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ func (q *Query) GetPrinciple(p Principle) (*DBResponse, error) {
var r Principle

sql := generateSQL("select * from principle", u, SEP_AND)
sql = fmt.Sprintf("%v LIMIT 1", sql)
rows, err := q.DB.NamedQuery(sql, u)
if err != nil {
return r, err
Expand Down
5 changes: 1 addition & 4 deletions internal/database/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,10 @@ func (q *Query) InsertOrUpdateAuthenticationClient(client AuthenticationClient,
client.Secret = generateString(30)

for {
tx := db.MustBegin()
tx.NamedExec(stmt, client)
err := tx.Commit()
_, err := db.NamedExec(generateInsertSQL("clients", "id", client, upsert), client)
if err == nil {
return client, err
}

client.ID = util.RandomClientID()
}
}
Expand Down
Loading

0 comments on commit 8f129fd

Please sign in to comment.