1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-15 17:46:55 +00:00

Finish removing emote usage data reporting

This commit is contained in:
Kane York 2017-09-15 16:26:44 -07:00
parent 8626b476db
commit 1aa1046073
2 changed files with 14 additions and 16 deletions

View file

@ -2,11 +2,9 @@ package server
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"log" "log"
"net/url" "net/url"
"strconv"
"sync" "sync"
"time" "time"
@ -301,13 +299,13 @@ func C2STrackFollow(_ *websocket.Conn, client *ClientInfo, msg ClientMessage) (_
} }
// AggregateEmoteUsage is a map from emoteID to a map from chatroom name to usage count. // AggregateEmoteUsage is a map from emoteID to a map from chatroom name to usage count.
var aggregateEmoteUsage = make(map[int]map[string]int) //var aggregateEmoteUsage = make(map[int]map[string]int)
// AggregateEmoteUsageLock is the lock for AggregateEmoteUsage. // AggregateEmoteUsageLock is the lock for AggregateEmoteUsage.
var aggregateEmoteUsageLock sync.Mutex //var aggregateEmoteUsageLock sync.Mutex
// ErrNegativeEmoteUsage is emitted when the submitted emote usage is negative. // ErrNegativeEmoteUsage is emitted when the submitted emote usage is negative.
var ErrNegativeEmoteUsage = errors.New("Emote usage count cannot be negative") //var ErrNegativeEmoteUsage = errors.New("Emote usage count cannot be negative")
// C2SEmoticonUses implements the `emoticon_uses` C2S Command. // C2SEmoticonUses implements the `emoticon_uses` C2S Command.
// msg.Arguments are in the JSON format of [1]map[emoteID]map[ChatroomName]float64. // msg.Arguments are in the JSON format of [1]map[emoteID]map[ChatroomName]float64.
@ -329,10 +327,10 @@ func aggregateDataSender_do() {
follows := followEvents follows := followEvents
followEvents = nil followEvents = nil
followEventsLock.Unlock() followEventsLock.Unlock()
aggregateEmoteUsageLock.Lock() //aggregateEmoteUsageLock.Lock()
emoteUsage := aggregateEmoteUsage //emoteUsage := aggregateEmoteUsage
aggregateEmoteUsage = make(map[int]map[string]int) //aggregateEmoteUsage = make(map[int]map[string]int)
aggregateEmoteUsageLock.Unlock() //aggregateEmoteUsageLock.Unlock()
reportForm := url.Values{} reportForm := url.Values{}
@ -344,10 +342,10 @@ func aggregateDataSender_do() {
} }
strEmoteUsage := make(map[string]map[string]int) strEmoteUsage := make(map[string]map[string]int)
for emoteID, usageByChannel := range emoteUsage { //for emoteID, usageByChannel := range emoteUsage {
strEmoteID := strconv.Itoa(emoteID) // strEmoteID := strconv.Itoa(emoteID)
strEmoteUsage[strEmoteID] = usageByChannel // strEmoteUsage[strEmoteID] = usageByChannel
} //}
emoteJSON, err := json.Marshal(strEmoteUsage) emoteJSON, err := json.Marshal(strEmoteUsage)
if err != nil { if err != nil {
log.Println("error reporting aggregate data:", err) log.Println("error reporting aggregate data:", err)