Added counting

Changed Count post URL
Archiving crashes now removes crashes that match the archive
This commit is contained in:
Caleb Gardner
2024-06-12 02:17:26 -05:00
parent df3fe83c5f
commit e3af23873f
6 changed files with 157 additions and 16 deletions
+6 -3
View File
@@ -45,7 +45,7 @@ func NewBackend(keyTable Table[ApiKey], apps ...App) (*Backend, error) {
}
}
if hasLog {
b.m.HandleFunc("POST /count/{uuid}", b.countLog)
b.m.HandleFunc("POST /count", b.countLog)
b.m.HandleFunc("GET /count", b.getCount)
}
if hasCrash {
@@ -59,8 +59,7 @@ func NewBackend(keyTable Table[ApiKey], apps ...App) (*Backend, error) {
func (b *Backend) cleanupLoop() {
for range time.Tick(24 * time.Hour) {
oldTim := time.Now().Add(-30 * 24 * time.Hour)
old := (oldTim.Year() * 10000) + (int(oldTim.Month()) * 100) + oldTim.Day()
old := getDate(time.Now().Add(-30 * 24 * time.Hour))
for _, a := range b.apps {
tab := a.CountTable()
if tab == nil {
@@ -71,6 +70,10 @@ func (b *Backend) cleanupLoop() {
}
}
func getDate(t time.Time) int {
return (t.Year() * 10000) + (int(t.Month()) * 100) + t.Day()
}
func (b *Backend) EnableManagementKey(managementID string) {
b.managementKeyID = managementID
b.m.HandleFunc("DELETE /{appID}/crash/{crashID}", b.managementDeleteCrash)