Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
8c8ef0db
Commit
8c8ef0db
authored
Jul 01, 2015
by
Dipo Olaitan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dates for x-axis of Utilization Charts and Cleaner code
parent
a395a1d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
42 deletions
+26
-42
dream/plugins/CapacityStations/CapacityAllocationByPeriod.py
dream/plugins/CapacityStations/CapacityAllocationByPeriod.py
+20
-20
dream/plugins/CapacityStations/CapacityProjectOperationUtilization.py
...s/CapacityStations/CapacityProjectOperationUtilization.py
+6
-22
No files found.
dream/plugins/CapacityStations/CapacityAllocationByPeriod.py
View file @
8c8ef0db
from
dream.plugins
import
plugin
from
dream.plugins.TimeSupport
import
TimeSupportMixin
from
datetime
import
datetime
,
timedelta
from
copy
import
deepcopy
class
StationAllocations
(
plugin
.
OutputPreparationPlugin
,
TimeSupportMixin
):
""" Output the
queue statistics in a format compatible with Output_viewGraph, for the second widget by week.
""" Output the
periodic operational capacity utilisation per project in a bar chart
"""
def
postprocess
(
self
,
data
):
startPeriod
=
datetime
.
strptime
(
data
[
'general'
][
'currentDate'
],
data
[
'general'
][
'dateFormat'
])
for
result
in
data
[
'result'
][
'result_list'
]:
#result = data['result']['result_list'][0]
bottleNeckUtilizationDict
=
result
[
'bottleneck_utilization_by_week'
]
=
{}
operationNames
=
[]
byPeriod
=
dict
((
period
,{})
for
period
in
range
(
len
(
result
[
'elementList'
][
10
][
'results'
][
'capacityUsed'
])))
for
station
in
result
[
'elementList'
]:
if
station
.
get
(
'family'
)
==
'CapacityStation'
:
byPeriod
=
dict
((
period
,{})
for
period
in
range
(
len
(
station
[
'results'
][
'capacityUsed'
])))
break
opNo
=
0
for
recd
in
result
[
'elementList'
]:
if
recd
.
get
(
'family'
)
==
'CapacityStation'
:
operationNames
.
append
(
recd
.
get
(
'id'
))
projectNames
=
list
(
set
([
rc
[
'project'
]
for
rc
in
recd
[
'results'
][
'detailedWorkPlan'
]]))
for
p
rd
,
pln
in
enumerate
(
recd
[
'results'
][
'capacityUsed'
]):
totalCapa
=
max
(
0.01
,
sum
([
pln
.
setdefault
(
project
,
0
)
for
project
in
projectNames
]))
totalUtilization
=
pln
[
"utilization"
]
for
station
in
result
[
'elementList'
]:
if
station
.
get
(
'family'
)
==
'CapacityStation'
:
operationNames
.
append
(
station
.
get
(
'id'
))
projectNames
=
list
(
set
([
rc
[
'project'
]
for
rc
in
station
[
'results'
][
'detailedWorkPlan'
]]))
for
p
eriod
,
record
in
enumerate
(
station
[
'results'
][
'capacityUsed'
]):
totalCapa
=
max
(
0.01
,
sum
([
record
.
setdefault
(
project
,
0
)
for
project
in
projectNames
]))
totalUtilization
=
record
[
"utilization"
]
for
pr
in
projectNames
:
if
pr
in
byPeriod
[
p
rd
]:
#byPeriod[pr
d]:
byPeriod
[
p
rd
][
pr
].
append
([
opNo
,(
pln
.
setdefault
(
pr
,
0
)
/
totalCapa
*
totalUtilization
)])
if
pr
in
byPeriod
[
p
erio
d
]:
byPeriod
[
p
eriod
][
pr
].
append
([
opNo
,(
record
.
setdefault
(
pr
,
0
)
/
totalCapa
*
totalUtilization
)])
else
:
byPeriod
[
p
rd
][
pr
]
=
[[
opNo
,(
pln
.
setdefault
(
pr
,
0
)
/
totalCapa
*
totalUtilization
)]]
byPeriod
[
p
eriod
][
pr
]
=
[[
opNo
,(
record
.
setdefault
(
pr
,
0
)
/
totalCapa
*
totalUtilization
)]]
opNo
+=
1
for
pd
in
byPeriod
:
for
p
r
d
in
byPeriod
:
series
=
[]
currentPeriod
=
str
(
startPeriod
+
timedelta
(
days
=
pd
))[:
10
]
#ticks = [[num,oprtn] for num,oprtn in enumerate(operationNames)]
currentPeriod
=
str
(
startPeriod
+
timedelta
(
days
=
prd
))[:
10
]
ticks
=
list
(
enumerate
(
operationNames
))
options
=
{
"xaxis"
:
{
"minTickSize"
:
1
,
"ticks"
:
ticks
},
"series"
:
{
"bars"
:
{
"show"
:
True
,
"barWidth"
:
0.10
,
"order"
:
1
,
"align"
:
"center"
},
"stack"
:
False
}}
bottleNeckUtilizationDict
[
currentPeriod
]
=
{
"series"
:
series
,
"options"
:
options
}
for
pj
in
byPeriod
[
pd
]:
series
.
append
({
"label"
:
pj
,
"data"
:
byPeriod
[
pd
][
pj
]})
for
pj
in
byPeriod
[
p
r
d
]:
series
.
append
({
"label"
:
pj
,
"data"
:
byPeriod
[
p
r
d
][
pj
]})
return
data
dream/plugins/CapacityStations/CapacityProjectOperationUtilization.py
View file @
8c8ef0db
...
...
@@ -4,7 +4,7 @@ from datetime import datetime, timedelta
from
copy
import
deepcopy
class
PeriodUtilizations
(
plugin
.
OutputPreparationPlugin
,
TimeSupportMixin
):
""" Output
the queue statistics in a format compatible with Output_viewGraph, for the second widget by week
.
""" Output
a line plot of operational capacity utilisations
.
"""
def
postprocess
(
self
,
data
):
...
...
@@ -12,37 +12,21 @@ class PeriodUtilizations(plugin.OutputPreparationPlugin, TimeSupportMixin):
startPeriod
=
datetime
.
strptime
(
data
[
'general'
][
'currentDate'
],
data
[
'general'
][
'dateFormat'
])
for
result
in
data
[
'result'
][
'result_list'
]:
self
.
initializeTimeSupport
(
data
)
#bottleNeckUtilizationDict = result['capacity_utilization'] = {}
operationNames
=
[]
byPeriod
=
dict
((
period
,{})
for
period
in
range
(
len
(
result
[
'elementList'
][
10
][
'results'
][
'capacityUsed'
])))
opNo
=
0
operationUtil
=
{}
for
recd
in
result
[
'elementList'
]:
if
recd
.
get
(
'family'
)
==
'CapacityStation'
:
operationNames
.
append
(
recd
.
get
(
'id'
))
operationUtil
[
recd
.
get
(
'id'
)]
=
[]
#projectNames = list(set([rc['project'] for rc in recd['results']['detailedWorkPlan']]))
for
prd
,
pln
in
enumerate
(
recd
[
'results'
][
'capacityUsed'
]):
currentPeriod
=
str
(
startPeriod
+
timedelta
(
days
=
prd
))[:
10
]
#totalCapa = max(0.01,sum([pln.setdefault(project,0) for project in projectNames]))
totalUtilization
=
pln
[
"utilization"
]
operationUtil
[
recd
.
get
(
'id'
)].
append
([
prd
,
pln
[
"utilization"
]])
ticks
=
[
lb
[
0
]
for
lb
in
operationUtil
[
recd
.
get
(
'id'
)]]
currentPeriod
=
startPeriod
+
timedelta
(
days
=
prd
)
timestamp
=
(
currentPeriod
-
datetime
(
1970
,
1
,
1
)).
total_seconds
()
operationUtil
[
recd
.
get
(
'id'
)].
append
([
timestamp
*
1000
,
pln
[
"utilization"
]])
series
=
[]
options
=
{
"xaxis"
:
{
"
ticks"
:
ticks
,
"minTickSize"
:
[
1
,
self
.
getTimeUnitText
()]}}
options
=
{
"xaxis"
:
{
"
mode"
:
"time"
,
"minTickSize"
:
[
1
,
self
.
getTimeUnitText
()]}}
result
[
'capacity_utilization'
]
=
{
"series"
:
series
,
"options"
:
options
}
for
operation
in
operationUtil
:
series
.
append
({
"label"
:
operation
,
"data"
:
operationUtil
[
operation
]})
#currentPeriod = str(startPeriod + timedelta(days=pd))[:10]
#ticks = [[num,oprtn] for num,oprtn in enumerate(operationNames)]
#label = operation
#ticks = list(enumerate(operationNames))
#options = {"xaxis": {"minTickSize": 1,"ticks": ticks},"series": {"bars": {"show": True,"barWidth": 0.10,"order": 1,"align": "center"},"stack": False}}
#bottleNeckUtilizationDict = {"series": series,"options": options}
#for pj in byPeriod[pd]:
#series.append({"label":operation,"data": operationUtil[operation]})
return
data
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