Project

General

Profile

Development #36770

API json sur les données de type délai de traitement

Added by Frédéric Péters 14 days ago. Updated 4 days ago.

Status:
Solution déployée
Priority:
Normal
Target version:
-
Start date:
08 Oct 2019
Due date:
% Done:

0%

Patch proposed:
Yes
Planning:
No

Description

{"format":"1",
 "data":[
  [null,null],[null,null],
  ["103732.846154","4311824.0"],
  ["215939.775",null],
  ...
  ],
 "axis":{
   "y_labels":["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"],
   "x_labels":["A","B"]
  }
}

Aujourd'hui on a les délais sous forme de chaines, avec dedans des nombres de secondes.

Il faudrait avoir des nombres, et inclure l'info de l'unité dans un attribut.

0001-views-export-duration-as-numbers-in-JSON-API-36770.patch View (5.26 KB) Benjamin Dauvergne, 12 Oct 2019 05:23 PM

0001-views-export-duration-as-numbers-in-JSON-API-36770.patch View (5.29 KB) Benjamin Dauvergne, 13 Oct 2019 10:44 PM

Associated revisions

Revision 09c52ca6 (diff)
Added by Benjamin Dauvergne 9 days ago

views: export duration as numbers in JSON API (#36770)

History

#1 Updated by Benjamin Dauvergne 10 days ago

  • Assignee set to Benjamin Dauvergne

#2 Updated by Benjamin Dauvergne 10 days ago

#3 Updated by Frédéric Péters 9 days ago

En tesant sur des données en local,

  File "/home/fred/src/eo/venv1.11/local/lib/python2.7/site-packages/rest_framework/views.py", line 486, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/fred/src/eo/bijoe/bijoe/visualization/views.py", line 313, in get
    data = [cell_value(x[1]) for x in table]
  File "/home/fred/src/eo/bijoe/bijoe/visualization/views.py", line 280, in cell_value
    return cell['value'].total_seconds()
AttributeError: 'NoneType' object has no attribute 'total_seconds'

Du coup je propose :

         def cell_value(cell):
-            if cell['type'] == 'duration':
+            if cell['type'] == 'duration' and cell['value']:
                 return cell['value'].total_seconds()
             return cell['value'] 

#5 Updated by Serghei Mihai 5 days ago

  • Status changed from Solution proposée to Solution validée

#6 Updated by Benjamin Dauvergne 5 days ago

  • Status changed from Solution validée to Résolu (à déployer)
commit 09c52ca6c351622f98ead1e7cf09473377b1e2de
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Sat Oct 12 17:10:21 2019 +0200

    views: export duration as numbers in JSON API (#36770)

#7 Updated by Frédéric Péters 4 days ago

  • Status changed from Résolu (à déployer) to Solution déployée

Also available in: Atom PDF