Added balance deletion
This commit is contained in:
parent
a52668ada5
commit
ce9a2538d6
38
patches/delete-balance/delete-balance.go
Normal file
38
patches/delete-balance/delete-balance.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
"github.com/fatih/color"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Shell parameters
|
||||||
|
var confirmed bool
|
||||||
|
|
||||||
|
// Shell flags
|
||||||
|
func init() {
|
||||||
|
flag.BoolVar(&confirmed, "confirm", false, "Confirm that you really want to execute this.")
|
||||||
|
flag.Parse()
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if !confirmed {
|
||||||
|
color.Green("Please run this command with -confirm option if you really want to reset the balance of all users.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
color.Yellow("Resetting balance of all users to 0")
|
||||||
|
|
||||||
|
// Get a stream of all users
|
||||||
|
allUsers, err := arn.StreamUsers()
|
||||||
|
arn.PanicOnError(err)
|
||||||
|
|
||||||
|
// Iterate over the stream
|
||||||
|
for user := range allUsers {
|
||||||
|
user.Balance = 0
|
||||||
|
arn.PanicOnError(user.Save())
|
||||||
|
}
|
||||||
|
|
||||||
|
color.Green("Finished.")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user