Permalink
Browse files

Vulnerability - split historical prepop data & some fixes

  • Loading branch information...
1 parent c70d7c6 commit 032e4e8b8e7ae45542149c077074baeb64b49b69 graeme committed Oct 10, 2012
@@ -166,7 +166,8 @@ def index():
),
dt_action_col = -1,
dt_group_space = "true",
- dt_shrink_groups = "accordion"
+ dt_shrink_groups = "accordion",
+ dt_group_types = ["text", "none"],
)
s3.report = report
@@ -753,7 +754,8 @@ def action_repr(id):
),
dt_action_col = -1,
dt_group_space = "true",
- dt_shrink_groups = "accordion"
+ dt_shrink_groups = "accordion",
+ dt_group_types = ["text", "none"],
)
reportCount = T("%(count)s Entries Found") % dict(count=filteredrows)
report.append(INPUT(_type="hidden",
@@ -831,12 +833,15 @@ def getReportDetails(id, buttonsRequired):
tr.append(th)
table.append(tr)
- tr_class = "grey"
+ mark = XML("<mark>*</mark>")
+ tr_class = "white"
for row in rows:
- tr_class = "grey" if tr_class == "white" else "white"
+ tr_class = "gray" if tr_class == "white" else "white"
tr = TR(_class=tr_class)
name = row.vulnerability_indicator.name
- tr.append(TD(name, _class="indicatorLabels"))
+ td = TD(mark, _class="indicatorLabels")
+ td.append(name)
+ tr.append(td)
value = int(row.vulnerability_data.value)
for i in range(5):
option = INPUT(_type = "radio",
View
@@ -282,7 +282,6 @@ def stats_update_time_aggregate(cls, data_id=None):
query = (dtable.deleted != True) & \
(dtable.approved_by != None)
records = db(query).select()
- return
elif isinstance(data_id, Rows):
records = data_id
elif not isinstance(data_id, Row):
@@ -307,7 +306,7 @@ def stats_update_time_aggregate(cls, data_id=None):
parameter_id = record.parameter_id
# Exit if either the location or the parameter is not valid
if not location_id or not parameter_id:
- return
+ continue
(start_date, end_date) = stats_aggregated_period(record.date)
# Get all the stats_data records for this location and parameter
@@ -342,7 +341,7 @@ def stats_update_time_aggregate(cls, data_id=None):
# The newly added indicator is the one currently stored
# in data but a more recent value is held on the database
# This will not change any of the aggregated data
- return
+ break
if start_date < earliest_period:
earliest_period = start_date
# Store the record from the db in the data storage
@@ -526,23 +525,24 @@ def stats_update_time_aggregate(cls, data_id=None):
parents_data = {}
for (param_id, loc_dict) in param_location_dict.items():
for (loc_id, periods) in loc_dict.items():
- for p_loc_row in parents[loc_id]:
- p_loc_id = p_loc_row.id
- if param_id in parents_data:
- if p_loc_id in parents_data[param_id]:
- # store the older of the changed periods (the end will always be None)
- # Only need to check the start date of the first period
- if periods[0][0] < parents_data[param_id][p_loc_id][0][0][0]:
- parents_data[param_id][p_loc_id][0] = periods
+ if loc_id in parents: # There won't be a parent if this is a L0
+ for p_loc_row in parents[loc_id]:
+ p_loc_id = p_loc_row.id
+ if param_id in parents_data:
+ if p_loc_id in parents_data[param_id]:
+ # store the older of the changed periods (the end will always be None)
+ # Only need to check the start date of the first period
+ if periods[0][0] < parents_data[param_id][p_loc_id][0][0][0]:
+ parents_data[param_id][p_loc_id][0] = periods
+ else:
+ parents_data[param_id][p_loc_id] = [periods,
+ loc_level_list[loc_id]
+ ]
else:
- parents_data[param_id][p_loc_id] = [periods,
- loc_level_list[loc_id]
- ]
- else:
- parents_data[param_id] = {p_loc_id : [periods,
- loc_level_list[loc_id]
- ]
- }
+ parents_data[param_id] = {p_loc_id : [periods,
+ loc_level_list[loc_id]
+ ]
+ }
# OPTIMISATION step 2
@@ -566,7 +566,6 @@ def stats_update_time_aggregate(cls, data_id=None):
else:
resilence_parents[p_loc_id] = [periods, loc_level_list[loc_id], False]
- #print "%s %s %s %s" % (len(location_dict), len(parents), len(parents_data), len(resilence_parents))
# Now that the time aggregate types have been set up correctly,
# fire off requests for the location aggregates to be calculated
async = current.s3task.async
@@ -2953,7 +2953,10 @@ def htmlConfig(html,
"alert" : [2,10,13]}
dt_text_maximum_len: The maximum length of text before it is condensed
dt_text_condense_len: The length displayed text is condensed down to
- dt_shrink_groups: If true then the rows within a group will be hidden
+ dt_shrink_groups: If set then the rows within a group will be hidden
+ two types are supported, 'individulal' and 'accordion'
+ dt_group_types: The type of indicator for groups that can be 'shrunk'
+ Permitted valies are: 'icon' (the default) 'text' and 'none'
@global current.response.s3.actions used to get the RowActions
"""
@@ -3028,6 +3031,7 @@ def htmlConfig(html,
config.textMaxLength = attr.get("dt_text_maximum_len", 80)
config.textShrinkLength = attr.get("dt_text_condense_len", 75)
config.shrinkGroupedRows = attr.get("dt_shrink_groups", "false")
+ config.groupIcon = attr.get("dt_group_types", [])
# Wrap the table in a form and add some data in hidden fields
form = FORM()
if not s3.no_formats and len(html) > 0:
@@ -158,14 +158,21 @@ stats,group_type,Vulnerability/stats_group_type.csv,group_type.xsl
# Add sample locations, the indicators and data
vulnerability,aggregated_indicator,Vulnerability/aggregated_indicator.csv,aggregated_indicator.xsl
vulnerability,indicator,Vulnerability/indicator.csv,indicator.xsl
-vulnerability,data,Vulnerability/vulnerability_data_short.csv,data.xsl
-vulnerability,data,Vulnerability/vulnerability_data.csv,data.xsl
-#vulnerability,data,Vulnerability/vulnerability_data_historical.csv,data.xsl
+# The vulnerability data comes in three flavours:
+# * fast: which is a very small subet enabling to see the system without impacting on prepop times
+# * short: sufficient data to properly test the system, grab your coffee (5 minutes)
+# * long: lots of data, have lunch (40 minutes)
+# In addition their is a historical data set used for the analysis
+vulnerability,data,Vulnerability/vulnerability_data_fast.csv,data.xsl
+#vulnerability,data,Vulnerability/vulnerability_data_short.csv,data.xsl
+#vulnerability,data,Vulnerability/vulnerability_data_historical_short.csv,data.xsl
#vulnerability,data,Vulnerability/vulnerability_data_long.csv,data.xsl
+#vulnerability,data,Vulnerability/vulnerability_data_historical_long.csv,data.xsl
# Demographics (needs to be after Vulnerability)
+# Demographic flavours mirror the vulnerability ones
stats,demographic,IFRC/stats_demographic.csv,demographic.xsl
+stats,demographic_data,Vulnerability/demographic_data_fast.csv,demographic_data.xsl
#stats,demographic_data,Vulnerability/demographic_data_short.csv,demographic_data.xsl
-#stats,demographic_data,Vulnerability/demographic_data.csv,demographic_data.xsl
#stats,demographic_data,Vulnerability/demographic_data_long.csv,demographic_data.xsl
#*,stats_rebuild_aggregates,
# END -------------------------------------------------------------------------
Oops, something went wrong.

0 comments on commit 032e4e8

Please sign in to comment.