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 %} json tree example -
+
\ No newline at end of file diff --git a/frontend/treeview/treeview_app/templates/treeview_app/install_info.html b/frontend/treeview/treeview_app/templates/treeview_app/asserts_info.html similarity index 58% copy from frontend/treeview/treeview_app/templates/treeview_app/install_info.html copy to frontend/treeview/treeview_app/templates/treeview_app/asserts_info.html index feb01ad..12086f8 100644 --- a/frontend/treeview/treeview_app/templates/treeview_app/install_info.html +++ b/frontend/treeview/treeview_app/templates/treeview_app/asserts_info.html @@ -1,20 +1,21 @@ {% load staticfiles %} json tree example - + -
+

Last 100 asserts

+
\ No newline at end of file diff --git a/frontend/treeview/treeview_app/templates/treeview_app/images_info.html b/frontend/treeview/treeview_app/templates/treeview_app/images_info.html index f6e73e9..9fa8eeb 100644 --- a/frontend/treeview/treeview_app/templates/treeview_app/images_info.html +++ b/frontend/treeview/treeview_app/templates/treeview_app/images_info.html @@ -1,21 +1,21 @@ {% load staticfiles %} json tree example -
+
\ No newline at end of file diff --git a/frontend/treeview/treeview_app/templates/treeview_app/install_graphs.html b/frontend/treeview/treeview_app/templates/treeview_app/install_graphs.html index 32e47e2..db6602f 100644 --- a/frontend/treeview/treeview_app/templates/treeview_app/install_graphs.html +++ b/frontend/treeview/treeview_app/templates/treeview_app/install_graphs.html @@ -1,18 +1,17 @@ {% load staticfiles %} -{{ chart.as_html }} {{ chart1.as_html }} {{ chart2.as_html }} {{ chart3.as_html }} {{ chart4.as_html }} {{ chart5.as_html - }} {{ chart6.as_html }} {{ chart7.as_html }} +{{ chart.as_html }} {{ chart1.as_html }} {{ chart2.as_html }} {{ chart6.as_html }} {{ chart7.as_html }} \ No newline at end of file diff --git a/frontend/treeview/treeview_app/templates/treeview_app/install_info.html b/frontend/treeview/treeview_app/templates/treeview_app/install_info.html index feb01ad..91a5625 100644 --- a/frontend/treeview/treeview_app/templates/treeview_app/install_info.html +++ b/frontend/treeview/treeview_app/templates/treeview_app/install_info.html @@ -1,20 +1,20 @@ {% load staticfiles %} json tree example -
+
\ No newline at end of file diff --git a/frontend/treeview/treeview_app/templates/treeview_app/start_page.html b/frontend/treeview/treeview_app/templates/treeview_app/start_page.html index 5aca073..8e14255 100644 --- a/frontend/treeview/treeview_app/templates/treeview_app/start_page.html +++ b/frontend/treeview/treeview_app/templates/treeview_app/start_page.html @@ -1,67 +1,67 @@

Main page

-
- + +
\ No newline at end of file diff --git a/frontend/treeview/treeview_app/templates/treeview_app/tools_info.html b/frontend/treeview/treeview_app/templates/treeview_app/tools_info.html index feb01ad..2a66b84 100644 --- a/frontend/treeview/treeview_app/templates/treeview_app/tools_info.html +++ b/frontend/treeview/treeview_app/templates/treeview_app/tools_info.html @@ -1,20 +1,20 @@ {% load staticfiles %} json tree example -
+
\ No newline at end of file diff --git a/frontend/treeview/treeview_app/urls.py b/frontend/treeview/treeview_app/urls.py index 1f1965a..ab8b7b7 100644 --- a/frontend/treeview/treeview_app/urls.py +++ b/frontend/treeview/treeview_app/urls.py @@ -1,20 +1,21 @@ from django.conf.urls import url from . import views from jsonview.decorators import json_view views.collectLargeDataWrapper() urlpatterns = [ url(r'^$', views.start_list, name='star_list'), url(r'^installInfo/$', views.show_install_info, name='show_install_info'), url(r'^actions/$', views.show_actions_info, name='show_actions_info'), url(r'^tools/$', views.show_tools_info, name='show_tools_info'), url(r'^images/$', views.show_images_info, name='show_images_info'), - url(r'^imagesGraphs/$', views.image_graphs, name='image_graphs'), - url(r'^installGraphs/$', views.install_graphs , name='install_graphs'), - url(r'^toolsTableUse/$', views.tools_table_use , name='tools_table_use'), - url(r'^toolsTableActivate/$', views.tools_table_activate , name='tools_table_activate'), - url(r'^actionsTable/$', views.actions_table , name='actions_table'), + url(r'^assertsInfo/$', views.show_asserts_info, name='show_asserts_info'), + url(r'^imagesGraphs/$', views.image_graphs, name='image_graphs'), + url(r'^installGraphs/$', views.install_graphs, name='install_graphs'), + url(r'^toolsTableUse/$', views.tools_table_use, name='tools_table_use'), + url(r'^toolsTableActivate/$', views.tools_table_activate, + name='tools_table_activate'), + url(r'^actionsTable/$', views.actions_table, name='actions_table'), ] - diff --git a/frontend/treeview/treeview_app/views.py b/frontend/treeview/treeview_app/views.py index bfb4e00..0bc7082 100644 --- a/frontend/treeview/treeview_app/views.py +++ b/frontend/treeview/treeview_app/views.py @@ -1,328 +1,343 @@ from django.core.serializers import json import json from django.shortcuts import render import http.client from graphos.renderers import gchart from graphos.sources.simple import SimpleDataSource from graphos.renderers.gchart import BarChart from .models import Tools, ToolsActivate, Actions from django_tables2 import RequestConfig from .tables import ToolsTable, ToolsActivateTable, ActionsTable import threading import sched, time # Create your views here. def show_install_info(request): # response = json.dumps({"timestamp1": 22, "timestamp2": 14}) # temporary solution response = json.dumps({"there should be ": "error request"}) try: conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/install") r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() print(response) except Exception as e: print("error") return render(request, "treeview_app/error_page.html") return render(request, "treeview_app/install_info.html", {'json_string': response}) def show_images_info(request): # response = json.dumps({"timestamp1": 22, "timestamp2": 14}) # temporary solution response = json.dumps({"there should be ": "error request"}) try: conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/images") r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() print(response) except Exception as e: print("error") return render(request, "treeview_app/error_page.html") return render(request, "treeview_app/images_info.html", {'json_string': response}) def show_tools_info(request): # response = json.dumps({"timestamp1": 22, "timestamp2": 14}) # temporary solution response = json.dumps({"there should be ": "error request"}) try: conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/tools") r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() print(response) except Exception as e: print("error") return render(request, "treeview_app/error_page.html") return render(request, "treeview_app/tools_info.html", {'json_string': response}) def show_actions_info(request): # response = json.dumps({"timestamp1": 22, "timestamp2": 14}) # temporary solution response = json.dumps({"there should be ": "error request"}) try: conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/actions") r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() print(response) except Exception as e: print("error") return render(request, "treeview_app/error_page.html") return render(request, "treeview_app/actions_info.html", {'json_string': response}) +def show_asserts_info(request): + response = json.dumps({"there should be ": "error request"}) + try: + conn = http.client.HTTPConnection("localhost:8080") + conn.request("GET", "/get/asserts") + r1 = conn.getresponse() + response = r1.read() # what will happen if response code will be not 200 + conn.close() + print(response) + except Exception as e: + print("error") + return render(request, "treeview_app/error_page.html") + return render(request, "treeview_app/asserts_info.html", {'asserts': response}) + def start_list(request): return render(request, 'treeview_app/start_page.html', {}) def getImageInfo(type, distribution, subsection, title): conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/images?type=" + type) r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() print("test1") response = response.decode("utf-8") print(type) decoded = json.loads(response) resultList = [[title, subsection], ] for x in distribution: # print(decoded[x][subsection]) resultList.append([x, decoded[x][subsection]]) print(type + "TYPE") return resultList def image_graphs(request): WIDTH_COUNT = 0 HEIGHT_COUNT = 1 NUMLAYERS_COUNT = 2 FILESIZE_COUNT = 3 COLORPROFILE_COUNT = 4 response = [[], [], [], [], []] try: response[WIDTH_COUNT] = getImageInfo( "width", ["L500", "L1000", "L2000", "L4000", "L8000", "M8000", "Unknown"], "Count", "Width") response[HEIGHT_COUNT] = getImageInfo("height", [ "L500", "L1000", "L2000", "L4000", "L8000", "M8000", "Unknown"], "Count", "Height") response[NUMLAYERS_COUNT] = getImageInfo("numlayers", [ "L1", "L2", "L4", "L8", "L16", "L32", "L64", "M64", "Unknown"], "Count", "Num layers") response[FILESIZE_COUNT] = getImageInfo("filesize", [ "Mb1", "Mb5", "Mb10", "Mb25", "Mb50", "Mb100", "Mb200", "Mb400", "Mb800", "More800", "Unknown"], "Count", "File size") response[COLORPROFILE_COUNT] = getImageInfo("colorprofile", [ "RGBA", "CMYK", "Grayscale", "XYZ", "YCbCr", "Lab", "Unknown"], "Count", "Color Profile") except Exception as e: print(e) return render(request, "treeview_app/error_page.html") # DataSource object data_source = [0, 0, 0, 0, 0] data_source[WIDTH_COUNT] = SimpleDataSource(data=response[WIDTH_COUNT]) data_source[HEIGHT_COUNT] = SimpleDataSource(data=response[HEIGHT_COUNT]) data_source[NUMLAYERS_COUNT] = SimpleDataSource( data=response[NUMLAYERS_COUNT]) data_source[FILESIZE_COUNT] = SimpleDataSource( data=response[FILESIZE_COUNT]) data_source[COLORPROFILE_COUNT] = SimpleDataSource( data=response[COLORPROFILE_COUNT]) # Chart objects chart = [0, 0, 0, 0, 0] chart[WIDTH_COUNT] = BarChart(data_source[WIDTH_COUNT]) chart[HEIGHT_COUNT] = BarChart(data_source[HEIGHT_COUNT]) chart[NUMLAYERS_COUNT] = BarChart(data_source[NUMLAYERS_COUNT]) chart[FILESIZE_COUNT] = BarChart(data_source[FILESIZE_COUNT]) chart[COLORPROFILE_COUNT] = BarChart(data_source[COLORPROFILE_COUNT]) context = {'chart': chart[WIDTH_COUNT], 'chart2': chart[HEIGHT_COUNT], "chart4": chart[NUMLAYERS_COUNT], "chart6": chart[FILESIZE_COUNT], "chart8": chart[COLORPROFILE_COUNT] } return render(request, 'treeview_app/image_graphs.html', context) def getInstallInfo(type, distribution, subsection, title): print("get installInfo") conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/install?type=" + type) r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() response = response.decode("utf-8") decoded = json.loads(response) print(decoded) resultList = [[title, subsection], ] for x in distribution: # print(decoded[x][subsection]) resultList.append([x, decoded[x][subsection]]) print(type + "TYPE") return resultList def install_graphs(request): OS_COUNT = 0 WINDOWS_COUNT = 1 LINUX_COUNT = 2 MAC_COUNT = 3 CPU_ARCHITECTURE_COUNT = 4 CPU_CORES_COUNT = 5 COMPILER_COUNT = 6 LOCALE_COUNT = 7 + ISINTEL_COUNT = 8 response = [] for i in range(8): response.append([]) print("DD") try: response[OS_COUNT] = getInstallInfo( "os", ["Windows", "Linux", "Mac", "Unknown"], "Count", "Os") response[WINDOWS_COUNT] = getInstallInfo("windows", [ "V7", "V8", "V81", "V10", "Other"], "Count", "Versions of Windows") response[LINUX_COUNT] = getInstallInfo("linux", [ "Ubuntu1404", "Ubuntu1410", "Ubuntu1504", "Ubuntu1510", "Ubuntu1604", "Ubuntu1610", "Ubuntu1704", "Other"], "Count", "Version of Linux") response[MAC_COUNT] = getInstallInfo("mac", [ "V1012", "Other"], "Count", "Versions of Macs") response[CPU_ARCHITECTURE_COUNT] = getInstallInfo("architecture", [ "X86_64", "X86", "Other", "Unknown"], "Count", "Kinds of architecture") response[CPU_CORES_COUNT] = getInstallInfo("cores", [ "C1", "C2", "C3", "C4", "C6", "C8", "Other", "Unknown"], "Count", "Number of cores") response[COMPILER_COUNT] = getInstallInfo("compiler", [ "GCC", "Clang", "MSVC", "Other", "Unknown"], "Count", "Compilers") response[LOCALE_COUNT] = getInstallInfo("locale", [ "English", "Russian", "Other", "Unknown"], "Count", "Locales") except Exception as e: print(e) return render(request, "treeview_app/error_page.html") # DataSource object data_source = [] for i in range(8): data_source.append([]) data_source[OS_COUNT] = SimpleDataSource(data=response[OS_COUNT]) data_source[WINDOWS_COUNT] = SimpleDataSource(data=response[WINDOWS_COUNT]) data_source[LINUX_COUNT] = SimpleDataSource( data=response[LINUX_COUNT]) data_source[MAC_COUNT] = SimpleDataSource( data=response[MAC_COUNT]) data_source[CPU_ARCHITECTURE_COUNT] = SimpleDataSource( data=response[CPU_ARCHITECTURE_COUNT]) data_source[CPU_CORES_COUNT] = SimpleDataSource( data=response[CPU_CORES_COUNT]) data_source[COMPILER_COUNT] = SimpleDataSource( data=response[COMPILER_COUNT]) data_source[LOCALE_COUNT] = SimpleDataSource( data=response[LOCALE_COUNT]) # Chart objects chart = [] for i in range(8): chart.append([]) chart[OS_COUNT] = BarChart(data_source[OS_COUNT]) chart[WINDOWS_COUNT] = BarChart(data_source[WINDOWS_COUNT]) chart[LINUX_COUNT] = BarChart(data_source[LINUX_COUNT]) chart[MAC_COUNT] = BarChart(data_source[MAC_COUNT]) chart[CPU_ARCHITECTURE_COUNT] = BarChart( data_source[CPU_ARCHITECTURE_COUNT]) chart[CPU_CORES_COUNT] = BarChart( data_source[CPU_CORES_COUNT]) chart[COMPILER_COUNT] = BarChart( data_source[COMPILER_COUNT]) chart[LOCALE_COUNT] = BarChart( data_source[LOCALE_COUNT]) context = {'chart': chart[OS_COUNT], 'chart1': chart[WINDOWS_COUNT], "chart2": chart[LINUX_COUNT], "chart3": chart[MAC_COUNT], "chart4": chart[CPU_ARCHITECTURE_COUNT], "chart5": chart[CPU_CORES_COUNT], "chart6": chart[COMPILER_COUNT], "chart7": chart[LOCALE_COUNT], } return render(request, 'treeview_app/install_graphs.html', context) def tools_table_use(request): table = ToolsTable(Tools.objects.all()) RequestConfig(request).configure(table) context = {'tools': table} return render(request, 'treeview_app/tools_table.html', context) def tools_table_activate(request): table = ToolsActivateTable(ToolsActivate.objects.all()) RequestConfig(request).configure(table) context = {'tools': table} return render(request, 'treeview_app/tools_table.html', context) def actions_table(request): table = ActionsTable(Actions.objects.all()) RequestConfig(request).configure(table) context = {'actions': table} return render(request, 'treeview_app/actions_table.html', context) def collectLargeData(): s = sched.scheduler(time.time, time.sleep) def collect(sc): print("collect data...") ToolsActivate.objects.all().delete() Tools.objects.all().delete() Actions.objects.all().delete() conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/tools") r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() response = response.decode("utf-8") decoded = json.loads(response) for x in decoded["ToolsActivate"]: # print(decoded[x][subsection]) dd = ToolsActivate(name=x["Name"], countUse=x["CountUse"], time = x["Time"]) dd.save() for x in decoded["ToolsUse"]: # print(decoded[x][subsection]) dd = Tools(name=x["Name"], countUse=x["CountUse"], time = x["Time"]) dd.save() #actions conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/actions") r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() response = response.decode("utf-8") decoded = json.loads(response) for x in decoded["Actions"]: # print(decoded[x][subsection]) dd = Actions(name=x["Name"], countUse=x["CountUse"]) dd.save() s.enter(3600, 1, collect, (sc,)) #updates every hour s.enter(0.1, 1, collect, (s,)) s.run() def collectLargeDataWrapper(): t = threading.Timer(10.0, collectLargeData) t.start()