Skip to content

Commit

Permalink
Delete blank status symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
duncte123 committed Jun 23, 2024
1 parent ccb115b commit 9aeed21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions sql/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ func UpdateMember(userId string, status string, payAmount int) {
}

func DeleteMember(userId string) {
sql := "DELETE FROM patreon_status WHERE patreon_id = $1;"

db := GetConnection()
defer CloseConnection(db)

DeleteMemberConn(userId, db)
}

func DeleteMemberConn(userId string, db *pgx.Conn) {
sql := "DELETE FROM patreon_status WHERE patreon_id = $1;"

_, err := db.Query(context.Background(), sql, userId)

if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ func updatePatronsInDatabase(data []structs.PatreonMembersData) {
log.Println(userId, "is an", status, "paying", payAmount, "cents")

if status == "" {
// ignore blank statuses
// Delete users with a blank status from the db
sql.DeleteMemberConn(userId, conn)
continue
}

Expand Down

0 comments on commit 9aeed21

Please sign in to comment.