Skip to content

Commit

Permalink
Big changes to structure of tableau_documents, trying to make the fil…
Browse files Browse the repository at this point in the history
…e classes make a lot more sense
  • Loading branch information
Bryant Howell committed Dec 4, 2019
1 parent db44a4b commit a1377d7
Show file tree
Hide file tree
Showing 3 changed files with 392 additions and 7 deletions.
12 changes: 7 additions & 5 deletions tableau_documents/tableau_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,10 @@ def add_table_column(self, table_alias: str, table_field_name: str, tableau_fiel

self.column_mapping[tableau_field_alias] = "[{}].[{}]".format(table_alias, table_field_name)

def add_column_alias(self, tableau_field_alias, caption=None, dimension_or_measure=None,
discrete_or_continuous=None, datatype=None, calculation=None):
def add_column_alias(self, tableau_field_alias: str, caption: Optional[str] = None,
dimension_or_measure: Optional[str] = None,
discrete_or_continuous: Optional[str] = None, datatype: Optional[str] = None,
calculation: Optional[str] = None):
if dimension_or_measure.lower() in ['dimension', 'measure']:
role = dimension_or_measure.lower()
else:
Expand Down Expand Up @@ -917,7 +919,7 @@ def add_relative_date_extract_filter(self, column_name, period_type, number_of_p
to_date)
self.extract_filters.append(ds_filter)

def create_continuous_filter(self, column_name, min_value=None, max_value=None, date=False):
def create_continuous_filter(self, column_name: str, min_value=None, max_value=None, date=False) -> Dict:
# Dates need to be wrapped in # #
if date is True:
if min_value is not None:
Expand All @@ -943,7 +945,7 @@ def create_continuous_filter(self, column_name, min_value=None, max_value=None,
}
return ds_filter

def create_relative_date_filter(self, column_name, period_type, number_of_periods,
def create_relative_date_filter(self, column_name: str, period_type, number_of_periods,
previous_next_current='previous', to_date=False):
if period_type.lower() not in ['quarter', 'year', 'month', 'day', 'hour', 'minute']:
raise InvalidOptionException('period_type must be one of : quarter, year, month, day, hour, minute')
Expand Down Expand Up @@ -1058,7 +1060,7 @@ def generate_filters(self, filter_list: List[Dict]) -> List[ET.Element]:
return_array.append(f)
return return_array

def generate_datasource_filters_section(self):
def generate_datasource_filters_section(self) -> List[ET.Element]:
filters = self.generate_filters(self.datasource_filters)
filters_array = []
for f in filters:
Expand Down
Loading

0 comments on commit a1377d7

Please sign in to comment.