Skip to content

Commit

Permalink
reminders: migrate away from gorm to sqlboiler (#1652)
Browse files Browse the repository at this point in the history
* reminders: add database schemas

* reminders: set up and run sqlboiler

* reminders: migrate to sqlboiler

While at it, lightly refactor and simplify the code as applicable. The most substantial (non-database) refactor is renaming and moving strReminders to DisplayReminders.

To aid in the refactor, also add discordgo.ParseID as a shortcut for strconv.ParseInt(...). This operation is often needed to convert string IDs in database to int64's and having a shorter name helps.

* reminders: auto-delete old entries with null guild_id as necessary
  • Loading branch information
jo3-l authored May 28, 2024
1 parent 0a25681 commit 5813655
Show file tree
Hide file tree
Showing 11 changed files with 1,417 additions and 191 deletions.
23 changes: 14 additions & 9 deletions lib/discordgo/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ var ErrMFA = errors.New("account has 2FA enabled")
// tasks if given enough information to do so. Currently you can pass zero
// arguments and it will return an empty Discord session.
// There are 3 ways to call New:
// With a single auth token - All requests will use the token blindly,
// no verification of the token will be done and requests may fail.
// IF THE TOKEN IS FOR A BOT, IT MUST BE PREFIXED WITH `BOT `
// eg: `"Bot <token>"`
// With an email and password - Discord will sign in with the provided
// credentials.
// With an email, password and auth token - Discord will verify the auth
// token, if it is invalid it will sign in with the provided
// credentials. This is the Discord recommended way to sign in.
//
// With a single auth token - All requests will use the token blindly,
// no verification of the token will be done and requests may fail.
// IF THE TOKEN IS FOR A BOT, IT MUST BE PREFIXED WITH `BOT `
// eg: `"Bot <token>"`
// With an email and password - Discord will sign in with the provided
// credentials.
// With an email, password and auth token - Discord will verify the auth
// token, if it is invalid it will sign in with the provided
// credentials. This is the Discord recommended way to sign in.
//
// NOTE: While email/pass authentication is supported by DiscordGo it is
// HIGHLY DISCOURAGED by Discord. Please only use email/pass to obtain a token
Expand Down Expand Up @@ -153,3 +154,7 @@ func CheckRetry(_ context.Context, resp *http.Response, err error) (bool, error)
func StrID(id int64) string {
return strconv.FormatInt(id, 10)
}

func ParseID(s string) (int64, error) {
return strconv.ParseInt(s, 10, 64)
}
38 changes: 38 additions & 0 deletions reminders/models/boil_queries.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions reminders/models/boil_table_names.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions reminders/models/boil_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions reminders/models/boil_view_names.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 99 additions & 0 deletions reminders/models/psql_upsert.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5813655

Please sign in to comment.