Skip to content

Commit

Permalink
Removed callback cyclic dependency in org_filters
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddavo committed Aug 4, 2022
1 parent fad522d commit 4deb471
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
6 changes: 4 additions & 2 deletions dao_analyzer/apps/aragon/business/app_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ def get_layout(self, **kwargs) -> html.Div:
"""
if not self.__already_bound:
self.bind_callbacks()

org_list = self.organization_list()

return view.generate_layout(
organization_list=self.organization_list(),
organization_list=org_list,
platform_info=self.platform(org_list),
sections=self.__get_sections(),
ecosystem='aragon',
update=self.__orgsDAO.get_last_update_str(),
platform_id=TEXT['css_id_organization'],
datapoints=self.__get_datapoints(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def __init__(self,
def name(self) -> str:
return self._name

@property
def id(self) -> str:
return self._name.lower()

@property
def networks(self) -> List[str]:
return self._networks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

def generate_layout(
organization_list: OrganizationList,
platform_info: Platform,
sections: Dict,
datapoints,
ecosystem: str,
update: str,
platform_id: str,
org_value: str,
Expand All @@ -48,9 +48,11 @@ def generate_layout(
if not org_value:
org_value = organization_list.ALL_ORGS_ID

assert isinstance(platform_info, Platform)

return html.Div([
dbc.Container(
__generate_header(organization_list, ecosystem, update, org_value, network_value, filter_values),
__generate_header(organization_list, platform_info, update, org_value, network_value, filter_values),
className='top body mb-3 py-4'),
dbc.Container([
__generate_subheader(platform_id, datapoints),
Expand All @@ -68,15 +70,15 @@ def __gen_ecosystem(id: str, selected: str) -> html.Div:

def __generate_header(
organization_list: OrganizationList,
ecosystem: str,
platform_info: Platform,
update: str,
org_value: str,
network_value: str,
filter_values: List[str],
) -> dbc.Row:
selected: List[str] = __ECOSYSTEM_SELECTED['default']
if ecosystem in __ECOSYSTEM_SELECTED.keys():
selected = __ECOSYSTEM_SELECTED[ecosystem]
if platform_info.id in __ECOSYSTEM_SELECTED.keys():
selected = __ECOSYSTEM_SELECTED[platform_info.id]

ecosystems: List[html.Div] = [ __gen_ecosystem(eid, selected[i]) for i,eid in enumerate(['daohaus', 'aragon', 'daostack']) ]

Expand Down Expand Up @@ -141,7 +143,7 @@ def __generate_header(
# The following dcc is changed in callbacks that modify the dao-info-container
dcc.Store(
id='platform-info-store',
data=None, # Initially there is no data
data=platform_info,
storage_type='memory',
),
# This dcc is read-only an used to generate the dropdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ def load_ecosystem(bt_daostack: int, bt_daohaus: int, bt_aragon: int, dropdown_v
State('org-dropdown', 'value'),
State('organization-list-store', 'data'),
State('page-content', 'data-subpage'),
State('platform-info-store', 'data'),
)
def org_filters(filter_values: List[str], network_value: str, org_value: str, org_list: list, platform_name: str, prev_platform: str):
def org_filters(filter_values: List[str], network_value: str, org_value: str, org_list: list, platform_name: str):
filtered = OrganizationList.from_json(org_list)

# First we initialize all values
Expand All @@ -184,8 +183,8 @@ def org_filters(filter_values: List[str], network_value: str, org_value: str, or
else:
value = organizations.get_all_orgs_dict()['value']

# Change only if is all orgs, or its not stablished yet
if value == organizations.ALL_ORGS_ID or not prev_platform:
# Change only if is all orgs
if value == organizations.ALL_ORGS_ID:
platform = services[platform_name].platform(organizations)

return options, value, org_number, platform, _params_string(params)
6 changes: 4 additions & 2 deletions dao_analyzer/apps/daohaus/business/app_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ def get_layout(self, **kwargs) -> html.Div:
if not self.__already_bound:
self.bind_callbacks()

org_list = self.organization_list()

return view.generate_layout(
organization_list=self.organization_list(),
organization_list=org_list,
platform_info=self.platform(org_list),
sections=self.__get_sections(),
ecosystem='daohaus',
update=self.__orgsDAO.get_last_update_str(),
platform_id=TEXT['css_id_organization'],
datapoints=self.__get_datapoints(),
Expand Down
6 changes: 4 additions & 2 deletions dao_analyzer/apps/daostack/business/app_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ def get_layout(self, **kwargs) -> html.Div:
if not self.__already_bound:
self.bind_callbacks()

org_list = self.organization_list()

return view.generate_layout(
organization_list=self.organization_list(),
organization_list=org_list,
platform_info=self.platform(org_list),
sections=self.__get_sections(),
ecosystem='daostack',
update=self.__orgsDAO.get_last_update_str(),
platform_id=TEXT['css_id_organization'],
datapoints=self.__get_datapoints(),
Expand Down

0 comments on commit 4deb471

Please sign in to comment.