I find it easiest and cleanest to reformat data structures in python,
using list comprehensions. Javascript sucks for loops. So instead of
jsonifying the raw database output, fix it first:
export_optimizer_records = [{'FreezeTime': r.panel_1hrs.FreezeTime,
'StringID': r.panel_1hrs.StringID, 'Po_avg_sum':
r._extra['sum(panel_1hrs.Po_avg)']} for r in export_optimizer_records]
Basically, just add this line to your controller.
On Jan 14, 5:58 pm, Lorin Rivers <[email protected]> wrote:
> Controller:
> export_optimizer_records =
> dbset(db.table.FreezeTime,db.table.StringID,db.table.Po_avg.sum(),groupby=.
> .FreezeTime|..StringID).as_list()
>
> View:
> var optimizerdata = {{response.write(json(export_optimizer_records),
> escape=False)}};
>
> The JSON looks like this:
>
> [{
> "panel_1hrs": {
> "FreezeTime": "2010-12-12 19:00:00",
> "StringID": "S00000001"
> },
> "_extra": {
> "sum(panel_1hrs.Po_avg)": 519.912549612443
> }},
>
> {
> "panel_1hrs": {
> "FreezeTime": "2010-12-12 19:00:00",
> "StringID": "S00000002"
> },
> "_extra": {
> "sum(panel_1hrs.Po_avg)": 532.390706326218
> }
>
> }]
>
> What I want is this:
>
> [{
> "FreezeTime": "2010-12-12 19:00:00",
> "StringID": "S00000001",
> "Po_avg_sum": 519.912549612443},
>
> {
> "FreezeTime": "2010-12-12 19:00:00",
> "StringID": "S00000002",
> "Po_avg_sum": 532.390706326218
>
> }]
>
> What's the easiest way to get that?
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing <http://www.mosasaur.com>
> <mailto:[email protected]>
> 512/203.3198 (m)