Commit abdb3aa1 authored by Jérome Perrin's avatar Jérome Perrin

Capacity project plugins: postprocess all results, not only the last one

parent c036000b
......@@ -14,41 +14,42 @@ class CapacityProjectGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
data['general']['dateFormat']='%Y/%m/%d'
self.initializeTimeSupport(data)
date_format = '%d-%m-%Y %H:%M'
resultElements=data['result']['result_list'][-1]['elementList']
task_dict = {}
# loop in the results to find CapacityProjects
for element in resultElements:
if element['_class']=="Dream.CapacityProject":
# add the project in the task_dict
task_dict[element['id']] = dict(
id=element['id'],
text='Project %s' % element['id'],
type='project',
open=False)
# loop in the project schedule to create the sub-tasks
projectSchedule=element['results'].get('schedule',{})
for record in projectSchedule:
task_dict[element['id']+record['stationId']] = dict(
id=element['id']+record['stationId'],
parent=element['id'],
text=record['stationId'],
start_date=self.convertToRealWorldTime(
record['entranceTime']).strftime(date_format),
stop_date=self.convertToRealWorldTime(
record['exitTime']).strftime(date_format),
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(
time_unit=self.getTimeUnitText(),
task_list=sorted(task_dict.values(),
key=lambda task: (task.get('parent'),
task.get('type') == 'project',
task.get('entranceTime'),task.get('id'))))
for result in data['result']['result_list']:
resultElements = result['elementList']
task_dict = {}
# loop in the results to find CapacityProjects
for element in resultElements:
if element['_class']=="Dream.CapacityProject":
# add the project in the task_dict
task_dict[element['id']] = dict(
id=element['id'],
text='Project %s' % element['id'],
type='project',
open=False)
# loop in the project schedule to create the sub-tasks
projectSchedule=element['results'].get('schedule',{})
for record in projectSchedule:
task_dict[element['id']+record['stationId']] = dict(
id=element['id']+record['stationId'],
parent=element['id'],
text=record['stationId'],
start_date=self.convertToRealWorldTime(
record['entranceTime']).strftime(date_format),
stop_date=self.convertToRealWorldTime(
record['exitTime']).strftime(date_format),
open=False,
duration=int(record['exitTime'])-int(record['entranceTime']),
entranceTime=record['entranceTime']
)
# return the result to the gadget
result[self.configuration_dict['output_id']] = dict(
time_unit=self.getTimeUnitText(),
task_list=sorted(task_dict.values(),
key=lambda task: (task.get('parent'),
task.get('type') == 'project',
task.get('entranceTime'),task.get('id'))))
return data
......@@ -6,52 +6,52 @@ class CapacityProjectStationUtilization(plugin.OutputPreparationPlugin):
"""
def postprocess(self, data):
result = data['result']['result_list'][-1]
ticks = []
utilized_data = []
idle_data = []
options = {
"xaxis": {
"minTickSize": 1,
"ticks": ticks
},
"yaxis": {
"max": 100
},
"series": {
"bars": {
"show": True,
"barWidth": 0.8,
"align": "center"
for result in data['result']['result_list']:
ticks = []
utilized_data = []
idle_data = []
options = {
"xaxis": {
"minTickSize": 1,
"ticks": ticks
},
"yaxis": {
"max": 100
},
"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 = [{
"label": "Utilized",
"data": utilized_data
}, {
"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
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
return data
......@@ -14,54 +14,55 @@ class CapacityStationGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
data['general']['dateFormat']='%Y/%m/%d'
self.initializeTimeSupport(data)
date_format = '%d-%m-%Y %H:%M'
resultElements=data['result']['result_list'][-1]['elementList']
task_dict = {}
# loop in the results to find CapacityProjects
for element in resultElements:
if element['_class']=="Dream.CapacityStation":
# add the project in the task_dict
task_dict[element['id']] = dict(
id=element['id'],
text='Station %s' % element['id'],
type='station',
open=False)
# loop in the project schedule to create the sub-tasks
detailedWorkPlan=element['results'].get('detailedWorkPlan',{})
projectIds=[]
for record in detailedWorkPlan:
if record['project'] not in projectIds:
projectIds.append(record['project'])
for projectId in projectIds:
timesInStation=[]
for record in detailedWorkPlan:
if record['project']==projectId:
timesInStation.append(float(record['time']))
entranceTime=int(min(timesInStation))
exitTime=int(max(timesInStation)+1)
task_dict[element['id']+projectId] = dict(
id=element['id']+projectId,
parent=element['id'],
text=projectId,
start_date=self.convertToRealWorldTime(entranceTime).strftime(date_format),
stop_date=self.convertToRealWorldTime(exitTime).strftime(date_format),
open=False,
duration=exitTime-entranceTime,
entranceTime=entranceTime
)
import json
outputJSONString=json.dumps(task_dict, indent=5)
outputJSONFile=open('taskDict.json', mode='w')
outputJSONFile.write(outputJSONString)
# return the result to the gadget
result = data['result']['result_list'][-1]
result[self.configuration_dict['output_id']] = dict(
time_unit=self.getTimeUnitText(),
task_list=sorted(task_dict.values(),
key=lambda task: (task.get('parent'),
task.get('type') == 'station',
task.get('entranceTime'),
task.get('id'))))
for result in data['result']['result_list']:
resultElements = result['elementList']
task_dict = {}
# loop in the results to find CapacityProjects
for element in resultElements:
if element['_class']=="Dream.CapacityStation":
# add the project in the task_dict
task_dict[element['id']] = dict(
id=element['id'],
text='Station %s' % element['id'],
type='station',
open=False)
# loop in the project schedule to create the sub-tasks
detailedWorkPlan=element['results'].get('detailedWorkPlan',{})
projectIds=[]
for record in detailedWorkPlan:
if record['project'] not in projectIds:
projectIds.append(record['project'])
for projectId in projectIds:
timesInStation=[]
for record in detailedWorkPlan:
if record['project']==projectId:
timesInStation.append(float(record['time']))
entranceTime=int(min(timesInStation))
exitTime=int(max(timesInStation)+1)
task_dict[element['id']+projectId] = dict(
id=element['id']+projectId,
parent=element['id'],
text=projectId,
start_date=self.convertToRealWorldTime(entranceTime).strftime(date_format),
stop_date=self.convertToRealWorldTime(exitTime).strftime(date_format),
open=False,
duration=exitTime-entranceTime,
entranceTime=entranceTime
)
import json
outputJSONString=json.dumps(task_dict, indent=5)
outputJSONFile=open('taskDict.json', mode='w')
outputJSONFile.write(outputJSONString)
# return the result to the gadget
result[self.configuration_dict['output_id']] = dict(
time_unit=self.getTimeUnitText(),
task_list=sorted(task_dict.values(),
key=lambda task: (task.get('parent'),
task.get('type') == 'station',
task.get('entranceTime'),
task.get('id'))))
return data
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment