From 7ccca1dbbc2631dbebeab632e209e3dc6ce48fe5 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 5 Jan 2023 21:05:23 -0500 Subject: [PATCH] Make (cache) search-results a `set` and avoid overlay duplicate entries --- piker/ui/_chart.py | 22 ++++------------------ piker/ui/_search.py | 6 +++--- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/piker/ui/_chart.py b/piker/ui/_chart.py index 7f078a47..8eb35267 100644 --- a/piker/ui/_chart.py +++ b/piker/ui/_chart.py @@ -127,7 +127,10 @@ class GodWidget(QWidget): # self.init_strategy_ui() # self.vbox.addLayout(self.hbox) - self._chart_cache: dict[str, LinkedSplits] = {} + self._chart_cache: dict[ + str, + tuple[LinkedSplits, LinkedSplits], + ] = {} self.hist_linked: Optional[LinkedSplits] = None self.rt_linked: Optional[LinkedSplits] = None @@ -147,23 +150,6 @@ class GodWidget(QWidget): def linkedsplits(self) -> LinkedSplits: return self.rt_linked - # def init_timeframes_ui(self): - # self.tf_layout = QHBoxLayout() - # self.tf_layout.setSpacing(0) - # self.tf_layout.setContentsMargins(0, 12, 0, 0) - # time_frames = ('1M', '5M', '15M', '30M', '1H', '1D', '1W', 'MN') - # btn_prefix = 'TF' - - # for tf in time_frames: - # btn_name = ''.join([btn_prefix, tf]) - # btn = QtWidgets.QPushButton(tf) - # # TODO: - # btn.setEnabled(False) - # setattr(self, btn_name, btn) - # self.tf_layout.addWidget(btn) - - # self.toolbar_layout.addLayout(self.tf_layout) - # XXX: strat loader/saver that we don't need yet. # def init_strategy_ui(self): # self.strategy_box = StrategyBoxWidget(self) diff --git a/piker/ui/_search.py b/piker/ui/_search.py index 36b16132..b5bf58b9 100644 --- a/piker/ui/_search.py +++ b/piker/ui/_search.py @@ -624,10 +624,10 @@ class SearchWidget(QtWidgets.QWidget): godw = self.godwidget # first entry in the cache is the current symbol(s) - fqsns = [] - + fqsns = set() for multi_fqsns in list(godw._chart_cache): - fqsns.extend(list(multi_fqsns)) + for fqsn in set(multi_fqsns): + fqsns.add(fqsn) self.view.set_section_entries( 'cache',