mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-14 12:29:54 +01:00
Clear expired appointments
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gookit/color"
|
"github.com/gookit/color"
|
||||||
@@ -17,6 +18,34 @@ func Arbeiten() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Arbeit() {
|
func Arbeit() {
|
||||||
|
// check appointments
|
||||||
|
appoints, err := ReadAppointments()
|
||||||
|
if err != nil {
|
||||||
|
if !strings.Contains(err.Error(), "not found") && err != nutsdb.ErrBucketEmpty {
|
||||||
|
color.Errorln(err.Error())
|
||||||
|
logOut.WriteError(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cleared := 0
|
||||||
|
for _, a := range appoints {
|
||||||
|
if a.Time.Before(time.Now()) {
|
||||||
|
// appointment expired
|
||||||
|
keyBytes := Int64AndDateToBytes(a.Anime, a.Time)
|
||||||
|
err = DbDelete(bucketAppoint, string(keyBytes))
|
||||||
|
if err != nil {
|
||||||
|
color.Errorln(err.Error())
|
||||||
|
logOut.WriteError(err)
|
||||||
|
} else {
|
||||||
|
cleared++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if cleared > 0 {
|
||||||
|
color.Infof("Cleared %d expired appointments\n", cleared)
|
||||||
|
logOut.WriteLine(fmt.Sprintf("♻️ Cleared %d expired appointments", cleared))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// refresh animelist of users
|
// refresh animelist of users
|
||||||
animesUsers, err := ReadAnimeUsers()
|
animesUsers, err := ReadAnimeUsers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user