summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongyuan Ma2018-08-08 08:09:51 +0000
committerHongyuan Ma2018-08-08 08:09:51 +0000
commit169fe430df64b8bd1ec0ca47294ebc34f6ed2adf (patch)
treed3b0b64b7871bb76852c4e36032a5914b5e3c153
parent50c6b444e6a71f8663653250c9fcee0e1eb0f838 (diff)
Detail optimization
-rw-r--r--client/post-example/results.json20
-rw-r--r--client/post-example/upload.py2
-rw-r--r--front-end/src/component/history-records-pane1/index.jsx6
-rw-r--r--front-end/src/component/userinfo-card/index.jsx11
-rw-r--r--front-end/src/page/detailInfo/index.css9
-rw-r--r--front-end/src/page/detailInfo/index.jsx46
-rw-r--r--front-end/src/page/portal/index.jsx10
-rw-r--r--front-end/src/service/user-service.jsx6
-rw-r--r--front-end/src/util/machine-record-table/index.jsx2
-rw-r--r--front-end/src/util/record-table/index.jsx2
-rw-r--r--web/apps/test_records/models.py21
-rw-r--r--web/apps/test_records/serializer.py16
-rw-r--r--web/apps/test_records/views.py12
-rw-r--r--web/apps/user_operation/serializer.py56
-rw-r--r--web/apps/user_operation/views.py8
-rw-r--r--web/apps/users/models.py5
-rw-r--r--web/apps/users/serializer.py5
-rw-r--r--web/db_tools/data/branch_data.py28
-rw-r--r--web/db_tools/import_branch_data.py4
-rw-r--r--web/db_tools/path.py1
-rw-r--r--web/pgperffarm/settings.py1
-rw-r--r--web/pgperffarm/urls.py2
22 files changed, 190 insertions, 83 deletions
diff --git a/client/post-example/results.json b/client/post-example/results.json
index c9863c1..ba57808 100644
--- a/client/post-example/results.json
+++ b/client/post-example/results.json
@@ -4,8 +4,8 @@
"10": {
"1": {
"std": 0.0,
- "metric": 10551.681364,
- "median": 10551.681364,
+ "metric": 30551.681364,
+ "median": 30551.681364,
"results": [
{
"latency": -1,
@@ -24,8 +24,8 @@
},
"2": {
"std": 0.0,
- "metric": 28238.312979,
- "median": 28238.312979,
+ "metric": 38238.312979,
+ "median": 38238.312979,
"results": [
{
"latency": -1,
@@ -44,8 +44,8 @@
},
"4": {
"std": 0.0,
- "metric": 25567.822014,
- "median": 25567.822014,
+ "metric": 35567.822014,
+ "median": 35567.822014,
"results": [
{
"latency": -1,
@@ -68,8 +68,8 @@
"10": {
"1": {
"std": 0.0,
- "metric": 216.508045,
- "median": 216.508045,
+ "metric": 116.508045,
+ "median": 116.508045,
"results": [
{
"latency": -1,
@@ -131,9 +131,9 @@
},
"postgres": {
"commit": "c6736ff76046521f56c50deb31da218bc1b29533",
- "branch": "master",
+ "branch": "rel_9_5_stable",
"settings": {
- "checkpoint_timeout": "15min",
+ "checkpoint_timeout": "20min",
"log_temp_files": "32",
"work_mem": "64MB",
"log_line_prefix": "%n %t ",
diff --git a/client/post-example/upload.py b/client/post-example/upload.py
index abc0052..467497c 100644
--- a/client/post-example/upload.py
+++ b/client/post-example/upload.py
@@ -14,7 +14,7 @@ def byteify(input):
return input
-token = 'fake token'
+token = '0ae27ecb064ff5283296b297bac77d9e'
# BASE_URL = 'http://140.211.168.111:8080/'
BASE_URL = 'http://127.0.0.1:8000/'
PATH_URL = 'upload/'
diff --git a/front-end/src/component/history-records-pane1/index.jsx b/front-end/src/component/history-records-pane1/index.jsx
index 608b3d0..ae28d8f 100644
--- a/front-end/src/component/history-records-pane1/index.jsx
+++ b/front-end/src/component/history-records-pane1/index.jsx
@@ -102,9 +102,9 @@ class HistoryRecordPane1 extends React.Component {
<div>
<div className="branch-tags-container">
{branch_tags}
- <div>
- current num: {this.state.currentTotal}
- </div>
+ {/*<div>*/}
+ {/*current num: {this.state.currentTotal}*/}
+ {/*</div>*/}
</div>
<MachineRecordTable list={this.state.currentList} total={this.state.currentTotal} current={this.state.currentPage} loadfunc={this.loadMachineRecordListByBranch}/>
diff --git a/front-end/src/component/userinfo-card/index.jsx b/front-end/src/component/userinfo-card/index.jsx
index 5381538..916dcae 100644
--- a/front-end/src/component/userinfo-card/index.jsx
+++ b/front-end/src/component/userinfo-card/index.jsx
@@ -21,22 +21,21 @@ class UserInfoCard extends React.Component {
<i className="fa fa-user"></i>&nbsp; Your Info
</h3>
<span className="panel-report-num">
- name: Maleic Acid
+ &nbsp; &nbsp;&nbsp; total reports: {userinfo.reports}
</span>
</div>
<div>
- <img className="user-avatar" src="http://s.gravatar.com/avatar/6ccc9d4e8fc9f75d253b5a28e05c11b8" alt=""/>
+ <img className="user-avatar" src={userinfo['avatar']} alt=""/>
</div>
</div>
<div className="panel-body userinfo-panel-body">
<p><strong>{userinfo.username}</strong></p>
<ul className="panel-body-ul">
- <li><i className="fa fa-desktop fa-fw"></i> {userinfo.machine_num}4 machine(s)</li>
- <li><i className="fa fa-file fa-fw"></i> {userinfo.reports}5 report(s)</li>
- <li><i className="fa fa-code-fork fa-fw"></i> {userinfo.branches}2 branch(es) involved</li>
- <li><i className="fa fa-envelope-o fa-fw"></i> <a href="mailto:[email protected]">[email protected]</a></li>
+ <li><i className="fa fa-desktop fa-fw"></i> {userinfo.machines} machine(s)</li>
+ <li><i className="fa fa-code-fork fa-fw"></i> {userinfo.involved} branch(es) involved</li>
+ <li><i className="fa fa-envelope-o fa-fw"></i> <a href={'mailto:'+userinfo.email}>{userinfo.email}</a></li>
</ul>
</div>
<div className="panel-footer clearfix">
diff --git a/front-end/src/page/detailInfo/index.css b/front-end/src/page/detailInfo/index.css
index 52c13a2..758664a 100644
--- a/front-end/src/page/detailInfo/index.css
+++ b/front-end/src/page/detailInfo/index.css
@@ -1,11 +1,14 @@
.record-title{
padding-left: 14px;
-}
-.record-title-top {
+ padding-right: 44px;
display: flex;
flex-direction: row;
+ justify-content:space-between;
+}
+.title-flex {
+ display: flex;
+ flex-direction: column;
justify-content:flex-start;
-
font-weight: 600;
}
diff --git a/front-end/src/page/detailInfo/index.jsx b/front-end/src/page/detailInfo/index.jsx
index 612331b..2a7bf6f 100644
--- a/front-end/src/page/detailInfo/index.jsx
+++ b/front-end/src/page/detailInfo/index.jsx
@@ -1,10 +1,13 @@
import React from 'react';
+import {Link} from 'react-router-dom';
import './index.css';
import {Table, Divider, Segment, Icon} from 'semantic-ui-react'
import PGUtil from 'util/util.jsx'
import FarmerCard from 'component/farmer-card/index.jsx'
import InfoList from 'component/info-list/index.jsx'
import Record from 'service/record-service.jsx'
+import PGConstant from 'util/constant.jsx'
+
const _util = new PGUtil();
const _record = new Record();
@@ -43,7 +46,9 @@ class DetailInfo extends React.Component {
}
render() {
+ let prev = this.state.recordInfo.prev || 'none';
let branch = this.state.recordInfo.branch || '';
+ let commit = this.state.recordInfo.commit || '';
let date = this.state.recordInfo.date || '';
let machine = this.state.recordInfo.test_machine || {};
let dataset = this.state.recordInfo.dataset_info || {};
@@ -53,19 +58,19 @@ class DetailInfo extends React.Component {
let hardware_info = this.state.recordInfo.hardware_info || {};
let ro = dataset.ro || {};
let rw = dataset.rw || {};
- console.log(machine)
+ // console.log(machine)
// Object.keys(obj).map(key => console.log(obj[key]));
let ro_10 = ro['10'] || {};
let rw_10 = rw['10'] || {};
let rw_tables = Object.keys(rw_10).map(key => {
- console.log(rw_10[key])
+ // console.log(rw_10[key])
let metric = 0;
let percentage = 0.0;
let status = -1;
let tableRow = rw_10[key].map((item, idx) => {
- console.log('item is:')
- console.log(item)
+ // console.log('item is:')
+ // console.log(item)
metric = parseFloat(item['metric']).toFixed(4)
percentage = (item['percentage'] * 100).toFixed(2).toString() + '%'
status = item['status']
@@ -102,7 +107,7 @@ class DetailInfo extends React.Component {
<Table.HeaderCell colSpan="4">
<div className="client-title-div">
<div>Client(s) {key}: {metric} {trend_span}</div>
- <div><a href=""> >>prev</a></div>
+ {/*<div><a href=""> >>prev</a></div>*/}
</div>
{/*<div>*/}
{/*<span>Improved ()</span>*/}
@@ -175,7 +180,7 @@ class DetailInfo extends React.Component {
<Table.HeaderCell colSpan="4">
<div className="client-title-div">
<div>Client(s) {key}: {metric} {trend_span}</div>
- <div><a href=""> >>prev</a></div>
+ {/*<div><a href=""> >>prev</a></div>*/}
</div>
{/*<div>*/}
{/*<span>Improved ()</span>*/}
@@ -203,15 +208,36 @@ class DetailInfo extends React.Component {
);
});
+ let prev_link
+ if(prev == 'none') {
+ prev_link = prev
+ }else{
+ prev_link = (
+ <Link target = '_blank' color='linkedin' to={'/detailInfo/' + prev}>
+ {prev.substring(0, 7)}
+ </Link>
+ )
+ }
return (
<div className="container-fluid detail-container">
- <div className="record-title">
+ <div className="record-title ">
+ <div className="record-title-right title-flex">
+ <div className="record-title-top">
+ <span>Branch: {branch}</span>
+ <span>Commit: <a target="_blank" href={ PGConstant.PG_GITHUB_MIRROR + commit}>{commit.substring(0, 7)}</a></span>
+ </div>
+ <div className="record-title-bottom">
+ <h2 >NO: {this.state.recordNo}</h2>
+ </div>
+ </div>
- <div className="record-title-top">
- <span>Branch: {branch}</span>
+ <div className="record-title-left title-flex">
<span>Date: {date}</span>
+ <span>
+ prev: {prev_link}
+ </span>
</div>
- <h2 >NO: {this.state.recordNo}</h2>
+
</div>
<div className="col-md-3">
diff --git a/front-end/src/page/portal/index.jsx b/front-end/src/page/portal/index.jsx
index b730709..e6ba7d7 100644
--- a/front-end/src/page/portal/index.jsx
+++ b/front-end/src/page/portal/index.jsx
@@ -38,7 +38,7 @@ class Portal extends React.Component {
let username = this.state.username
_user.getUserPortalInfo(username).then(res => {
this.setState({
- userinfo: res.results,
+ userinfo: res,
});
}, errMsg => {
_util.errorTips(errMsg);
@@ -64,12 +64,6 @@ class Portal extends React.Component {
// this.props.history.push('/login')
// hashHistory.push('/login')
window.location.href = '/';
- // _user.logout().then(res => {
- // _util.removeStorage('userInfo');
- // window.location.href = '/login';
- // }, errMsg => {
- // _util.errorTips(errMsg);
- // });
}
render() {
@@ -79,7 +73,7 @@ class Portal extends React.Component {
<div className="col-md-3">
{/*<Segment vertical>Farmer Info</Segment>*/}
- <UserInfoCard info={this.state.userinfo}></UserInfoCard>
+ <UserInfoCard userinfo={this.state.userinfo}></UserInfoCard>
<div className="panel panel-default panel-blue">
<div className="panel-heading">
diff --git a/front-end/src/service/user-service.jsx b/front-end/src/service/user-service.jsx
index b697142..4020bab 100644
--- a/front-end/src/service/user-service.jsx
+++ b/front-end/src/service/user-service.jsx
@@ -57,13 +57,11 @@ class User{
}
getUserPortalInfo(username=''){
- let url = PGConstant.base_url + '/portal/';
+ let url = PGConstant.base_url + '/user-portal/' + username;
return _util.request({
type : 'get',
url : url,
- data : {
- username : username
- }
+ data : {}
});
}
diff --git a/front-end/src/util/machine-record-table/index.jsx b/front-end/src/util/machine-record-table/index.jsx
index 91ef3d3..4cb03d2 100644
--- a/front-end/src/util/machine-record-table/index.jsx
+++ b/front-end/src/util/machine-record-table/index.jsx
@@ -144,7 +144,7 @@ class MachineRecordTable extends React.Component {
{/*<Icon name='chevron right'/>*/}
{/*</Menu.Item>*/}
{/*</Menu>*/}
- <Pagination style={style} onChange={(current) => this.onPageNumChange(current)} pageSize={2}
+ <Pagination style={style} onChange={(current) => this.onPageNumChange(current)} pageSize={20}
current={this.state.currentPage} total={this.props.total}/>
</Table.HeaderCell>
diff --git a/front-end/src/util/record-table/index.jsx b/front-end/src/util/record-table/index.jsx
index dc731cc..f9ae12f 100644
--- a/front-end/src/util/record-table/index.jsx
+++ b/front-end/src/util/record-table/index.jsx
@@ -204,7 +204,7 @@ class RecordTable extends React.Component {
<Table.Footer>
<Table.Row>
<Table.HeaderCell colSpan='10'>
- <Pagination style={style} onChange={(current) => this.onPageNumChange(current)} pageSize={2}
+ <Pagination style={style} onChange={(current) => this.onPageNumChange(current)} pageSize={20}
current={this.state.currentPage} total={this.state.total}/>
</Table.HeaderCell>
diff --git a/web/apps/test_records/models.py b/web/apps/test_records/models.py
index 2d9e2ad..f2dc376 100644
--- a/web/apps/test_records/models.py
+++ b/web/apps/test_records/models.py
@@ -10,8 +10,10 @@ class TestBranch(models.Model):
"""
test brand
"""
- branch_name = models.CharField(max_length=128, verbose_name="branch name", help_text="branch name")
- branch_order = models.IntegerField(verbose_name=" branch order", help_text="order in all the branch")
+ branch_name = models.CharField(max_length=128, unique=True,verbose_name="branch name", help_text="branch name")
+ branch_order = models.IntegerField(default=5,verbose_name=" branch order", help_text="order in all the branch")
+ is_show = models.BooleanField(verbose_name="branch isshow", default=True, help_text="branch isshow")
+ is_accept = models.BooleanField(verbose_name="branch weather accept accept new reports", default=True, help_text="branch weather accept new reports")
add_time = models.DateTimeField(default=timezone.now, verbose_name="branch added time",
help_text="branch added time")
@@ -188,25 +190,26 @@ def calc_status(sender, instance, **kwargs):
# record_id = instance.test_record.id
machine_id = instance.test_record.test_machine_id
add_time = instance.test_record.add_time
- prevRecord = TestRecord.objects.order_by('-add_time').filter(test_machine_id=machine_id,
+ branch = instance.test_record.branch
+ prevRecord = TestRecord.objects.order_by('-add_time').filter(test_machine_id=machine_id,branch=branch,
add_time__lt=add_time).first()
if (prevRecord == None):
print("prev record not found")
return
- print("previd is: " + str(prevRecord.id))
+ # print("previd is: " + str(prevRecord.id))
prevTestDataSet = TestDataSet.objects.filter(test_record_id=prevRecord.id, scale=instance.scale,
clients=instance.clients, test_cate_id=instance.test_cate_id).first()
if (prevTestDataSet == None):
- print("prev dataset not found")
+ # print("prev dataset not found")
return
- print("prev dataset is: " + str(prevTestDataSet.id))
+ # print("prev dataset is: " + str(prevTestDataSet.id))
percentage = (instance.metric - prevTestDataSet.metric) / prevTestDataSet.metric
- print('instance.metric is:' + str(instance.metric))
- print('prevTestDataSet.metric is:' + str(prevTestDataSet.metric))
- print('percentage is:' + str(percentage))
+ # print('instance.metric is:' + str(instance.metric))
+ # print('prevTestDataSet.metric is:' + str(prevTestDataSet.metric))
+ # print('percentage is:' + str(percentage))
status = 0
if (percentage >= 0.05):
status = 1
diff --git a/web/apps/test_records/serializer.py b/web/apps/test_records/serializer.py
index 574ab70..a57b54c 100644
--- a/web/apps/test_records/serializer.py
+++ b/web/apps/test_records/serializer.py
@@ -349,12 +349,24 @@ class TestRecordDetailSerializer(serializers.ModelSerializer):
dataset_info = serializers.SerializerMethodField()
- # rw_info = serializers.SerializerMethodField()
+ prev = serializers.SerializerMethodField()
class Meta:
model = TestRecord
fields = (
'branch', 'date', 'uuid', 'pg_info', 'linux_info', 'hardware_info', 'meta_info', 'dataset_info',
- 'test_desc', 'meta_time', 'test_machine')
+ 'test_desc', 'meta_time', 'test_machine', 'commit', 'prev')
+
+ def get_prev(self, obj):
+ target = TestDataSet.objects.filter(test_record_id=obj.id).first()
+ serializer = TestDataSetDetailSerializer(target)
+ prev = serializer.data["prev"]
+ target = TestDataSet.objects.filter(id=prev).first()
+ serializer = TestDataSetDetailSerializer(target)
+ record_id = serializer.data["test_record"]
+
+ target_record= TestRecord.objects.filter(id=record_id).first()
+ serializer = TestRecordDetailSerializer(target_record)
+ return serializer.data["uuid"]
def get_branch(self, obj):
branch = TestBranch.objects.filter(id=obj.branch_id).first()
diff --git a/web/apps/test_records/views.py b/web/apps/test_records/views.py
index 1e094b7..d09484b 100644
--- a/web/apps/test_records/views.py
+++ b/web/apps/test_records/views.py
@@ -28,7 +28,7 @@ import json
class StandardResultsSetPagination(PageNumberPagination):
- page_size = 2
+ page_size = 20
page_size_query_param = 'page_size'
max_page_size = 100
@@ -41,7 +41,7 @@ class TestBranchListViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
List test records
"""
- queryset = TestBranch.objects.all().order_by('branch_order')
+ queryset = TestBranch.objects.all().order_by('branch_order','add_time')
serializer_class = TestBranchSerializer
pagination_class = BigResultsSetPagination
@@ -58,10 +58,10 @@ class TestRecordListViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
class TestRecordListByBranchViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
"""
- List test records
+ List test records (/status)
"""
- queryset = TestRecord.objects.order_by('test_machine_id','-add_time').distinct('test_machine_id').all()
+ queryset = TestRecord.objects.order_by('test_machine__alias__name','-add_time').distinct('test_machine__alias__name').all()
serializer_class = TestRecordListSerializer
pagination_class = StandardResultsSetPagination
filter_backends = (django_filters.rest_framework.DjangoFilterBackend,)
@@ -162,9 +162,9 @@ def TestRecordCreate(request, format=None):
if(branch_str == 'master'):
branch_str = 'HEAD'
- branch = TestBranch.objects.filter(branch_name=branch_str).get()
+ branch = TestBranch.objects.filter(branch_name__iexact=branch_str,is_accept=True).get()
if not branch:
- raise TestDataUploadError('branch msg error')
+ raise TestDataUploadError('The branch name is unavailable.')
commit = pg_data['commit']
pg_settings = pg_data['settings']
diff --git a/web/apps/user_operation/serializer.py b/web/apps/user_operation/serializer.py
index 770b083..069c175 100644
--- a/web/apps/user_operation/serializer.py
+++ b/web/apps/user_operation/serializer.py
@@ -1,19 +1,54 @@
from django.db.models import Count
from rest_framework import serializers
-from pgperffarm.settings import DB_ENUM
+from pgperffarm.settings import DB_ENUM,AVATAR_URL
from test_records.serializer import TestRecordListSerializer
from users.serializer import AliasSerializer, UserMachineSerializer
from test_records.models import TestRecord
from users.models import UserMachine, Alias, UserProfile
import hashlib
-class UserPortalInfoSerializer(serializers.ModelSerializer):
+class UserPortalInfoSerializer(serializers.ModelSerializer):
involved = serializers.SerializerMethodField()
+ reports = serializers.SerializerMethodField()
+ machines = serializers.SerializerMethodField()
+ avatar = serializers.SerializerMethodField()
+ date_joined = serializers.SerializerMethodField()
+
class Meta:
model = UserProfile
- fields = ('email', 'involved', 'date_joined')
+ fields = ('email', 'involved', 'reports', 'date_joined', 'machines', 'avatar')
+
+ def date_joined(self, obj):
+ return obj.date_joined.strftime('%Y')
+
+ def get_avatar(self, obj):
+ email = obj.email
+ avatar = AVATAR_URL + hashlib.md5(email).hexdigest()
+ return avatar
+
+ def get_machines(self, obj):
+ '''
+ machines num
+ '''
+
+ return UserMachine.objects.filter(machine_owner_id=obj.id).count()
+
+ def get_reports(self, obj):
+ '''
+ reports num
+ '''
+ machine_dict = []
+ target_machines = UserMachine.objects.filter(machine_owner_id=obj.id)
+ serializer = UserMachineSerializer(target_machines, many=True)
+ # print(serializer.data)
+ for item in serializer.data:
+ machine_dict.append(item['machine_sn'])
+
+ reports = TestRecord.objects.filter(test_machine__machine_sn__in=machine_dict).count()
+
+ return reports
def get_involved(self, obj):
'''
@@ -22,13 +57,13 @@ class UserPortalInfoSerializer(serializers.ModelSerializer):
machine_dict = []
target_machines = UserMachine.objects.filter(machine_owner_id=obj.id)
serializer = UserMachineSerializer(target_machines, many=True)
- print(serializer.data)
- # for item in serializer.data:
- # machine_dict.append(item.id)
+ # print(serializer.data)
+ for item in serializer.data:
+ machine_dict.append(item['machine_sn'])
- reports = TestRecord.objects.filter(test_machine_id__in=machine_dict).count()
+ reports = TestRecord.objects.filter(test_machine__machine_sn__in=machine_dict).values_list('branch__branch_name').annotate(Count('id'))
+ return reports.count()
- return reports
class UserMachineManageSerializer(serializers.ModelSerializer):
'''
@@ -39,9 +74,12 @@ class UserMachineManageSerializer(serializers.ModelSerializer):
reports = serializers.SerializerMethodField()
lastest = serializers.SerializerMethodField()
state = serializers.SerializerMethodField()
+
class Meta:
model = UserMachine
- fields = ('alias', 'machine_sn','os_name', 'os_version', 'comp_name', 'comp_version', 'reports', 'state', 'lastest', 'state', 'add_time')
+ fields = (
+ 'alias', 'machine_sn', 'os_name', 'os_version', 'comp_name', 'comp_version', 'reports', 'state', 'lastest',
+ 'state', 'add_time')
def get_state(self, obj):
state_code = obj.state
diff --git a/web/apps/user_operation/views.py b/web/apps/user_operation/views.py
index c006723..0985349 100644
--- a/web/apps/user_operation/views.py
+++ b/web/apps/user_operation/views.py
@@ -16,7 +16,7 @@ from serializer import UserMachineManageSerializer, UserPortalInfoSerializer, Te
class StandardResultsSetPagination(PageNumberPagination):
- page_size = 2
+ page_size = 20
page_size_query_param = 'page_size'
max_page_size = 100
@@ -31,7 +31,7 @@ class UserMachineRecordByBranchListViewSet(mixins.ListModelMixin, viewsets.Gener
List machine records by branch
"""
- queryset = TestRecord.objects.all().order_by('add_time')
+ queryset = TestRecord.objects.all().order_by('-add_time')
serializer_class = TestRecordListSerializer
pagination_class = StandardResultsSetPagination
filter_backends = (django_filters.rest_framework.DjangoFilterBackend,)
@@ -69,7 +69,7 @@ class PublicMachineListViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
serializer_class = UserMachineManageSerializer
pagination_class = MiddleResultsSetPagination
-class UserPortalInfoViewSet( mixins.RetrieveModelMixin, viewsets.GenericViewSet):
+class UserPortalInfoViewSet(mixins.RetrieveModelMixin, viewsets.GenericViewSet):
"""
user info
"""
@@ -86,7 +86,7 @@ class UserMachinePermission(permissions.BasePermission):
def has_permission(self, request, view):
secret = request.META.get("HTTP_AUTHORIZATION")
- print(secret)
+ # print(secret)
# alias = request.data.alias
ret = UserMachine.objects.filter(machine_secret=secret, state=1).exists()
return ret
diff --git a/web/apps/users/models.py b/web/apps/users/models.py
index 669a419..35ed109 100644
--- a/web/apps/users/models.py
+++ b/web/apps/users/models.py
@@ -1,4 +1,5 @@
from datetime import datetime
+from django.utils.timezone import utc
import shortuuid
import hashlib
@@ -31,7 +32,7 @@ class UserProfile(AbstractUser):
return self.user_name
class Alias(models.Model):
- name = models.CharField(max_length=32, verbose_name="alias name")
+ name = models.CharField(max_length=32, unique=True, verbose_name="alias name")
is_used = models.BooleanField(default=False,verbose_name="is_used")
add_time = models.DateTimeField(default=timezone.now, verbose_name="add time", help_text="category added time")
@@ -44,7 +45,7 @@ class UserMachine(models.Model):
machine_sn = models.CharField(max_length=16, blank=True, default='',verbose_name="machine sn")
machine_secret = models.CharField(max_length=32, blank=True, default='', verbose_name="machine secret")
machine_owner = models.ForeignKey(UserProfile)
- alias = models.ForeignKey(Alias,blank=True, null=True, verbose_name="alias", help_text="alias")
+ alias = models.OneToOneField(Alias,blank=True, null=True, verbose_name="alias", help_text="alias")
os_name = models.CharField(max_length=32, verbose_name="operation system name")
os_version = models.CharField(max_length=32, verbose_name="operation system version")
comp_name = models.CharField(max_length=32, verbose_name="compiler name")
diff --git a/web/apps/users/serializer.py b/web/apps/users/serializer.py
index 553f456..1ef3ae2 100644
--- a/web/apps/users/serializer.py
+++ b/web/apps/users/serializer.py
@@ -1,5 +1,6 @@
from rest_framework import serializers
+from pgperffarm.settings import AVATAR_URL
from test_records.models import TestRecord
from users.models import UserMachine, Alias, UserProfile
import hashlib
@@ -44,8 +45,8 @@ class UserMachineSerializer(serializers.ModelSerializer):
def get_avatar(self, obj):
target_owner = UserProfile.objects.filter(id=obj.machine_owner_id).values('email').first()
- avatar = 'http://s.gravatar.com/avatar/' + hashlib.md5(target_owner['email']).hexdigest()
- print avatar
+
+ avatar = AVATAR_URL + hashlib.md5(target_owner['email']).hexdigest()
return avatar
class JWTUserProfileSerializer(serializers.ModelSerializer):
diff --git a/web/db_tools/data/branch_data.py b/web/db_tools/data/branch_data.py
index fdbe10d..f908c74 100644
--- a/web/db_tools/data/branch_data.py
+++ b/web/db_tools/data/branch_data.py
@@ -2,4 +2,32 @@ row_data = [
{
'branch_name': 'HEAD',
},
+ {
+ 'branch_name': 'REL_9_0_STABLE',
+ },
+ {
+ 'branch_name': 'REL_9_1_STABLE',
+ },
+ {
+ 'branch_name': 'REL_9_2_STABLE',
+ },
+ {
+ 'branch_name': 'REL_9_3_STABLE',
+ },
+ {
+ 'branch_name': 'REL_9_4_STABLE',
+ },
+ {
+ 'branch_name': 'REL_9_5_STABLE',
+ },
+ {
+ 'branch_name': 'REL_9_6_STABLE',
+ },
+ {
+ 'branch_name': 'REL_10_STABLE',
+ },
+ {
+ 'branch_name': 'REL_11_STABLE',
+ },
+
]
diff --git a/web/db_tools/import_branch_data.py b/web/db_tools/import_branch_data.py
index 67a61e7..c736cad 100644
--- a/web/db_tools/import_branch_data.py
+++ b/web/db_tools/import_branch_data.py
@@ -1,6 +1,6 @@
import sys
import os
-from pgperffarm.settings import PORJECT_PATH
+from path import PORJECT_PATH
# Use django's model independently
pwd = os.path.dirname(os.path.realpath(__file__))
sys.path.append(pwd)
@@ -18,4 +18,6 @@ from data.branch_data import row_data
for branch_item in row_data:
branch = TestBranch()
branch.branch_name = branch_item["branch_name"]
+ # branch.is_accept = True
+ # branch.is_show = True
branch.save() \ No newline at end of file
diff --git a/web/db_tools/path.py b/web/db_tools/path.py
new file mode 100644
index 0000000..984eaee
--- /dev/null
+++ b/web/db_tools/path.py
@@ -0,0 +1 @@
+PORJECT_PATH = 'D:\GitSpace\pgperffarm\web\pgperffarm'# 'D:\GitSpace\pgperffarm\web\pgperffarm' '/var/www/web/pgperffarm'
diff --git a/web/pgperffarm/settings.py b/web/pgperffarm/settings.py
index f5b3385..52c1987 100644
--- a/web/pgperffarm/settings.py
+++ b/web/pgperffarm/settings.py
@@ -157,6 +157,7 @@ REST_FRAMEWORK = {
'PAGE_SIZE': 20
}
+AVATAR_URL = 'http://s.gravatar.com/avatar/'
DB_ENUM = {
"general_switch": {
"on": 1,
diff --git a/web/pgperffarm/urls.py b/web/pgperffarm/urls.py
index 245faec..cf0ec7b 100644
--- a/web/pgperffarm/urls.py
+++ b/web/pgperffarm/urls.py
@@ -45,7 +45,7 @@ router.register(r'machine-records-by-branch', UserMachineRecordByBranchListViewS
# user's machine manage list
router.register(r'my-machine', UserMachineListViewSet, base_name="my-machine")
# get userinfo on portal page
-router.register(r'^portal/', UserPortalInfoViewSet, base_name="portal")
+router.register(r'user-portal', UserPortalInfoViewSet, base_name="user-portal")
urlpatterns = [
url(r'^perf_farm_admin/', admin.site.urls),