This commit is contained in:
shoopea 2019-05-19 11:12:07 +08:00
parent bf42f210db
commit d6268acc60
2 changed files with 17 additions and 1 deletions

2
job.go
View File

@ -20,7 +20,7 @@ func jobRescan(j Job) {
if len(ids) > 1 {
for i := 1; i <= (len(ids)/SQLMsgRescanJobSize)+1; i++ {
var s string
for _, id := range ids[((i - 1) * SQLMsgRescanJobSize):(i*SQLMsgRescanJobSize - 1)] {
for _, id := range ids[((i - 1) * SQLMsgRescanJobSize) : Min((i*SQLMsgRescanJobSize), len(ids))-1] {
s = s + fmt.Sprintf("SELECT %d id FROM DUAL UNION\n", id)
}
s = s + `SELECT 0 id FROM DUAL WHERE 1 = 2;`

View File

@ -20,6 +20,22 @@ func logOnError(err error, msg string) {
}
}
func Min(int a, int b) int {
if a < b {
return a
} else {
return b
}
}
func Max(int a, int b) int {
if a > b {
return a
} else {
return b
}
}
func fromChatWarsDate(d string) (t time.Time, err error) {
r := regexp.MustCompile(`(?P<Day>[0-9]{2}) (?P<Month>(Wintar|Hornung|Lenzin|Ōstar|Winni|Brāh|Hewi|Aran|Witu|Wīndume|Herbist|Hailag)) (?P<Year>[0-9]{4})( (?P<Hour>[0-9]{2}):(?P<Minute>[0-9]{2})){0,1}`)
if r.FindStringSubmatch(d) != nil {