diff --git a/.gitignore b/.gitignore index 77ae454..539a427 100644 --- a/.gitignore +++ b/.gitignore @@ -1,48 +1,50 @@ .vscode debug nohup* *swp # Binaries for programs and plugins *.exe *.dll *.so *.dylib # Test binary, build with `go test -c` *.test # Output of the go coverage tool, specifically when used with LiteIDE *.out # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 .glide/ node_modules/ public/api *.idea/* +*.idea* +../.idea/ *.vscode *.log .travis.yml *.bak .tern-project public/build *.tmpl.js public/coverage *.swp frontend/public/assets/* #django *.egg-info *.pot *.py[co] .tox/ __pycache__ MANIFEST dist/ docs/_build/ docs/locale/ node_modules/ tests/coverage_html/ tests/.coverage build/ tests/report/ diff --git a/backend/goserver/goserver b/backend/goserver/goserver index 1be3c4d..c87ae09 100755 Binary files a/backend/goserver/goserver and b/backend/goserver/goserver differ diff --git a/backend/goserver/server/agregate/toolsInfo.go b/backend/goserver/server/agregate/toolsInfo.go index a80180e..fc19fa5 100644 --- a/backend/goserver/server/agregate/toolsInfo.go +++ b/backend/goserver/server/agregate/toolsInfo.go @@ -1,64 +1,65 @@ package agregate import ( "bufio" serv "kritaServers/backend/goserver/server" md "kritaServers/backend/goserver/server/models" "os" "gopkg.in/mgo.v2/bson" ) func countToolsUse(name string) (float64, float64) { resultsCount := []bson.M{} resultsAvg := []bson.M{} var countUse float64 var averageTimeUse float64 c := serv.Session.DB("telemetry").C("tools") pipe := c.Pipe([]bson.M{{"$unwind": "$tools"}, {"$match": bson.M{"tools.toolname": name}}, {"$group": bson.M{"_id": "$tools.toolname", "total_count": bson.M{"$sum": "$tools.countuse"}}}}) pipe2 := c.Pipe([]bson.M{{"$unwind": "$tools"}, {"$match": bson.M{"tools.toolname": name}}, {"$group": bson.M{"_id": "$tools.toolname", "total_count": bson.M{"$avg": "$tools.time"}}}}) resp := []bson.M{} resp2 := []bson.M{} err := pipe.All(&resp) err = pipe2.All(&resp2) serv.CheckErr(err) err = pipe.All(&resultsCount) err = pipe2.All(&resultsAvg) serv.CheckErr(err) if len(resultsCount) > 0 { countUse, _ = resultsCount[0]["total_count"].(float64) // fmt.Println(name, num) } if len(resultsAvg) > 0 { averageTimeUse, _ = resultsAvg[0]["total_count"].(float64) } return countUse, averageTimeUse } + func AgregateTools() { file, err := os.Open("list_tools.txt") serv.CheckErr(err) defer file.Close() var ToolUse md.ToolsCollected var ToolActivate md.ToolsCollected var ToolsUse []md.ToolsCollected var ToolsActivate []md.ToolsCollected scanner := bufio.NewScanner(file) for scanner.Scan() { ToolUse.Name = scanner.Text() - ToolUse.CountUse, _ = countToolsUse("/Use/" + ToolUse.Name) + ToolUse.CountUse, ToolUse.Time = countToolsUse("/Use/" + ToolUse.Name) ToolsUse = append(ToolsUse, ToolUse) ToolActivate.Name = ToolUse.Name - ToolActivate.CountUse, _ = countToolsUse("/Activate/" + ToolActivate.Name) - ToolsActivate = append(ToolsActivate, ToolUse) + ToolActivate.CountUse, ToolActivate.Time = countToolsUse("/Activate/" + ToolActivate.Name) + ToolsActivate = append(ToolsActivate, ToolActivate) } agregatedTools.ToolsActivate = ToolsActivate agregatedTools.ToolsUse = ToolsUse err = scanner.Err() serv.CheckErr(err) } diff --git a/backend/goserver/server/models/collectModel.go b/backend/goserver/server/models/collectModel.go index c37fa9b..1b47b97 100644 --- a/backend/goserver/server/models/collectModel.go +++ b/backend/goserver/server/models/collectModel.go @@ -1,156 +1,157 @@ package models type ActionCollected struct { CountUse float64 Name string } 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 } } 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/frontend/treeview/db.sqlite3 b/frontend/treeview/db.sqlite3 index a9ef1b3..a115283 100644 Binary files a/frontend/treeview/db.sqlite3 and b/frontend/treeview/db.sqlite3 differ diff --git a/frontend/treeview/treeview/settings.py b/frontend/treeview/treeview/settings.py index 2c84edd..6c25ce4 100644 --- a/frontend/treeview/treeview/settings.py +++ b/frontend/treeview/treeview/settings.py @@ -1,125 +1,126 @@ """ Django settings for treeview project. Generated by 'django-admin startproject' using Django 1.11.3. For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'h!khjr!+%c_7v5-^w)*x2*sy5e#0g^3dmzyt1@y0wtr6^x)uiq' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [ '.akapustin.me', # Allow domain and subdomains 'localhost', '127.0.0.1' ] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'treeview_app', - 'graphos' + 'graphos', + 'django_tables2' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'treeview.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'treeview.wsgi.application' # Database # https://docs.djangoproject.com/en/1.11/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/1.11/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'Europe/Moscow' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ STATIC_URL = '/static/' diff --git a/frontend/treeview/treeview_app/migrations/0001_initial.py b/frontend/treeview/treeview_app/migrations/0001_initial.py new file mode 100644 index 0000000..f49857a --- /dev/null +++ b/frontend/treeview/treeview_app/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.3 on 2017-08-16 14:28 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Tools', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('countUse', models.IntegerField()), + ], + ), + ] diff --git a/frontend/treeview/treeview_app/models.py b/frontend/treeview/treeview_app/migrations/__init__.py similarity index 100% copy from frontend/treeview/treeview_app/models.py copy to frontend/treeview/treeview_app/migrations/__init__.py diff --git a/frontend/treeview/treeview_app/models.py b/frontend/treeview/treeview_app/models.py index e69de29..9235651 100644 --- a/frontend/treeview/treeview_app/models.py +++ b/frontend/treeview/treeview_app/models.py @@ -0,0 +1,12 @@ +from django.db import models + + +class Tools(models.Model): + name = models.CharField(max_length=100) + time = models.FloatField() + countUse = models.IntegerField() + +class ToolsActivate(models.Model): + name = models.CharField(max_length=100) + time = models.FloatField() + countUse = models.IntegerField() diff --git a/frontend/treeview/treeview_app/static/django_tables2/bootstrap.css b/frontend/treeview/treeview_app/static/django_tables2/bootstrap.css new file mode 100644 index 0000000..80aaef2 --- /dev/null +++ b/frontend/treeview/treeview_app/static/django_tables2/bootstrap.css @@ -0,0 +1,8 @@ +.table-container th.asc:after { + content: '\0000a0\0025b2'; + float: right; +} +.table-container th.desc:after { + content: '\0000a0\0025bc'; + float: right; +} diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/css/screen.css b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/css/screen.css new file mode 100644 index 0000000..f0c6343 --- /dev/null +++ b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/css/screen.css @@ -0,0 +1,127 @@ +table.paleblue { + border-collapse: collapse; + border-color: #CCC; + border: 1px solid #DDD; +} + +table.paleblue, +table.paleblue + ul.pagination { + font: normal 11px/14px 'Lucida Grande', Verdana, Helvetica, Arial, sans-serif; +} + +table.paleblue a:link, +table.paleblue a:visited, +table.paleblue + ul.pagination > li > a { + color: #5B80B2; + text-decoration: none; + font-weight: bold; +} + +table.paleblue a:hover { + color: #036; +} + +table.paleblue td, +table.paleblue th { + padding: 5px; + line-height: 13px; + border-bottom: 1px solid #EEE; + border-left: 1px solid #DDD; + text-align: left; +} + +table.paleblue thead th:first-child, +table.paleblue thead td:first-child { + border-left: none !important; +} + +table.paleblue thead th, +table.paleblue thead td { + background: #FCFCFC url(../img/header-bg.png) left bottom repeat-x; + border-bottom: 1px solid #DDD; + padding: 2px 5px; + font-size: 11px; + vertical-align: middle; + color: #666; +} + +table.paleblue thead th > a:link, +table.paleblue thead th > a:visited { + color: #666; +} + +table.paleblue thead th.orderable > a { + padding-right: 20px; + background: url(../img/arrow-inactive-up.png) right center no-repeat; +} +table.paleblue thead th.orderable.asc > a { + background-image: url(../img/arrow-active-up.png); +} +table.paleblue thead th.orderable.desc > a { + background-image: url(../img/arrow-active-down.png); +} + +table.paleblue tr.odd { + background-color: #EDF3FE; +} + +table.paleblue tr.even { + background-color: white; +} + +table.paleblue + ul.pagination { + background: white url(../img/pagination-bg.gif) left 180% repeat-x; + overflow: auto; + margin: 0; + padding: 10px; + border: 1px solid #DDD; + list-style: none; +} + +table.paleblue + ul.pagination > li { + float: left; + line-height: 22px; + margin-left: 10px; +} + +table.paleblue + ul.pagination > li:first-child { + margin-left: 0; +} + +table.paleblue + ul.pagination > li.cardinality { + float: right; + color: #8d8d8d; +} + +table.paleblue > tbody > tr > td > span.true, +table.paleblue > tbody > tr > td > span.false { + background-position: top left; + background-repeat: no-repeat; + display: inline-block; + height: 10px; + overflow: hidden; + text-indent: -200px; + width: 10px; +} + +table.paleblue > tbody > tr > td > .missing { + background: transparent url(../img/missing.png) right center no-repeat; + color: #717171; + padding-right: 20px; +} + +table.paleblue > tbody > tr > td > .missing:hover { + color: #333; +} + +table.paleblue > tbody > tr > td > span.true { + background-image: url(../img/true.gif); +} + +table.paleblue > tbody > tr > td > span.false { + background-image: url(../img/false.gif); +} + +div.table-container { + display: inline-block; +} diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-active-down.png b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-active-down.png new file mode 100644 index 0000000..fbf6073 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-active-down.png differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-active-up.png b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-active-up.png new file mode 100644 index 0000000..e9b0e58 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-active-up.png differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-inactive-down.png b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-inactive-down.png new file mode 100644 index 0000000..0c16ab3 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-inactive-down.png differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-inactive-up.png b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-inactive-up.png new file mode 100644 index 0000000..d3f3245 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-inactive-up.png differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/false.gif b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/false.gif new file mode 100644 index 0000000..1b4ee58 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/false.gif differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/header-bg.png b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/header-bg.png new file mode 100644 index 0000000..c0d2027 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/header-bg.png differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/missing.png b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/missing.png new file mode 100644 index 0000000..aa3c8ab Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/missing.png differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/pagination-bg.gif b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/pagination-bg.gif new file mode 100644 index 0000000..f8402b8 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/pagination-bg.gif differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/true.gif b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/true.gif new file mode 100644 index 0000000..7399282 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/true.gif differ diff --git a/frontend/treeview/treeview_app/tables.py b/frontend/treeview/treeview_app/tables.py new file mode 100644 index 0000000..2223669 --- /dev/null +++ b/frontend/treeview/treeview_app/tables.py @@ -0,0 +1,15 @@ +import django_tables2 as tables +from .models import Tools +from .models import ToolsActivate + +class ToolsTable(tables.Table): + class Meta: + model = Tools + # add class="paleblue" to
+ | + + | ++ + | +