Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
inspect_report
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengjinlei
inspect_report
Commits
dffa83a1
Commit
dffa83a1
authored
Dec 19, 2019
by
zhengjinlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保留2位小数
parent
410c43a0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
tasksapi.py
src/inspect_report/api/tasksapi.py
+7
-6
models.py
src/inspect_report/models.py
+7
-0
No files found.
src/inspect_report/api/tasksapi.py
View file @
dffa83a1
...
@@ -5,7 +5,7 @@ from rest_framework import viewsets
...
@@ -5,7 +5,7 @@ from rest_framework import viewsets
from
rest_framework.decorators
import
action
from
rest_framework.decorators
import
action
from
rest_framework.request
import
Request
from
rest_framework.request
import
Request
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
inspect_report.models
import
Tasks
,
CheckSession
,
RulesStat
,
SeatStat
,
ScoreStat
from
inspect_report.models
import
Tasks
,
CheckSession
,
RulesStat
,
SeatStat
,
ScoreStat
,
Round
import
json
import
json
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
config.config
import
TABLE_PRE
from
config.config
import
TABLE_PRE
...
@@ -426,9 +426,9 @@ class TasksApi(viewsets.ViewSet):
...
@@ -426,9 +426,9 @@ class TasksApi(viewsets.ViewSet):
task_condition
[
'agentName'
]
=
agent_name
task_condition
[
'agentName'
]
=
agent_name
# , 'total_session', 'validate_num', 'validate_session', 'validate_zero'
# , 'total_session', 'validate_num', 'validate_session', 'validate_zero'
rules
=
ScoreStat
.
objects
.
filter
(
**
task_condition
)
.
extra
(
select
=
{
'area'
:
"task"
,
'agentName'
:
'agentName'
})
\
rules
=
ScoreStat
.
objects
.
filter
(
**
task_condition
)
.
extra
(
select
=
{
'area'
:
"task"
,
'agentName'
:
'agentName'
})
\
.
values
(
'area'
,
'agentName'
)
.
annotate
(
avg_score_svc
=
Avg
(
'service_score'
),
.
values
(
'area'
,
'agentName'
)
.
annotate
(
avg_score_svc
=
Round
(
Avg
(
'service_score'
),
2
),
avg_score_bus
=
Avg
(
'business_score'
),
avg_score_bus
=
Round
(
Avg
(
'business_score'
),
2
),
avg_score
=
Avg
(
'score'
),
total_session
=
Sum
(
'total_session'
),
avg_score
=
Round
(
Avg
(
'score'
),
2
),
total_session
=
Sum
(
'total_session'
),
validate_num
=
Sum
(
'validate_num'
),
validate_zero
=
Sum
(
'validate_zero'
))
\
validate_num
=
Sum
(
'validate_num'
),
validate_zero
=
Sum
(
'validate_zero'
))
\
.
order_by
(
sort
)
.
order_by
(
sort
)
paginator
=
Paginator
(
rules
,
page_size
)
paginator
=
Paginator
(
rules
,
page_size
)
...
@@ -550,8 +550,9 @@ class TasksApi(viewsets.ViewSet):
...
@@ -550,8 +550,9 @@ class TasksApi(viewsets.ViewSet):
if
task_id
:
if
task_id
:
task_condition
[
'task'
]
=
task_id
task_condition
[
'task'
]
=
task_id
rules
=
ScoreStat
.
objects
.
filter
(
**
task_condition
)
.
extra
(
select
=
{
'area'
:
"task"
})
\
rules
=
ScoreStat
.
objects
.
filter
(
**
task_condition
)
.
extra
(
select
=
{
'area'
:
"task"
})
\
.
values
(
'area'
)
.
annotate
(
avg_score_svc
=
Avg
(
'service_score'
),
avg_score_bus
=
Avg
(
'business_score'
),
.
values
(
'area'
)
.
annotate
(
avg_score_svc
=
Round
(
Avg
(
'service_score'
),
2
),
avg_score
=
Avg
(
'score'
),
total_session
=
Sum
(
'total_session'
),
avg_score_bus
=
Round
(
Avg
(
'business_score'
),
2
),
avg_score
=
Round
(
Avg
(
'score'
),
2
),
total_session
=
Sum
(
'total_session'
),
validate_num
=
Sum
(
'validate_num'
),
validate_zero
=
Sum
(
'validate_zero'
))
\
validate_num
=
Sum
(
'validate_num'
),
validate_zero
=
Sum
(
'validate_zero'
))
\
.
order_by
(
sort
)
.
order_by
(
sort
)
paginator
=
Paginator
(
rules
,
page_size
)
paginator
=
Paginator
(
rules
,
page_size
)
...
...
src/inspect_report/models.py
View file @
dffa83a1
...
@@ -2,6 +2,9 @@ from django.db import models
...
@@ -2,6 +2,9 @@ from django.db import models
# Create your models here.
# Create your models here.
from
django.db.models
import
Func
class
Tasks
(
models
.
Model
):
class
Tasks
(
models
.
Model
):
name
=
models
.
CharField
(
'任务名称'
,
null
=
True
,
max_length
=
50
,
db_index
=
True
)
name
=
models
.
CharField
(
'任务名称'
,
null
=
True
,
max_length
=
50
,
db_index
=
True
)
type
=
models
.
IntegerField
(
'任务分类'
,
default
=
1
)
type
=
models
.
IntegerField
(
'任务分类'
,
default
=
1
)
...
@@ -130,3 +133,7 @@ class CheckSession(models.Model):
...
@@ -130,3 +133,7 @@ class CheckSession(models.Model):
}
}
return
type
(
table_name
,
(
Class
,),
attrs
)
return
type
(
table_name
,
(
Class
,),
attrs
)
class
Round
(
Func
):
function
=
'ROUND'
arity
=
2
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment