Detail optimization
authorHongyuan Ma <CS_MaleicAcid@163.com>
Wed, 8 Aug 2018 08:09:51 +0000 (16:09 +0800)
committerHongyuan Ma <CS_MaleicAcid@163.com>
Wed, 8 Aug 2018 08:09:51 +0000 (16:09 +0800)
22 files changed:
client/post-example/results.json
client/post-example/upload.py
front-end/src/component/history-records-pane1/index.jsx
front-end/src/component/userinfo-card/index.jsx
front-end/src/page/detailInfo/index.css
front-end/src/page/detailInfo/index.jsx
front-end/src/page/portal/index.jsx
front-end/src/service/user-service.jsx
front-end/src/util/machine-record-table/index.jsx
front-end/src/util/record-table/index.jsx
web/apps/test_records/models.py
web/apps/test_records/serializer.py
web/apps/test_records/views.py
web/apps/user_operation/serializer.py
web/apps/user_operation/views.py
web/apps/users/models.py
web/apps/users/serializer.py
web/db_tools/data/branch_data.py
web/db_tools/import_branch_data.py
web/db_tools/path.py [new file with mode: 0644]
web/pgperffarm/settings.py
web/pgperffarm/urls.py

index c9863c1a989bb4d735d11bcca2d9a9b00b6005cc..ba57808e62d72e8e34cf9b91d0f9d47471b21590 100644 (file)
@@ -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, 
     }, 
     "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 ", 
index abc005245158252422f63cf57eab408bd4512d1c..467497cd09ffe12009852ab3b1e01de234ce0be2 100644 (file)
@@ -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/'
index 608b3d06fc733008890dd1ee8982730fb83a4bc6..ae28d8ffcfc4db143401dd8c383fa10b542482c6 100644 (file)
@@ -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}/>
index 538153829b9ff0299c6fbac8317e5c8a2a78271b..916dcae2a4cd1724c36c8b7ea3f4e1942448e837 100644 (file)
@@ -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:mahongyuan1997@gmail.com">mahongyuan@gmail.com</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">
index 52c13a2a440dab6e335e40110c1a7a16e119aec9..758664a90e3a5ad07d7ce788cb13bfceb31ece7e 100644 (file)
@@ -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;
 }
 
index 612331ba81299bfaf8233ba9b35e7e10ee437da7..2a7bf6fbb96b9676210131b492a972eec86934bc 100644 (file)
@@ -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">
index b730709699078280a9da13f6544398c9ed58faf5..e6ba7d75b1489b36f506f81c04766f4d136f0978 100644 (file)
@@ -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">
index b6971429444f584833c76f868aa64aeb1d2364c8..4020bab65d2a42934fd5e00827968a728f367142 100644 (file)
@@ -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    : {}
         });
     }
 
index 91ef3d33f7d3e79717640bd2f6dfed78d3d5cbd9..4cb03d27eb9837d6e74daa4f228f9e3bdb427f67 100644 (file)
@@ -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>
index dc731cce365fa91f981588ed23f0bdf3e72a6530..f9ae12f3e4638ea909a08bb6f19ed559da62a910 100644 (file)
@@ -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>
index 2d9e2ad768a3d173ba12f945f57c3e6e16cdb93f..f2dc376e8147b8420dfcbcceb13e3ef6e3439f76 100644 (file)
@@ -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
index 574ab70bb2b33dd381cda7aae7f8c48b1eccb88c..a57b54c1dc9f9ea8403c7a16425309316233b7b8 100644 (file)
@@ -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()
index 1e094b73ff539367f03055b06a6cbca7286488d9..d09484b7cb615e7fdb91bf73733af6e7eb6bf600 100644 (file)
@@ -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']
index 770b083428bc745c063aec3553ffc2004b110c85..069c1756e87a0b77f1f3d4fae74f20ef38335b58 100644 (file)
@@ -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
index c006723e72f9bd63043b3b858c9a4009bf15ee36..0985349545c72b5647c597744d86b3e0a3da79d8 100644 (file)
@@ -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
index 669a419f2e68e1eee99cc6177fd577b85572d04a..35ed109b8557a338943d74806510092b1b2f8ad7 100644 (file)
@@ -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")
index 553f456001287c9a43c8d62371eb19e5a1ad3fbf..1ef3ae21640198281406d5325531e2ac36b6e8a6 100644 (file)
@@ -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):
index fdbe10d04823c3a545a50a57bbed2582e8f55f11..f908c7434e0df7bbb12fa4f99d8c3c37acd591eb 100644 (file)
@@ -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',
+    },
+
 ]
index 67a61e71902ae1819242da5414e90e0dbd6d38ae..c736cad1a4ff7cb02ed3155274862f7de2a69096 100644 (file)
@@ -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 (file)
index 0000000..984eaee
--- /dev/null
@@ -0,0 +1 @@
+PORJECT_PATH = 'D:\GitSpace\pgperffarm\web\pgperffarm'# 'D:\GitSpace\pgperffarm\web\pgperffarm' '/var/www/web/pgperffarm'
index f5b3385178d5d500d223cbf4d26dd18bd3e61a5d..52c19870426c12ee2bea9c6aa5d27ffef62a87fe 100644 (file)
@@ -157,6 +157,7 @@ REST_FRAMEWORK = {
     'PAGE_SIZE': 20
 }
 
+AVATAR_URL = 'http://s.gravatar.com/avatar/'
 DB_ENUM = {
     "general_switch": {
         "on": 1,
index 245faec6e9abaf10064db473aecca06921733bd1..cf0ec7b158a8c1403dfd8a31a386ed328ac27a6f 100644 (file)
@@ -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),