Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1560: Reduce and improve db queries #1562

Merged
merged 12 commits into from
Sep 2, 2024

Conversation

KatunaNorbert
Copy link
Member

Fixes #1560

@KatunaNorbert KatunaNorbert marked this pull request as ready for review August 30, 2024 10:47
predictoor_cols, predictoor_data, raw_predictoor_data = (
self.get_data_for_predictoors_table(predictoor_stats)
self.get_data_for_predictoors_table(self.app.predictoors_data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use the same self.app.predictoors data in self.get_data_for_predictoors_table, since it's the same instance. No need to pass it around as a parameter

@@ -54,7 +54,7 @@ def sample_table_rows():

def pytest_setup_options():
options = Options()
options.add_argument("--headless")
# options.add_argument("--headless")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please reinstate this, we do not need to run visual stuff on the CI machines

@@ -71,7 +75,8 @@ def get_predictoors_data_from_payouts(
list: List of processed user payouts stats data.
"""

for data in user_payout_stats:
payout_stats = deepcopy(user_payout_stats)
for data in payout_stats:
formatted_data = format_dict(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest format_dict had an extra argument "only_include_keys" which does pick from dict implicitly, and since pick from dict is really simple, we don't need an explicit function, just the functionality in format_dict.

I also think this goes well, logically speaking, into the responsibility of formatting the dict

}

return {
"avg_accuracy": 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking maybe we should have some defaults in the result itself? Just an idea, not part of the main code review

) -> Dict[str, Union[float, int, str]]:
result = find_with_key_value(feed_subcription_stats, "contract", contract)

if result:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you treat the other case first and unindent?

f"{result['ws_buy_count']}-WS" if result["ws_buy_count"] > 0 else ""
)

if df_buy_count_str or ws_buy_count_str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or alternately build the result itself. It could also improve this part right here modify result["sales"] if needed

}


def get_feeds_data_for_feeds_table(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an excellent candidate of why presentation should go into db getter: it's just renaming some columns and presenting them differently. (Not part of the main code review, but discussed for a further iteration)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I noticed it

@@ -43,7 +43,6 @@
"time_machine==2.15.0",
"typeguard==4.3.0",
"xgboost==2.1.1",
"dash_bootstrap_components==1.6.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure we don't need this? Aren't we using it in other dashboards?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a duplicate, that's why a removed it

Copy link
Contributor

@calina-c calina-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments

@KatunaNorbert KatunaNorbert merged commit e180581 into main Sep 2, 2024
5 checks passed
@KatunaNorbert KatunaNorbert deleted the issue-1560-PdrDashboard-reduce-db-queries branch September 2, 2024 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PdrDashboard] Reduce and improve db queries
2 participants