-
Notifications
You must be signed in to change notification settings - Fork 18
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
Optimize total_installs for /plugin/index #1040
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving for now to help get this change in, but I would recommend not passing around an additional variable is_total
for instantiating InstallActivity
, since it's redundant with an existing variable activity_type
that we can utilize. The mix of positional and keyword arguments here is a little confusing as well, ideally we would only mix them if one of the arguments was optional.
With how the pynamo Model's are initialized, refactoring that to be evaluated in the
So, I am more in favor of computing it outside and passing it on as an attribute. As an added advantage, we compute just once to determine the value of
I agree, we should avoid mixing keyword and positional arguments and lean towards keyword arguments in such cases. Updating the code to reflect that. |
for item in _InstallActivityModel.total_installs.scan(): | ||
if item.plugin_name in plugins: | ||
results[item.plugin_name] = item.install_count | ||
|
||
duration = (time.perf_counter() - start) * 1000 | ||
logging.info(f'BatchGet for total_installs_by_plugins time_taken={duration}ms') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manasaV3 Sorry I missed this before, but let's make sure to update the logging statements too that still reference BatchGet
.
Description
Relates to: #1042
Changes introduced:
Adds a new index to
install-activity
table on the plugin_name, and is_total fieldAdds the
is_total
attribute only to the records of type=TOTAL in data workflowIn backend, updates the data fetch from batch get to scan of the table.
Notes: