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
abdb3aa1
Commit
abdb3aa1
authored
Feb 26, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Capacity project plugins: postprocess all results, not only the last one
parent
c036000b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
133 additions
and
131 deletions
+133
-131
dream/plugins/CapacityProjectGantt.py
dream/plugins/CapacityProjectGantt.py
+38
-37
dream/plugins/CapacityProjectStationUtilization.py
dream/plugins/CapacityProjectStationUtilization.py
+44
-44
dream/plugins/CapacityStationGantt.py
dream/plugins/CapacityStationGantt.py
+51
-50
No files found.
dream/plugins/CapacityProjectGantt.py
View file @
abdb3aa1
...
@@ -14,41 +14,42 @@ class CapacityProjectGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
...
@@ -14,41 +14,42 @@ class CapacityProjectGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
data
[
'general'
][
'dateFormat'
]
=
'%Y/%m/%d'
data
[
'general'
][
'dateFormat'
]
=
'%Y/%m/%d'
self
.
initializeTimeSupport
(
data
)
self
.
initializeTimeSupport
(
data
)
date_format
=
'%d-%m-%Y %H:%M'
date_format
=
'%d-%m-%Y %H:%M'
resultElements
=
data
[
'result'
][
'result_list'
][
-
1
][
'elementList'
]
task_dict
=
{}
for
result
in
data
[
'result'
][
'result_list'
]:
# loop in the results to find CapacityProjects
resultElements
=
result
[
'elementList'
]
for
element
in
resultElements
:
task_dict
=
{}
if
element
[
'_class'
]
==
"Dream.CapacityProject"
:
# loop in the results to find CapacityProjects
# add the project in the task_dict
for
element
in
resultElements
:
task_dict
[
element
[
'id'
]]
=
dict
(
if
element
[
'_class'
]
==
"Dream.CapacityProject"
:
id
=
element
[
'id'
],
# add the project in the task_dict
text
=
'Project %s'
%
element
[
'id'
],
task_dict
[
element
[
'id'
]]
=
dict
(
type
=
'project'
,
id
=
element
[
'id'
],
open
=
False
)
text
=
'Project %s'
%
element
[
'id'
],
type
=
'project'
,
# loop in the project schedule to create the sub-tasks
open
=
False
)
projectSchedule
=
element
[
'results'
].
get
(
'schedule'
,{})
# loop in the project schedule to create the sub-tasks
for
record
in
projectSchedule
:
projectSchedule
=
element
[
'results'
].
get
(
'schedule'
,{})
task_dict
[
element
[
'id'
]
+
record
[
'stationId'
]]
=
dict
(
id
=
element
[
'id'
]
+
record
[
'stationId'
],
for
record
in
projectSchedule
:
parent
=
element
[
'id'
],
task_dict
[
element
[
'id'
]
+
record
[
'stationId'
]]
=
dict
(
text
=
record
[
'stationId'
],
id
=
element
[
'id'
]
+
record
[
'stationId'
],
start_date
=
self
.
convertToRealWorldTime
(
parent
=
element
[
'id'
],
record
[
'entranceTime'
]).
strftime
(
date_format
),
text
=
record
[
'stationId'
],
stop_date
=
self
.
convertToRealWorldTime
(
start_date
=
self
.
convertToRealWorldTime
(
record
[
'exitTime'
]).
strftime
(
date_format
),
record
[
'entranceTime'
]).
strftime
(
date_format
),
open
=
False
,
stop_date
=
self
.
convertToRealWorldTime
(
duration
=
int
(
record
[
'exitTime'
])
-
int
(
record
[
'entranceTime'
]),
record
[
'exitTime'
]).
strftime
(
date_format
),
entranceTime
=
record
[
'entranceTime'
]
open
=
False
,
)
duration
=
int
(
record
[
'exitTime'
])
-
int
(
record
[
'entranceTime'
]),
entranceTime
=
record
[
'entranceTime'
]
# return the result to the gadget
)
result
=
data
[
'result'
][
'result_list'
][
-
1
]
result
[
self
.
configuration_dict
[
'output_id'
]]
=
dict
(
# return the result to the gadget
time_unit
=
self
.
getTimeUnitText
(),
result
[
self
.
configuration_dict
[
'output_id'
]]
=
dict
(
task_list
=
sorted
(
task_dict
.
values
(),
time_unit
=
self
.
getTimeUnitText
(),
key
=
lambda
task
:
(
task
.
get
(
'parent'
),
task_list
=
sorted
(
task_dict
.
values
(),
task
.
get
(
'type'
)
==
'project'
,
key
=
lambda
task
:
(
task
.
get
(
'parent'
),
task
.
get
(
'entranceTime'
),
task
.
get
(
'id'
))))
task
.
get
(
'type'
)
==
'project'
,
task
.
get
(
'entranceTime'
),
task
.
get
(
'id'
))))
return
data
return
data
dream/plugins/CapacityProjectStationUtilization.py
View file @
abdb3aa1
...
@@ -6,52 +6,52 @@ class CapacityProjectStationUtilization(plugin.OutputPreparationPlugin):
...
@@ -6,52 +6,52 @@ class CapacityProjectStationUtilization(plugin.OutputPreparationPlugin):
"""
"""
def
postprocess
(
self
,
data
):
def
postprocess
(
self
,
data
):
result
=
data
[
'result'
][
'result_list'
][
-
1
]
for
result
in
data
[
'result'
][
'result_list'
]:
ticks
=
[]
ticks
=
[]
utilized_data
=
[]
utilized_data
=
[]
idle_data
=
[]
idle_data
=
[]
options
=
{
options
=
{
"xaxis"
:
{
"xaxis"
:
{
"minTickSize"
:
1
,
"minTickSize"
:
1
,
"ticks"
:
ticks
"ticks"
:
ticks
},
},
"yaxis"
:
{
"yaxis"
:
{
"max"
:
100
"max"
:
100
},
"series"
:
{
"bars"
:
{
"show"
:
True
,
"barWidth"
:
0.8
,
"align"
:
"center"
},
},
"stack"
:
True
"series"
:
{
"bars"
:
{
"show"
:
True
,
"barWidth"
:
0.8
,
"align"
:
"center"
},
"stack"
:
True
}
}
series
=
[{
"label"
:
"Utilized"
,
"data"
:
utilized_data
},
{
"label"
:
"Idle"
,
"data"
:
idle_data
}
}
}
];
series
=
[{
out
=
result
[
self
.
configuration_dict
[
'output_id'
]]
=
{
"label"
:
"Utilized"
,
"series"
:
series
,
"data"
:
utilized_data
"options"
:
options
},
{
}
"label"
:
"Idle"
,
"data"
:
idle_data
}
];
out
=
result
[
self
.
configuration_dict
[
'output_id'
]]
=
{
"series"
:
series
,
"options"
:
options
}
i
=
0
for
obj
in
result
[
'elementList'
]:
if
obj
.
get
(
'family'
)
==
self
.
configuration_dict
.
get
(
'family'
):
if
obj
[
'results'
][
'meanUtilization'
]:
utilized_data
.
append
((
i
,
obj
[
'results'
][
'meanUtilization'
]
*
100
))
idle_data
.
append
((
i
,
(
1
-
obj
[
'results'
][
'meanUtilization'
])
*
100
))
ticks
.
append
((
i
,
obj
.
get
(
'name'
,
self
.
getNameFromId
(
data
,
obj
[
'id'
]))))
i
+=
1
i
=
0
for
obj
in
result
[
'elementList'
]:
if
obj
.
get
(
'family'
)
==
self
.
configuration_dict
.
get
(
'family'
):
if
obj
[
'results'
][
'meanUtilization'
]:
utilized_data
.
append
((
i
,
obj
[
'results'
][
'meanUtilization'
]
*
100
))
idle_data
.
append
((
i
,
(
1
-
obj
[
'results'
][
'meanUtilization'
])
*
100
))
ticks
.
append
((
i
,
obj
.
get
(
'name'
,
self
.
getNameFromId
(
data
,
obj
[
'id'
]))))
i
+=
1
return
data
return
data
dream/plugins/CapacityStationGantt.py
View file @
abdb3aa1
...
@@ -14,54 +14,55 @@ class CapacityStationGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
...
@@ -14,54 +14,55 @@ class CapacityStationGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
data
[
'general'
][
'dateFormat'
]
=
'%Y/%m/%d'
data
[
'general'
][
'dateFormat'
]
=
'%Y/%m/%d'
self
.
initializeTimeSupport
(
data
)
self
.
initializeTimeSupport
(
data
)
date_format
=
'%d-%m-%Y %H:%M'
date_format
=
'%d-%m-%Y %H:%M'
resultElements
=
data
[
'result'
][
'result_list'
][
-
1
][
'elementList'
]
for
result
in
data
[
'result'
][
'result_list'
]:
task_dict
=
{}
resultElements
=
result
[
'elementList'
]
# loop in the results to find CapacityProjects
task_dict
=
{}
for
element
in
resultElements
:
# loop in the results to find CapacityProjects
if
element
[
'_class'
]
==
"Dream.CapacityStation"
:
for
element
in
resultElements
:
# add the project in the task_dict
if
element
[
'_class'
]
==
"Dream.CapacityStation"
:
task_dict
[
element
[
'id'
]]
=
dict
(
# add the project in the task_dict
id
=
element
[
'id'
],
task_dict
[
element
[
'id'
]]
=
dict
(
text
=
'Station %s'
%
element
[
'id'
],
id
=
element
[
'id'
],
type
=
'station'
,
text
=
'Station %s'
%
element
[
'id'
],
open
=
False
)
type
=
'station'
,
open
=
False
)
# loop in the project schedule to create the sub-tasks
detailedWorkPlan
=
element
[
'results'
].
get
(
'detailedWorkPlan'
,{})
# loop in the project schedule to create the sub-tasks
detailedWorkPlan
=
element
[
'results'
].
get
(
'detailedWorkPlan'
,{})
projectIds
=
[]
for
record
in
detailedWorkPlan
:
projectIds
=
[]
if
record
[
'project'
]
not
in
projectIds
:
for
record
in
detailedWorkPlan
:
projectIds
.
append
(
record
[
'project'
])
if
record
[
'project'
]
not
in
projectIds
:
for
projectId
in
projectIds
:
projectIds
.
append
(
record
[
'project'
])
timesInStation
=
[]
for
projectId
in
projectIds
:
for
record
in
detailedWorkPlan
:
timesInStation
=
[]
if
record
[
'project'
]
==
projectId
:
for
record
in
detailedWorkPlan
:
timesInStation
.
append
(
float
(
record
[
'time'
]))
if
record
[
'project'
]
==
projectId
:
entranceTime
=
int
(
min
(
timesInStation
))
timesInStation
.
append
(
float
(
record
[
'time'
]))
exitTime
=
int
(
max
(
timesInStation
)
+
1
)
entranceTime
=
int
(
min
(
timesInStation
))
task_dict
[
element
[
'id'
]
+
projectId
]
=
dict
(
exitTime
=
int
(
max
(
timesInStation
)
+
1
)
id
=
element
[
'id'
]
+
projectId
,
task_dict
[
element
[
'id'
]
+
projectId
]
=
dict
(
parent
=
element
[
'id'
],
id
=
element
[
'id'
]
+
projectId
,
text
=
projectId
,
parent
=
element
[
'id'
],
start_date
=
self
.
convertToRealWorldTime
(
entranceTime
).
strftime
(
date_format
),
text
=
projectId
,
stop_date
=
self
.
convertToRealWorldTime
(
exitTime
).
strftime
(
date_format
),
start_date
=
self
.
convertToRealWorldTime
(
entranceTime
).
strftime
(
date_format
),
open
=
False
,
stop_date
=
self
.
convertToRealWorldTime
(
exitTime
).
strftime
(
date_format
),
duration
=
exitTime
-
entranceTime
,
open
=
False
,
entranceTime
=
entranceTime
duration
=
exitTime
-
entranceTime
,
)
entranceTime
=
entranceTime
import
json
)
outputJSONString
=
json
.
dumps
(
task_dict
,
indent
=
5
)
outputJSONFile
=
open
(
'taskDict.json'
,
mode
=
'w'
)
import
json
outputJSONFile
.
write
(
outputJSONString
)
outputJSONString
=
json
.
dumps
(
task_dict
,
indent
=
5
)
outputJSONFile
=
open
(
'taskDict.json'
,
mode
=
'w'
)
# return the result to the gadget
outputJSONFile
.
write
(
outputJSONString
)
result
=
data
[
'result'
][
'result_list'
][
-
1
]
result
[
self
.
configuration_dict
[
'output_id'
]]
=
dict
(
# return the result to the gadget
time_unit
=
self
.
getTimeUnitText
(),
result
[
self
.
configuration_dict
[
'output_id'
]]
=
dict
(
task_list
=
sorted
(
task_dict
.
values
(),
time_unit
=
self
.
getTimeUnitText
(),
key
=
lambda
task
:
(
task
.
get
(
'parent'
),
task_list
=
sorted
(
task_dict
.
values
(),
task
.
get
(
'type'
)
==
'station'
,
key
=
lambda
task
:
(
task
.
get
(
'parent'
),
task
.
get
(
'entranceTime'
),
task
.
get
(
'type'
)
==
'station'
,
task
.
get
(
'id'
))))
task
.
get
(
'entranceTime'
),
task
.
get
(
'id'
))))
return
data
return
data
\ No newline at end of file
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