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
cca2bbf7
Commit
cca2bbf7
authored
Apr 27, 2020
by
lvshibao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据更新
parent
26eb7051
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
data_update.py
tests/data_update.py
+39
-0
No files found.
tests/data_update.py
0 → 100644
View file @
cca2bbf7
import
os
from
inspect_report.cron
import
team_seat
os
.
environ
.
setdefault
(
"DJANGO_SETTINGS_MODULE"
,
"src.config.settings"
)
import
django
django
.
setup
()
from
datetime
import
datetime
from
dateutil.rrule
import
rrule
,
DAILY
from
src.inspect_report.models
import
RulesStat
,
SeatStat
,
ScoreStat
def
data_update_by_date
(
clazz
,
date
,
seat_code_team_name
):
create_date
=
date
agent_names
=
clazz
.
objects
.
filter
(
create_date
=
create_date
)
.
values_list
(
'agentName'
,
flat
=
True
)
.
distinct
()
total_count
=
0
for
agent_name
in
agent_names
:
count
=
clazz
.
objects
.
filter
(
create_date
=
create_date
,
agentName
=
agent_name
)
.
update
(
task
=
seat_code_team_name
.
get
(
agent_name
,
'未找到团队'
))
total_count
=
total_count
+
count
print
(
str
(
date
)
+
', 更新'
+
clazz
.
Meta
.
db_table
+
str
(
total_count
)
+
'个'
)
def
rule_seat_score_data_update
(
start_date
,
end_date
):
"""
数据细分后更新数据
:param start_date:
%
Y-
%
m-
%
d格式
:param end_date:
%
Y-
%
m-
%
d格式
:return:
"""
seat_code_team_name
=
team_seat
()
s_date
=
datetime
.
strptime
(
start_date
,
'
%
Y-
%
m-
%
d'
)
e_date
=
datetime
.
strptime
(
end_date
,
'
%
Y-
%
m-
%
d'
)
seed_dt
=
list
(
rrule
(
DAILY
,
byweekday
=
[
0
,
1
,
2
,
3
,
4
,
5
,
6
],
dtstart
=
s_date
,
until
=
e_date
))
for
date
in
seed_dt
:
for
clazz
in
(
RulesStat
,
SeatStat
,
ScoreStat
):
data_update_by_date
(
clazz
,
date
,
seat_code_team_name
)
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