diff --git a/backend/goserver/goserver b/backend/goserver/goserver index faa3921..cc179cf 100755 Binary files a/backend/goserver/goserver and b/backend/goserver/goserver differ diff --git a/backend/goserver/main.go b/backend/goserver/main.go index 3f4d675..4224fca 100644 --- a/backend/goserver/main.go +++ b/backend/goserver/main.go @@ -1,139 +1,154 @@ package main import ( "fmt" "io/ioutil" serv "kritaServers/backend/goserver/server" agr "kritaServers/backend/goserver/server/agregate" "net/http" "time" ) type ColorGroup struct { ID int Name string Colors []string } func handlerInstall(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) fmt.Printf("REQUEST") bodyBuffer, _ := ioutil.ReadAll(r.Body) // fmt.Printf("after parse") fmt.Println(string(bodyBuffer)) serv.InsertGeneralInfo(bodyBuffer) w.Header().Set("Server", "A Go Web Server") w.WriteHeader(200) } func handlerTools(w http.ResponseWriter, r *http.Request) { bodyBuffer, _ := ioutil.ReadAll(r.Body) fmt.Println(string(bodyBuffer)) serv.InsertToolInfo(bodyBuffer) w.Header().Set("Server", "A Go Web Server") w.WriteHeader(200) } func handlerImageProperties(w http.ResponseWriter, r *http.Request) { bodyBuffer, _ := ioutil.ReadAll(r.Body) fmt.Println(string(bodyBuffer)) serv.InsertImageInfo(bodyBuffer) } func handlerAsserts(w http.ResponseWriter, r *http.Request) { - // bodyBuffer, _ := ioutil.ReadAll(r.Body) + bodyBuffer, _ := ioutil.ReadAll(r.Body) fmt.Printf("Asserts") - // fmt.Println(string(bodyBuffer)) - // sw.InsertAssertInfo(bodyBuffer) + fmt.Println(string(bodyBuffer)) + serv.InsertAssertInfo(bodyBuffer) w.Header().Set("Server", "A Go Web Server") w.WriteHeader(200) } func handlerActions(w http.ResponseWriter, r *http.Request) { bodyBuffer, _ := ioutil.ReadAll(r.Body) fmt.Println(string(bodyBuffer)) serv.InsertActionInfo(bodyBuffer) w.Header().Set("Server", "A Go Web Server") w.WriteHeader(200) } func handlerGetTools(w http.ResponseWriter, r *http.Request) { temp := agr.Agregated("tools") fmt.Fprintf(w, temp) } func handlerGetActions(w http.ResponseWriter, r *http.Request) { temp := agr.Agregated("actions") fmt.Fprintf(w, temp) } func handlerGetInstallInfo(w http.ResponseWriter, r *http.Request) { type1 := r.URL.Query().Get("type") + fmt.Println("Install!") + if len(type1) != 0 { dataOfType := agr.AgregatedInstall(type1) fmt.Fprintf(w, dataOfType) fmt.Println(dataOfType) return } temp := agr.Agregated("install") fmt.Println(temp) fmt.Fprintf(w, temp) } func handlerGetImageInfo(w http.ResponseWriter, r *http.Request) { type1 := r.URL.Query().Get("type") if len(type1) != 0 { dataOfType := agr.AgregatedImages(type1) fmt.Fprintf(w, dataOfType) return } temp := agr.Agregated("images") fmt.Fprintf(w, temp) } +func handlerGetAssertsInfo(w http.ResponseWriter, r *http.Request) { + temp := agr.Agregated("asserts") + fmt.Fprintf(w, temp) +} func main() { fmt.Printf("hello") serv.InitDB() defer serv.Session.Close() http.HandleFunc("/install/receiver/submit/org.krita.krita", handlerInstall) http.HandleFunc("/tools/receiver/submit/org.krita.krita", handlerTools) http.HandleFunc("/imageProperties/receiver/submit/org.krita.krita", handlerImageProperties) http.HandleFunc("/asserts/receiver/submit/org.krita.krita", handlerAsserts) http.HandleFunc("/actions/receiver/submit/org.krita.krita", handlerActions) http.HandleFunc("/GoogleLogin", serv.HandleGoogleLogin) http.HandleFunc("/GoogleCallback", serv.HandleGoogleCallback) http.HandleFunc("/get/tools", handlerGetTools) http.HandleFunc("/get/actions", handlerGetActions) http.HandleFunc("/get/install", handlerGetInstallInfo) http.HandleFunc("/get/images", handlerGetImageInfo) + http.HandleFunc("/get/asserts", handlerGetAssertsInfo) ticker := time.NewTicker(time.Minute * 2) tickerActions := time.NewTicker(time.Minute * 3) tickerTools := time.NewTicker(time.Minute * 3) tickerImages := time.NewTicker(time.Minute * 4) + tickerAsserts := time.NewTicker(time.Minute * 2) go func() { for _ = range ticker.C { agr.AgregateInstalInfo() // fmt.Println("Tick at", t) } }() go func() { for _ = range tickerActions.C { agr.AgregateActions() //fmt.Println("Tick actions at", t) } }() go func() { for _ = range tickerTools.C { agr.AgregateTools() // fmt.Println("Tick tools at", t) } }() go func() { for _ = range tickerImages.C { agr.AgregateImageProps() //fmt.Println("Tick image at", t) } }() + go func() { + for _ = range tickerAsserts.C { + agr.AgregateAsserts() + //fmt.Println("Tick asserts") + } + + }() http.ListenAndServe(":8080", nil) } diff --git a/backend/goserver/server/agregate/actionsInfo.go b/backend/goserver/server/agregate/actionsInfo.go index 730bf52..68d9587 100644 --- a/backend/goserver/server/agregate/actionsInfo.go +++ b/backend/goserver/server/agregate/actionsInfo.go @@ -1,47 +1,43 @@ package agregate import ( "bufio" serv "kritaServers/backend/goserver/server" md "kritaServers/backend/goserver/server/models" "os" "gopkg.in/mgo.v2/bson" ) func countActionsUse(name string) float64 { results := []bson.M{} c := serv.Session.DB("telemetry").C("actions") pipe := c.Pipe([]bson.M{{"$unwind": "$actions"}, {"$match": bson.M{"actions.actionname": name}}, {"$group": bson.M{"_id": "$actions.actionname", "total_count": bson.M{"$sum": "$actions.countuse"}}}}) //fmt.Println(pipe) - resp := []bson.M{} - err := pipe.All(&resp) - serv.CheckErr(err) - //fmt.Println(resp) // simple print proving it's working - err = pipe.All(&results) + err := pipe.All(&results) serv.CheckErr(err) if len(results) > 0 { num, _ := results[0]["total_count"].(float64) return num } return 0 } func AgregateActions() { file, err := os.Open("list_actions.txt") serv.CheckErr(err) defer file.Close() var action md.ActionCollected var actions []md.ActionCollected scanner := bufio.NewScanner(file) for scanner.Scan() { action.Name = scanner.Text() action.CountUse = countActionsUse(action.Name) actions = append(actions, action) } agregatedActions = actions err = scanner.Err() serv.CheckErr(err) } diff --git a/backend/goserver/server/agregate/agregateInfo.go b/backend/goserver/server/agregate/agregateInfo.go index 372a868..08a7345 100644 --- a/backend/goserver/server/agregate/agregateInfo.go +++ b/backend/goserver/server/agregate/agregateInfo.go @@ -1,120 +1,124 @@ package agregate import ( "encoding/json" serv "kritaServers/backend/goserver/server" md "kritaServers/backend/goserver/server/models" "math" "strconv" mgo "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) var agreagtedData md.CollectedInstallData var agregatedTools md.ToolsCollectedData var agregatedActions []md.ActionCollected var agregatedActionsJson md.AgregatedActionsJson var agregatedImageInfo md.ImageCollected +var agregatedAsserts md.AgregatedAssertsJson func getFloat64(n int, err error) float64 { serv.CheckErr(err) return float64(n) } func checkOtherCount(count float64) float64 { if count < 0 { return 0 } return count } func getProportion(specificCount float64, totalCount float64) string { divended := specificCount / totalCount if math.IsNaN(divended) { return "0%%" //+ "%" } result := strconv.FormatFloat(specificCount/totalCount*100, 'f', -1, 32) return result + "%%" } func countExist(category string, session *mgo.Collection) float64 { count := getFloat64(session.Find(bson.M{category: bson.M{"$exists": true}}).Count()) return count } // func Agregated(type) string { // out, _ := json.Marshal(agreagtedData) // return string(out) // } func AgregatedImages(type1 string) string { switch type1 { case "height": out, _ := json.Marshal(agregatedImageInfo.HD) return string(out) case "width": out, _ := json.Marshal(agregatedImageInfo.WD) return string(out) case "numlayers": out, _ := json.Marshal(agregatedImageInfo.LD) return string(out) case "filesize": out, _ := json.Marshal(agregatedImageInfo.ID) return string(out) case "colorprofile": out, _ := json.Marshal(agregatedImageInfo.CPD) return string(out) default: return string("error") } } func AgregatedInstall(type1 string) string { switch type1 { case "os": out, _ := json.Marshal(agreagtedData.Platform.Os) return string(out) case "windows": out, _ := json.Marshal(agreagtedData.Platform.Version.Windows) return string(out) case "linux": out, _ := json.Marshal(agreagtedData.Platform.Version.Linux) return string(out) case "mac": out, _ := json.Marshal(agreagtedData.Platform.Version.Mac) return string(out) case "architecture": out, _ := json.Marshal(agreagtedData.CPU.Architecture) return string(out) case "cores": out, _ := json.Marshal(agreagtedData.CPU.Cores) return string(out) case "compiler": out, _ := json.Marshal(agreagtedData.Compiler.Type) return string(out) case "locale": out, _ := json.Marshal(agreagtedData.Locale.Language) return string(out) default: return string("error") } } func Agregated(dataType string) string { switch dataType { case "install": out, _ := json.Marshal(agreagtedData) return string(out) case "tools": out, _ := json.Marshal(agregatedTools) return string(out) case "actions": agregatedActionsJson.Actions = agregatedActions out, _ := json.Marshal(agregatedActionsJson) return string(out) case "images": out, _ := json.Marshal(agregatedImageInfo) return string(out) + case "asserts": + out, _ := json.Marshal(agregatedAsserts) + return string(out) default: return string("error") } } diff --git a/backend/goserver/server/agregate/assertsInfo.go b/backend/goserver/server/agregate/assertsInfo.go new file mode 100644 index 0000000..680d3f1 --- /dev/null +++ b/backend/goserver/server/agregate/assertsInfo.go @@ -0,0 +1,23 @@ +package agregate + +import ( + "fmt" + serv "kritaServers/backend/goserver/server" + md "kritaServers/backend/goserver/server/models" + + "gopkg.in/mgo.v2/bson" +) + +func AgregateAsserts() { + + c := serv.Session.DB("telemetry").C("asserts") + + var results []md.AssertsCollected + + err := c.Find(bson.M{"assert": bson.M{"$exists": true}}).Limit(100).All(&results) + serv.CheckErr(err) + fmt.Println("hey") + agregatedAsserts.Asserts = results + //fmt.Println(results) + +} diff --git a/backend/goserver/server/agregate/installInfo.go b/backend/goserver/server/agregate/installInfo.go index b3fec6a..d45813b 100644 --- a/backend/goserver/server/agregate/installInfo.go +++ b/backend/goserver/server/agregate/installInfo.go @@ -1,130 +1,138 @@ package agregate import ( serv "kritaServers/backend/goserver/server" "gopkg.in/mgo.v2/bson" ) func AgregateInstalInfo() { c := serv.Session.DB("telemetry").C("installInfo") //Some error takes place. We lose a little bit of data countRecords := getFloat64(c.Find(bson.M{}).Count()) //compiler agreagtedData.Compiler.Type.GCC.Count = getFloat64(c.Find(bson.M{"compiler.type": "GCC"}).Count()) agreagtedData.Compiler.Type.Clang.Count = getFloat64(c.Find(bson.M{"compiler.type": "Clang"}).Count()) agreagtedData.Compiler.Type.MSVC.Count = getFloat64(c.Find(bson.M{"compiler.type": "MSVC"}).Count()) existsRecords := countExist("compiler.type", c) agreagtedData.Compiler.Type.Other.Count = existsRecords - agreagtedData.Compiler.Type.GCC.Count - agreagtedData.Compiler.Type.Clang.Count - agreagtedData.Compiler.Type.MSVC.Count agreagtedData.Compiler.Type.Other.Count = checkOtherCount(agreagtedData.Compiler.Type.Other.Count) agreagtedData.Compiler.Type.Unknown.Count = countRecords - existsRecords agreagtedData.Compiler.Type.GCC.Proportion = getProportion(agreagtedData.Compiler.Type.GCC.Count, existsRecords) agreagtedData.Compiler.Type.Clang.Proportion = getProportion(agreagtedData.Compiler.Type.Clang.Count, existsRecords) agreagtedData.Compiler.Type.MSVC.Proportion = getProportion(agreagtedData.Compiler.Type.MSVC.Count, existsRecords) agreagtedData.Compiler.Type.Other.Proportion = getProportion(agreagtedData.Compiler.Type.Other.Count, existsRecords) //os agreagtedData.Platform.Os.Linux.Count = getFloat64(c.Find(bson.M{"platform.os": "linux"}).Count()) agreagtedData.Platform.Os.Windows.Count = getFloat64(c.Find(bson.M{"platform.os": "windows"}).Count()) agreagtedData.Platform.Os.Mac.Count = getFloat64(c.Find(bson.M{"platform.os": "mac"}).Count()) existsRecords = countExist("platform.os", c) agreagtedData.Platform.Os.Other.Count = existsRecords - agreagtedData.Platform.Os.Linux.Count - agreagtedData.Platform.Os.Windows.Count - agreagtedData.Platform.Os.Mac.Count agreagtedData.Platform.Os.Other.Count = checkOtherCount(agreagtedData.Platform.Os.Other.Count) agreagtedData.Platform.Os.Unknown.Count = countRecords - existsRecords agreagtedData.Platform.Os.Linux.Proportion = getProportion(agreagtedData.Platform.Os.Linux.Count, existsRecords) agreagtedData.Platform.Os.Windows.Proportion = getProportion(agreagtedData.Platform.Os.Windows.Count, existsRecords) agreagtedData.Platform.Os.Mac.Proportion = getProportion(agreagtedData.Platform.Os.Mac.Count, existsRecords) agreagtedData.Platform.Os.Other.Proportion = getProportion(agreagtedData.Platform.Os.Other.Count, existsRecords) agreagtedData.Platform.Os.Unknown.Proportion = getProportion(agreagtedData.Platform.Os.Unknown.Count, existsRecords) //version os windows agreagtedData.Platform.Version.Windows.V7.Count = getFloat64(c.Find(bson.M{"platform.version": "7"}).Count()) agreagtedData.Platform.Version.Windows.V8.Count = getFloat64(c.Find(bson.M{"platform.version": "8"}).Count()) agreagtedData.Platform.Version.Windows.V81.Count = getFloat64(c.Find(bson.M{"platform.version": "8.1"}).Count()) agreagtedData.Platform.Version.Windows.V10.Count = getFloat64(c.Find(bson.M{"platform.version": "10"}).Count()) agreagtedData.Platform.Version.Windows.Other.Count = agreagtedData.Platform.Os.Windows.Count - agreagtedData.Platform.Version.Windows.V7.Count - agreagtedData.Platform.Version.Windows.V8.Count - agreagtedData.Platform.Version.Windows.V81.Count - agreagtedData.Platform.Version.Windows.V10.Count agreagtedData.Platform.Version.Windows.Other.Count = checkOtherCount(agreagtedData.Platform.Version.Windows.Other.Count) agreagtedData.Platform.Version.Windows.V7.Proportion = getProportion(agreagtedData.Platform.Version.Windows.V7.Count, agreagtedData.Platform.Os.Windows.Count) agreagtedData.Platform.Version.Windows.V8.Proportion = getProportion(agreagtedData.Platform.Version.Windows.V8.Count, agreagtedData.Platform.Os.Windows.Count) agreagtedData.Platform.Version.Windows.V81.Proportion = getProportion(agreagtedData.Platform.Version.Windows.V81.Count, agreagtedData.Platform.Os.Windows.Count) agreagtedData.Platform.Version.Windows.V10.Proportion = getProportion(agreagtedData.Platform.Version.Windows.V10.Count, agreagtedData.Platform.Os.Windows.Count) agreagtedData.Platform.Version.Windows.Other.Proportion = getProportion(agreagtedData.Platform.Version.Windows.Other.Count, agreagtedData.Platform.Os.Windows.Count) //version os linux //не уверен, что именно так пишется нужные версии linux agreagtedData.Platform.Version.Linux.Ubuntu1404.Count = getFloat64(c.Find(bson.M{"platform.version": "ubuntu-14.04"}).Count()) agreagtedData.Platform.Version.Linux.Ubuntu1410.Count = getFloat64(c.Find(bson.M{"platform.version": "ubuntu-14.10"}).Count()) agreagtedData.Platform.Version.Linux.Ubuntu1504.Count = getFloat64(c.Find(bson.M{"platform.version": "ubuntu-15.04"}).Count()) agreagtedData.Platform.Version.Linux.Ubuntu1510.Count = getFloat64(c.Find(bson.M{"platform.version": "ubuntu-15.10"}).Count()) agreagtedData.Platform.Version.Linux.Ubuntu1604.Count = getFloat64(c.Find(bson.M{"platform.version": "ubuntu-16.04"}).Count()) agreagtedData.Platform.Version.Linux.Other.Count = agreagtedData.Platform.Os.Linux.Count - agreagtedData.Platform.Version.Linux.Ubuntu1404.Count - agreagtedData.Platform.Version.Linux.Ubuntu1410.Count - agreagtedData.Platform.Version.Linux.Ubuntu1504.Count - agreagtedData.Platform.Version.Linux.Ubuntu1510.Count - agreagtedData.Platform.Version.Linux.Ubuntu1604.Count - agreagtedData.Platform.Version.Linux.Ubuntu1610.Count - agreagtedData.Platform.Version.Linux.Ubuntu1704.Count agreagtedData.Platform.Version.Linux.Other.Count = checkOtherCount(agreagtedData.Platform.Version.Linux.Other.Count) agreagtedData.Platform.Version.Linux.Ubuntu1404.Proportion = getProportion(agreagtedData.Platform.Version.Linux.Ubuntu1404.Count, agreagtedData.Platform.Os.Linux.Count) agreagtedData.Platform.Version.Linux.Ubuntu1410.Proportion = getProportion(agreagtedData.Platform.Version.Linux.Ubuntu1410.Count, agreagtedData.Platform.Os.Linux.Count) agreagtedData.Platform.Version.Linux.Ubuntu1504.Proportion = getProportion(agreagtedData.Platform.Version.Linux.Ubuntu1504.Count, agreagtedData.Platform.Os.Linux.Count) agreagtedData.Platform.Version.Linux.Ubuntu1510.Proportion = getProportion(agreagtedData.Platform.Version.Linux.Ubuntu1510.Count, agreagtedData.Platform.Os.Linux.Count) agreagtedData.Platform.Version.Linux.Ubuntu1604.Proportion = getProportion(agreagtedData.Platform.Version.Linux.Ubuntu1604.Count, agreagtedData.Platform.Os.Linux.Count) agreagtedData.Platform.Version.Linux.Ubuntu1610.Proportion = getProportion(agreagtedData.Platform.Version.Linux.Ubuntu1610.Count, agreagtedData.Platform.Os.Linux.Count) agreagtedData.Platform.Version.Linux.Ubuntu1704.Proportion = getProportion(agreagtedData.Platform.Version.Linux.Ubuntu1704.Count, agreagtedData.Platform.Os.Linux.Count) agreagtedData.Platform.Version.Linux.Other.Proportion = getProportion(agreagtedData.Platform.Version.Linux.Other.Count, agreagtedData.Platform.Os.Linux.Count) //mac version agreagtedData.Platform.Version.Mac.V1012.Count = getFloat64(c.Find(bson.M{"platform.version": "10.12"}).Count()) agreagtedData.Platform.Version.Mac.Other.Count = agreagtedData.Platform.Os.Mac.Count - agreagtedData.Platform.Version.Mac.V1012.Count agreagtedData.Platform.Version.Mac.Other.Count = checkOtherCount(agreagtedData.Platform.Version.Linux.Other.Count) agreagtedData.Platform.Version.Mac.V1012.Proportion = getProportion(agreagtedData.Platform.Version.Mac.V1012.Count, agreagtedData.Platform.Os.Linux.Count) agreagtedData.Platform.Version.Mac.Other.Proportion = getProportion(agreagtedData.Platform.Version.Mac.Other.Count, agreagtedData.Platform.Os.Linux.Count) //cpu agreagtedData.CPU.Architecture.X86_64.Count = getFloat64(c.Find(bson.M{"cpu.architecture": "x86_64"}).Count()) agreagtedData.CPU.Architecture.X86.Count = getFloat64(c.Find(bson.M{"cpu.architecture": "i386"}).Count()) existsRecords = countExist("cpu.architecture", c) agreagtedData.CPU.Architecture.Other.Count = existsRecords - agreagtedData.CPU.Architecture.X86_64.Count - agreagtedData.CPU.Architecture.X86.Count agreagtedData.CPU.Architecture.Other.Count = checkOtherCount(agreagtedData.CPU.Architecture.Other.Count) agreagtedData.CPU.Architecture.Unknown.Count = countRecords - existsRecords agreagtedData.CPU.Architecture.X86_64.Proportion = getProportion(agreagtedData.CPU.Architecture.X86_64.Count, existsRecords) agreagtedData.CPU.Architecture.X86.Proportion = getProportion(agreagtedData.CPU.Architecture.X86.Count, existsRecords) agreagtedData.CPU.Architecture.Other.Proportion = getProportion(agreagtedData.CPU.Architecture.Other.Count, existsRecords) agreagtedData.CPU.Architecture.Unknown.Proportion = getProportion(agreagtedData.CPU.Architecture.Unknown.Count, countRecords) //cpu cores - agreagtedData.CPU.Cores.C1.Count = getFloat64(c.Find(bson.M{"cpu.count": "1"}).Count()) - agreagtedData.CPU.Cores.C2.Count = getFloat64(c.Find(bson.M{"cpu.count": "2"}).Count()) - agreagtedData.CPU.Cores.C3.Count = getFloat64(c.Find(bson.M{"cpu.count": "3"}).Count()) - agreagtedData.CPU.Cores.C4.Count = getFloat64(c.Find(bson.M{"cpu.count": "4"}).Count()) - agreagtedData.CPU.Cores.C6.Count = getFloat64(c.Find(bson.M{"cpu.count": "6"}).Count()) - agreagtedData.CPU.Cores.C8.Count = getFloat64(c.Find(bson.M{"cpu.count": "8"}).Count()) + agreagtedData.CPU.Cores.C1.Count = getFloat64(c.Find(bson.M{"cpu.count": 1}).Count()) + agreagtedData.CPU.Cores.C2.Count = getFloat64(c.Find(bson.M{"cpu.count": 2}).Count()) + agreagtedData.CPU.Cores.C3.Count = getFloat64(c.Find(bson.M{"cpu.count": 3}).Count()) + agreagtedData.CPU.Cores.C4.Count = getFloat64(c.Find(bson.M{"cpu.count": 4}).Count()) + agreagtedData.CPU.Cores.C6.Count = getFloat64(c.Find(bson.M{"cpu.count": 6}).Count()) + agreagtedData.CPU.Cores.C8.Count = getFloat64(c.Find(bson.M{"cpu.count": 8}).Count()) existsRecords = countExist("cpu.count", c) agreagtedData.CPU.Cores.Other.Count = existsRecords - agreagtedData.CPU.Cores.C1.Count - agreagtedData.CPU.Cores.C2.Count - agreagtedData.CPU.Cores.C3.Count - agreagtedData.CPU.Cores.C4.Count - agreagtedData.CPU.Cores.C6.Count - agreagtedData.CPU.Cores.C8.Count agreagtedData.CPU.Cores.Unknown.Count = countRecords - existsRecords agreagtedData.CPU.Cores.C1.Proportion = getProportion(agreagtedData.CPU.Cores.C1.Count, existsRecords) agreagtedData.CPU.Cores.C2.Proportion = getProportion(agreagtedData.CPU.Cores.C2.Count, existsRecords) agreagtedData.CPU.Cores.C3.Proportion = getProportion(agreagtedData.CPU.Cores.C3.Count, existsRecords) agreagtedData.CPU.Cores.C4.Proportion = getProportion(agreagtedData.CPU.Cores.C4.Count, existsRecords) agreagtedData.CPU.Cores.C6.Proportion = getProportion(agreagtedData.CPU.Cores.C6.Count, existsRecords) agreagtedData.CPU.Cores.C8.Proportion = getProportion(agreagtedData.CPU.Cores.C8.Count, existsRecords) agreagtedData.CPU.Cores.Other.Proportion = getProportion(agreagtedData.CPU.Cores.Other.Count, existsRecords) agreagtedData.CPU.Cores.Unknown.Proportion = getProportion(agreagtedData.CPU.Cores.Unknown.Count, countRecords) + agreagtedData.CPU.Vendor.Intel.Count = getFloat64(c.Find(bson.M{"cpu.isintel": true}).Count()) + existsRecords = countExist("cpu.isintel", c) + agreagtedData.CPU.Vendor.Other.Count = existsRecords - agreagtedData.CPU.Vendor.Intel.Count + agreagtedData.CPU.Vendor.Unknown.Count = countRecords - existsRecords + + agreagtedData.CPU.Vendor.Intel.Proportion = getProportion(agreagtedData.CPU.Vendor.Intel.Count, existsRecords) + agreagtedData.CPU.Vendor.Other.Proportion = getProportion(agreagtedData.CPU.Vendor.Other.Count, existsRecords) + agreagtedData.CPU.Vendor.Unknown.Proportion = getProportion(agreagtedData.CPU.Vendor.Unknown.Count, countRecords) //language agreagtedData.Locale.Language.English.Count = getFloat64(c.Find(bson.M{"locale.language": "English"}).Count()) agreagtedData.Locale.Language.Russian.Count = getFloat64(c.Find(bson.M{"locale.language": "Russian"}).Count()) existsRecords = countExist("locale.language", c) agreagtedData.Locale.Language.Other.Count = existsRecords - agreagtedData.Locale.Language.English.Count - agreagtedData.Locale.Language.Russian.Count agreagtedData.Locale.Language.Other.Count = checkOtherCount(agreagtedData.Locale.Language.Other.Count) agreagtedData.Locale.Language.Unknown.Count = countRecords - existsRecords agreagtedData.Locale.Language.English.Proportion = getProportion(agreagtedData.Locale.Language.English.Count, existsRecords) agreagtedData.Locale.Language.Russian.Proportion = getProportion(agreagtedData.Locale.Language.Russian.Count, existsRecords) agreagtedData.Locale.Language.Other.Proportion = getProportion(agreagtedData.Locale.Language.Other.Count, existsRecords) agreagtedData.Locale.Language.Unknown.Proportion = getProportion(agreagtedData.Locale.Language.Unknown.Count, countRecords) } diff --git a/backend/goserver/server/infsertInfo.go b/backend/goserver/server/infsertInfo.go index 25fbb81..dfdc9ca 100644 --- a/backend/goserver/server/infsertInfo.go +++ b/backend/goserver/server/infsertInfo.go @@ -1,57 +1,53 @@ package server import ( "encoding/json" "fmt" md "kritaServers/backend/goserver/server/models" ) func InsertGeneralInfo(request []byte) { var model md.Request err := json.Unmarshal(request, &model) CheckErr(err) c := Session.DB("telemetry").C("installInfo") c.Insert(model) - fmt.Println("inserted info!") +} +func InsertAssertInfo(request []byte) { + var model md.Assert + err := json.Unmarshal(request, &model) + CheckErr(err) + c := Session.DB("telemetry").C("asserts") + c.Insert(model) + fmt.Println("inserted asserts!") } func InsertToolInfo(request []byte) { var err error var tools md.Tool err = json.Unmarshal(request, &tools) CheckErr(err) c := Session.DB("telemetry").C("tools") c.Insert(tools) fmt.Println("inserted TOOL info!") } func InsertActionInfo(request []byte) { var err error var actions md.Action err = json.Unmarshal(request, &actions) CheckErr(err) c := Session.DB("telemetry").C("actions") c.Insert(actions) fmt.Println("inserted ACTION info!") } func InsertImageInfo(request []byte) { var err error var images md.Image err = json.Unmarshal(request, &images) CheckErr(err) c := Session.DB("telemetry").C("images") c.Insert(images) fmt.Println("inserted IMAGE info!") } - -func InsertAssertInfo(request []byte) { - /// TODO - // var err error - // var tools md.Tool - // err = json.Unmarshal(request, &tools) - // CheckErr(err) - // c := Session.DB("telemetry").C("asserts") - // c.Insert(tools) - // fmt.Println("inserted ASSERTS info!") -} diff --git a/backend/goserver/server/models/assertInfo.go b/backend/goserver/server/models/assertInfo.go new file mode 100644 index 0000000..976bed3 --- /dev/null +++ b/backend/goserver/server/models/assertInfo.go @@ -0,0 +1,10 @@ +package models + +type Assert struct { + Assert AssertssInternal `json:"asserts"` +} +type AssertssInternal struct { + AssertFile string `json:"assertFile"` + AssertLine string `json:"assertLine"` + AssertText string `json:"assertText"` +} diff --git a/backend/goserver/server/models/collectModel.go b/backend/goserver/server/models/collectModel.go index 58abcd9..04e81f2 100644 --- a/backend/goserver/server/models/collectModel.go +++ b/backend/goserver/server/models/collectModel.go @@ -1,160 +1,175 @@ package models type ActionCollected struct { CountUse float64 Name string } type AgregatedActionsJson struct { Actions []ActionCollected } +type AssertsCollected struct { + Assert struct { + Line string `bson:"assertline"` + Text string `bson:"asserttext"` + File string `bson:"assertfile"` + } `bson:"assert"` +} +type AgregatedAssertsJson struct { + Asserts []AssertsCollected +} type ToolsCollected struct { CountUse float64 Time float64 Name string } type ToolsCollectedData struct { ToolsUse []ToolsCollected ToolsActivate []ToolsCollected } type CountAndProportion struct { Count float64 Proportion string } type CollectedInstallData struct { Platform struct { Os struct { Windows CountAndProportion Linux CountAndProportion Mac CountAndProportion Other CountAndProportion Unknown CountAndProportion } Version struct { Windows struct { V7 CountAndProportion V8 CountAndProportion V81 CountAndProportion V10 CountAndProportion Other CountAndProportion } Linux struct { Ubuntu1404 CountAndProportion Ubuntu1410 CountAndProportion Ubuntu1504 CountAndProportion Ubuntu1510 CountAndProportion Ubuntu1604 CountAndProportion Ubuntu1610 CountAndProportion Ubuntu1704 CountAndProportion Other CountAndProportion } Mac struct { V1012 CountAndProportion Other CountAndProportion } } } CPU struct { Architecture struct { X86_64 CountAndProportion X86 CountAndProportion //на самом деле x86_64 c маленькой буквы Other CountAndProportion Unknown CountAndProportion } Cores struct { C1 CountAndProportion C2 CountAndProportion C3 CountAndProportion C4 CountAndProportion C6 CountAndProportion C8 CountAndProportion Other CountAndProportion Unknown CountAndProportion } + Vendor struct { + Intel CountAndProportion + Other CountAndProportion + Unknown CountAndProportion + } } Compiler struct { Type struct { GCC CountAndProportion Clang CountAndProportion MSVC CountAndProportion Other CountAndProportion Unknown CountAndProportion } // Version struct { //подумать что можно сделать // V5dot4 float64 // Other float64 // } } Locale struct { Language struct { English CountAndProportion Russian CountAndProportion Other CountAndProportion Unknown CountAndProportion } } } //Less or equal then mb* type imageDistribution struct { Mb1 CountAndProportion Mb5 CountAndProportion Mb10 CountAndProportion Mb25 CountAndProportion Mb50 CountAndProportion Mb100 CountAndProportion Mb200 CountAndProportion Mb400 CountAndProportion Mb800 CountAndProportion More800 CountAndProportion Unknown CountAndProportion } type colorProfileDistribution struct { RGBA CountAndProportion CMYK CountAndProportion Grayscale CountAndProportion XYZ CountAndProportion YCbCr CountAndProportion Lab CountAndProportion Unknown CountAndProportion } //Less then L* type heightDistribution struct { L500 CountAndProportion L1000 CountAndProportion L2000 CountAndProportion L4000 CountAndProportion L8000 CountAndProportion M8000 CountAndProportion Unknown CountAndProportion } type widthDistribution struct { L500 CountAndProportion L1000 CountAndProportion L2000 CountAndProportion L4000 CountAndProportion L8000 CountAndProportion M8000 CountAndProportion Unknown CountAndProportion } type layersDistribution struct { L1 CountAndProportion L2 CountAndProportion L4 CountAndProportion L8 CountAndProportion L16 CountAndProportion L32 CountAndProportion L64 CountAndProportion M64 CountAndProportion Unknown CountAndProportion } type ImageCollected struct { ID imageDistribution CPD colorProfileDistribution HD heightDistribution WD widthDistribution LD layersDistribution //TODO COLORSPACE } diff --git a/backend/goserver/server/models/installInfo.go b/backend/goserver/server/models/installInfo.go index 23f908a..24a88a4 100644 --- a/backend/goserver/server/models/installInfo.go +++ b/backend/goserver/server/models/installInfo.go @@ -1,32 +1,39 @@ package models //Request from krita type Request struct { - ApplicationVersion struct { - Version string `json:"value"` - } `json:"applicationVersion"` + General struct { + AppVersion string `json:"appVersion"` + } `json:"general"` Compiler struct { Type string `json:"type"` Version string `json:"version"` } `json:"compiler"` + Cpu struct { + Architecture string `json:"architecture"` + Count float64 `json:"count"` + Family float64 `json:"family"` + IsIntel bool `json:"isIntel"` + Model float64 `json:"model"` + } Locale struct { Language string `json:"language"` } `json:"locale"` Opengl struct { GlslVersion string `json:"glslVersion"` Renderer string `json:"renderer"` Vendor string `json:"vendor"` } `json:"opengl"` Platform struct { Os string `json:"os"` Version string `json:"version"` } `json:"platform"` QtVersion struct { Version string `json:"value"` } `json:"qtVersion"` Screens []struct { Dpi float64 `json:"dpi"` Height float64 `json:"height"` Width float64 `json:"width"` } `json:"screens"` } diff --git a/frontend/treeview/db.sqlite3 b/frontend/treeview/db.sqlite3 index d8d893d..4fb175b 100644 Binary files a/frontend/treeview/db.sqlite3 and b/frontend/treeview/db.sqlite3 differ diff --git a/frontend/treeview/treeview_app/templates/treeview_app/actions_info.html b/frontend/treeview/treeview_app/templates/treeview_app/actions_info.html index f6e73e9..b96ca4b 100644 --- a/frontend/treeview/treeview_app/templates/treeview_app/actions_info.html +++ b/frontend/treeview/treeview_app/templates/treeview_app/actions_info.html @@ -1,21 +1,21 @@ {% load staticfiles %}
- |