Commit dc2848f9 authored by Mouadh's avatar Mouadh

format

parent 81ce493a
...@@ -17,6 +17,7 @@ from ..tools.connection import MyDB ...@@ -17,6 +17,7 @@ from ..tools.connection import MyDB
RUNNING_TOX = 'RUNTING_TOX' in os.environ RUNNING_TOX = 'RUNTING_TOX' in os.environ
class MdxEngine: class MdxEngine:
""" """
The principal class for executing a query The principal class for executing a query
...@@ -75,14 +76,15 @@ class MdxEngine: ...@@ -75,14 +76,15 @@ class MdxEngine:
# get csv files folders (cubes) # get csv files folders (cubes)
if RUNNING_TOX: if RUNNING_TOX:
location = os.path.join( location = os.path.join(
os.path.abspath( os.path.abspath(
os.path.join( os.path.join(
os.path.dirname(__file__), "..", "..", "..", "..")), os.path.dirname(__file__), "..", "..", "..", "..")),
MdxEngine.CUBE_FOLDER) MdxEngine.CUBE_FOLDER)
else: else:
home_directory = expanduser("~") home_directory = expanduser("~")
location = os.path.join(home_directory, 'olapy-data', cls.CUBE_FOLDER) location = os.path.join(home_directory, 'olapy-data',
cls.CUBE_FOLDER)
try: try:
MdxEngine.csv_files_cubes = [ MdxEngine.csv_files_cubes = [
...@@ -325,8 +327,8 @@ class MdxEngine: ...@@ -325,8 +327,8 @@ class MdxEngine:
for cubes in config_file_parser.construct_cubes(): for cubes in config_file_parser.construct_cubes():
# TODO cubes.source == 'csv' # TODO cubes.source == 'csv'
if cubes.source == 'postgres': if cubes.source == 'postgres':
fusion = self._construct_star_schema_config_file( fusion = self._construct_star_schema_config_file(cube_name,
cube_name, cubes) cubes)
elif cube_name in self.csv_files_cubes: elif cube_name in self.csv_files_cubes:
fusion = self._construct_star_schema_csv_files(cube_name) fusion = self._construct_star_schema_csv_files(cube_name)
...@@ -648,9 +650,8 @@ class MdxEngine: ...@@ -648,9 +650,8 @@ class MdxEngine:
:return: updated columns_to_keep :return: updated columns_to_keep
""" """
if len( if len(tuple_as_list) == 3 and tuple_as_list[-1] in self.tables_loaded[
tuple_as_list tuple_as_list[0]].columns:
) == 3 and tuple_as_list[-1] in self.tables_loaded[tuple_as_list[0]].columns:
# in case of [Geography].[Geography].[Country] # in case of [Geography].[Geography].[Country]
cols = [tuple_as_list[-1]] cols = [tuple_as_list[-1]]
else: else:
...@@ -751,14 +752,8 @@ class MdxEngine: ...@@ -751,14 +752,8 @@ class MdxEngine:
# TODO groupby in web demo (remove it for more performance) # TODO groupby in web demo (remove it for more performance)
# TODO margins=True for columns total !!!!! # TODO margins=True for columns total !!!!!
return { return {
'result': 'result': df.groupby(cols).sum()[self.selected_measures],
# df.drop_duplicates().replace(np.nan, -1).groupby(cols).sum(), 'columns_desc': tables_n_columns
# TODO remove this (FIX V1)
# df.replace(np.nan, -1).groupby(cols).sum()[self.selected_measures],
# TODO chech this FIX
df.groupby(cols).sum()[self.selected_measures],
'columns_desc':
tables_n_columns
} }
else: else:
......
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