mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-05 05:40:54 +00:00
lmao time.UnixDate sounds like a great idea doesn't it
This commit is contained in:
parent
b22efabfed
commit
1a709d6e51
3 changed files with 17 additions and 10 deletions
|
@ -1,12 +1,12 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/clarkduvall/hyperloglog"
|
||||
"../../server"
|
||||
"encoding/gob"
|
||||
"flag"
|
||||
"fmt"
|
||||
"../../server"
|
||||
"github.com/clarkduvall/hyperloglog"
|
||||
"net/http"
|
||||
"encoding/gob"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
@ -40,10 +40,6 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
if *forceWrite {
|
||||
ForceWrite()
|
||||
}
|
||||
|
||||
filename := flag.Arg(0)
|
||||
hll, err := DownloadAll(filename)
|
||||
if err != nil {
|
||||
|
@ -70,6 +66,12 @@ func DownloadAll(filename string) (*hyperloglog.HyperLogLogPlus, error) {
|
|||
result, _ := hyperloglog.NewPlus(server.CounterPrecision)
|
||||
|
||||
for _, server := range SERVERS {
|
||||
if *forceWrite {
|
||||
resp, err := http.Get(fmt.Sprintf("%s/hll_force_write", server))
|
||||
if err == nil {
|
||||
resp.Body.Close()
|
||||
}
|
||||
}
|
||||
singleHLL, err := DownloadHLL(fmt.Sprintf("%s%s%s", server, folderPrefix, filename))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -241,11 +241,13 @@ func HTTPBackendCachedPublish(w http.ResponseWriter, r *http.Request) {
|
|||
channel := formData.Get("channel")
|
||||
deleteMode := formData.Get("delete") != ""
|
||||
timeStr := formData.Get("time")
|
||||
timestamp, err := time.Parse(time.UnixDate, timeStr)
|
||||
timeNum, err := strconv.ParseInt(timeStr, 10, 64)
|
||||
if err != nil {
|
||||
w.WriteHeader(422)
|
||||
fmt.Fprintf(w, "error parsing time: %v", err)
|
||||
return
|
||||
}
|
||||
timestamp := time.Unix(timeNum, 0)
|
||||
|
||||
cacheinfo, ok := S2CCommandsCacheInfo[cmd]
|
||||
if !ok {
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
"encoding/binary"
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
|
@ -160,6 +160,7 @@ func writeAllHLLs() error {
|
|||
}
|
||||
|
||||
var hllFileServer = http.StripPrefix("/hll", http.FileServer(http.Dir(uniqCountDir)))
|
||||
|
||||
func HTTPShowHLL(w http.ResponseWriter, r *http.Request) {
|
||||
hllFileServer.ServeHTTP(w, r)
|
||||
}
|
||||
|
@ -239,7 +240,9 @@ func getNextMidnight() time.Time {
|
|||
// is_init_func
|
||||
func rolloverCounters() {
|
||||
for {
|
||||
time.Sleep(getNextMidnight().Sub(time.Now()))
|
||||
duration := getNextMidnight().Sub(time.Now())
|
||||
// fmt.Println(duration)
|
||||
time.Sleep(duration)
|
||||
rolloverCounters_do()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue