0003-feeder-store-delay-since-receipt_time-in-evolution-t.patch
tests/test_wcs.py | ||
---|---|---|
25 | 25 |
('evolution', 'time'), |
26 | 26 |
('evolution', 'date'), |
27 | 27 |
('evolution', 'hour_id'), |
28 |
('evolution', 'delay'), |
|
28 | 29 |
('evolution_demande', 'id'), |
29 | 30 |
('evolution_demande', 'status_id'), |
30 | 31 |
('evolution_demande', 'formdata_id'), |
31 | 32 |
('evolution_demande', 'time'), |
32 | 33 |
('evolution_demande', 'date'), |
33 | 34 |
('evolution_demande', 'hour_id'), |
35 |
('evolution_demande', 'delay'), |
|
34 | 36 |
('formdata', 'id'), |
35 | 37 |
('formdata', 'formdef_id'), |
36 | 38 |
('formdata', 'receipt_time'), |
wcs_olap/feeder.py | ||
---|---|---|
500 | 500 |
['time', 'timestamp'], |
501 | 501 |
['date', 'date'], |
502 | 502 |
['hour_id', 'smallint REFERENCES {hour_table} (id)'], |
503 |
['delay', 'interval'], |
|
503 | 504 |
]) |
504 | 505 |
self.ex('COMMENT ON TABLE {generic_evolution_table} IS %s', vars=(u'evolution générique',)) |
505 | 506 | |
... | ... | |
687 | 688 |
['time', 'timestamp'], |
688 | 689 |
['date', 'date'], |
689 | 690 |
['hour_id', 'smallint REFERENCES {hour_table} (id)'], |
691 |
['delay', 'interval'], |
|
690 | 692 |
]) |
691 | 693 |
self.ex('COMMENT ON TABLE "{evolution_table}" IS %s', |
692 | 694 |
vars=(u'evolution des demandes %s' % self.formdef.schema.name,)) |
... | ... | |
826 | 828 |
status_id = self.status_mapping[status.id] |
827 | 829 |
generic_status_id = self.generic_status(status) |
828 | 830 |
evolution.append( |
829 |
[0, status_id, evo.time, evo.time.date(), evo.time.hour]) |
|
831 |
[0, status_id, evo.time, evo.time.date(), evo.time.hour, evo.delay])
|
|
830 | 832 |
if generic_status_id == last_status: |
831 | 833 |
continue |
832 | 834 |
generic_evolution.append( |
833 |
[0, generic_status_id, evo.time, evo.time.date(), evo.time.hour]) |
|
835 |
[0, generic_status_id, evo.time, evo.time.date(), evo.time.hour, evo.delay])
|
|
834 | 836 |
last_status = generic_status_id |
835 | 837 |
generic_evolution_values.append(generic_evolution) |
836 | 838 |
evolution_values.append(evolution) |
... | ... | |
849 | 851 |
generic_evolutions.append(tuple(row)) |
850 | 852 |
if len(generic_evolutions) == 500: |
851 | 853 |
self.ex('INSERT INTO {generic_evolution_table} (%s) VALUES %s' % ( |
852 |
', '.join(['formdata_id', 'generic_status_id', 'time', 'date', 'hour_id']), |
|
854 |
', '.join(['formdata_id', 'generic_status_id', 'time', 'date', 'hour_id', 'delay']),
|
|
853 | 855 |
', '.join(['%s'] * len(generic_evolutions))), vars=generic_evolutions) |
854 | 856 |
generic_evolutions = [] |
855 | 857 |
if generic_evolutions: |
856 | 858 |
self.ex('INSERT INTO {generic_evolution_table} (%s) VALUES %s' % ( |
857 |
', '.join(['formdata_id', 'generic_status_id', 'time', 'date', 'hour_id']), |
|
859 |
', '.join(['formdata_id', 'generic_status_id', 'time', 'date', 'hour_id', 'delay']),
|
|
858 | 860 |
', '.join(['%s'] * len(generic_evolutions))), vars=generic_evolutions) |
859 | 861 | |
860 | 862 |
# insert evolutions |
... | ... | |
865 | 867 |
evolutions.append(tuple(row)) |
866 | 868 |
if len(evolutions) == 500: |
867 | 869 |
self.ex('INSERT INTO "{evolution_table}" (%s) VALUES %s' % ( |
868 |
', '.join(['formdata_id', 'status_id', 'time', 'date', 'hour_id']),
|
|
869 |
', '.join(['%s'] * len(evolutions))), vars=evolutions) |
|
870 |
', '.join(['formdata_id', 'status_id', 'time', 'date', 'hour_id', 'delay']),
|
|
871 |
', '.join(['%s'] * len(evolutions))), vars=evolutions)
|
|
870 | 872 |
evolutions = [] |
871 | 873 |
if evolutions: |
872 | 874 |
self.ex('INSERT INTO "{evolution_table}" (%s) VALUES %s' % ( |
873 |
', '.join(['formdata_id', 'status_id', 'time', 'date', 'hour_id']), |
|
875 |
', '.join(['formdata_id', 'status_id', 'time', 'date', 'hour_id', 'delay']),
|
|
874 | 876 |
', '.join(['%s'] * len(evolutions))), vars=evolutions) |
875 | 877 | |
876 | 878 |
def get_first_agent_in_evolution(self, formdata): |
wcs_olap/wcs_api.py | ||
---|---|---|
79 | 79 |
who = None |
80 | 80 |
status = None |
81 | 81 |
parts = None |
82 |
formdata = None |
|
82 | 83 | |
83 |
def __init__(self, wcs_api, **kwargs): |
|
84 |
def __init__(self, wcs_api, formdata, **kwargs):
|
|
84 | 85 |
super(Evolution, self).__init__(wcs_api, **kwargs) |
86 |
self.formdata = formdata |
|
85 | 87 |
self.time = isodate.parse_datetime(self.time) |
86 | 88 |
if self.parts: |
87 | 89 |
self.parts = [BaseObject(wcs_api, **part) for part in self.parts] |
88 | 90 |
if self.who: |
89 | 91 |
self.who = EvolutionUser(wcs_api, **self.who) |
90 | 92 | |
93 |
@property |
|
94 |
def delay(self): |
|
95 |
'''Compute delay as the time when the last not endpoint status precedes an endpoint |
|
96 |
status.''' |
|
97 |
return self.time - self.formdata.receipt_time |
|
98 | ||
91 | 99 | |
92 | 100 |
class FormData(BaseObject): |
93 | 101 |
geolocations = None |
... | ... | |
98 | 106 |
self.receipt_time = isodate.parse_datetime(self.receipt_time) |
99 | 107 |
self.submission = BaseObject(wcs_api, **self.submission) |
100 | 108 |
self.workflow = FormDataWorkflow(wcs_api, **self.workflow) |
101 |
self.evolution = [Evolution(wcs_api, **evo) for evo in self.evolution or []] |
|
109 |
self.evolution = [Evolution(wcs_api, self, **evo) for evo in self.evolution or []]
|
|
102 | 110 |
self.functions = {} |
103 | 111 |
self.concerned_roles = [] |
104 | 112 |
self.action_roles = [] |
105 |
- |