Commit c09f5bbd authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Modify the database schema for the table list2 (eval, query).

parent a96ea15c
docs/db_schema/database.png

177 KB | W: | H:

docs/db_schema/database.png

178 KB | W: | H:

docs/db_schema/database.png
docs/db_schema/database.png
docs/db_schema/database.png
docs/db_schema/database.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -362,7 +362,10 @@ ...@@ -362,7 +362,10 @@
<datatype>integer</datatype> <datatype>integer</datatype>
<relation table="events" row="id" /> <relation table="events" row="id" />
</row> </row>
<row name="transform" null="1" autoincrement="0"> <row name="eval" null="1" autoincrement="0">
<datatype>string</datatype>
<default>NULL</default></row>
<row name="query" null="1" autoincrement="0">
<datatype>string</datatype> <datatype>string</datatype>
<default>NULL</default></row> <default>NULL</default></row>
<row name="group_field" null="1" autoincrement="0"> <row name="group_field" null="1" autoincrement="0">
......
...@@ -196,7 +196,8 @@ class Report(object): ...@@ -196,7 +196,8 @@ class Report(object):
notnull=True, notnull=True,
label="Event"), label="Event"),
Field("transform", "text"), Field("eval", "text"),
Field("query", "text"),
Field("group_field", Field("group_field",
"string", "string",
...@@ -205,11 +206,9 @@ class Report(object): ...@@ -205,11 +206,9 @@ class Report(object):
Field("sorters", "list:string", comment=TP_SORTERS), Field("sorters", "list:string", comment=TP_SORTERS),
Field("columns", Field("columns", "text",
"text",
default=def_columns, default=def_columns,
comment=T(TP_COLUMNS), comment=T(TP_COLUMNS)),
notnull=True),
Field("features", Field("features",
"text", "text",
......
...@@ -118,8 +118,11 @@ class List2(object): ...@@ -118,8 +118,11 @@ class List2(object):
df = func(**criteria) df = func(**criteria)
if not df.empty and config.transform not in (None, ""): if not df.empty and config.eval not in (None, ""):
df.eval(config.transform, inplace=True) df.eval(config.eval, inplace=True)
if not df.empty and config.query not in (None, ""):
df.query(config.query, inplace=True)
# .................................................................... # ....................................................................
# #
......
...@@ -10,6 +10,20 @@ formModifier = dbui.FormModifier ...@@ -10,6 +10,20 @@ formModifier = dbui.FormModifier
gridModifier = dbui.GridModifier gridModifier = dbui.GridModifier
storeModifier = dbui.StoreModifier storeModifier = dbui.StoreModifier
COLUMN_GUIDE = "All columns will be created when the field is empty"
EVAL_GUIDE = """
It is possible to transform the source by creating new columns from existing
ones using arithmetical expressions. The expression is written in natural
language with one assignment per line. For more details have a look to the
function pandas.eval and to the method pandas.DataFrame.eval.
"""
QUERY_GUIDE = """
It is possible to select data by applying a query on fields of the source.
The query is written in natural language using and / or operator.
For more details have a look to the method pandas.DataFrame.query.
"""
class ReportUi(object): class ReportUi(object):
...@@ -205,12 +219,19 @@ class ReportUi(object): ...@@ -205,12 +219,19 @@ class ReportUi(object):
mdf.configure_field("columns", mdf.configure_field("columns",
editorHeight=240, editorHeight=240,
hideLabel=True, fieldLabel=COLUMN_GUIDE,
hideLabel=False,
labelAlign="top",
language="json", language="json",
xtype="xaceeditorfield") xtype="xaceeditorfield")
mdf.configure_field("definition", height=100) mdf.configure_field("definition", height=100)
mdf.configure_field("eval",
emptyText=EVAL_GUIDE,
height=120,
hideLabel=True)
mdf.configure_field("features", mdf.configure_field("features",
editorHeight=240, editorHeight=240,
hideLabel=True, hideLabel=True,
...@@ -219,17 +240,16 @@ class ReportUi(object): ...@@ -219,17 +240,16 @@ class ReportUi(object):
mdf.configure_field("id_events", emptyText=" ") mdf.configure_field("id_events", emptyText=" ")
mdf.configure_field("query",
emptyText=QUERY_GUIDE,
height=120,
hideLabel=True)
mdf.configure_field("sorters", mdf.configure_field("sorters",
height=210, height=210,
hideHeader=True, hideHeader=True,
minimumRows=10) minimumRows=10)
mdf.configure_field("transform",
editorHeight=240,
hideLabel=True,
language="python",
xtype="xaceeditorfield")
#..................................................................... #.....................................................................
# #
# Form # Form
...@@ -243,13 +263,14 @@ class ReportUi(object): ...@@ -243,13 +263,14 @@ class ReportUi(object):
"definition", "definition",
title=T("General")) title=T("General"))
mdf.merge_fields("transform",
title=T("Transform"))
mdf.merge_fields("group_field", mdf.merge_fields("group_field",
"sorters", "sorters",
title=T("Group")) title=T("Group"))
mdf.merge_fields("eval",
"query",
title=T("Transform"))
mdf.merge_fields("columns", mdf.merge_fields("columns",
title=T("Columns")) title=T("Columns"))
...@@ -267,14 +288,15 @@ class ReportUi(object): ...@@ -267,14 +288,15 @@ class ReportUi(object):
mdf.configure_column("name", width=30) mdf.configure_column("name", width=30)
mdf.hide_columns("columns", mdf.hide_columns("columns",
"conditions", "conditions",
"eval",
"features", "features",
"group_field", "group_field",
"id_events", "id_events",
"kwargs", "kwargs",
"query",
"sorters", "sorters",
"source", "source",
"title", "title")
"transform")
#..................................................................... #.....................................................................
# #
......
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