Skip to content

Conversation

VakarisZ
Copy link
Contributor

What does this PR do?

Fixes #2165

Add any further explanations here.

PR Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Is the TravisCI build passing?
  • Was the CHANGELOG.md updated to reflect the changes?
  • Was the documentation framework updated to reflect the changes?
  • Have you checked that you haven't introduced any duplicate code?

Testing Checklist

  • Added relevant unit tests?
  • Have you successfully tested your changes locally? Elaborate:

    Tested by running unit tests
    Manually:
    image

  • If applicable, add screenshots or log transcripts of the feature working

@VakarisZ VakarisZ requested a review from mssalvatore August 11, 2022 14:28
@codecov
Copy link

codecov bot commented Aug 11, 2022

Codecov Report

Merging #2188 (737070f) into develop (21f9b5a) will increase coverage by 0.14%.
The diff coverage is 51.72%.

❗ Current head 737070f differs from pull request most recent head af7eb23. Consider uploading reports for the commit af7eb23 to get more accurate results

@@             Coverage Diff             @@
##           develop    #2188      +/-   ##
===========================================
+ Coverage    56.96%   57.11%   +0.14%     
===========================================
  Files          498      499       +1     
  Lines        13379    13401      +22     
===========================================
+ Hits          7622     7654      +32     
+ Misses        5757     5747      -10     
Impacted Files Coverage Δ
monkey/monkey_island/cc/server_setup.py 0.00% <0.00%> (ø)
monkey/monkey_island/cc/version.py 97.56% <100.00%> (+58.43%) ⬆️
monkey/monkey_island/cc/resources/__init__.py 100.00% <0.00%> (ø)
monkey/monkey_island/cc/resources/events.py 72.72% <0.00%> (ø)
monkey/monkey_island/cc/app.py 79.72% <0.00%> (+0.14%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

)


class Analytics:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't make sense as a class. It doesn't maintain any state and nothing uses any object instances of this class. the constructor calls _send_analytics() to do some work and how it actually gets called is triggered when it gets added to the DI container. Very mysterious.

This can just be a function and you pass the Version and Deployment into it. In the long run, the version and deployment will be constructed at an earlier phase of the boot process.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, the "when" part is not evident. After taking a second look at the DI container I found a way to use it directly instead of creating a class

Island now performs 2 queries instead of 1(1 for analytics and 1 for update information)
@VakarisZ VakarisZ force-pushed the 2165-labda-decoupling branch from 789ae00 to 5ffec0e Compare August 11, 2022 14:45
This change makes the logic more evident, because sending the analytics is not done during the initialization of an object
@mssalvatore
Copy link
Collaborator

After some further discussion, the root problem is that this probably shouldn't be a back-end responsibility at all. There will be a follow-up issue.

@mssalvatore mssalvatore merged commit 82c7782 into develop Aug 12, 2022
@mssalvatore mssalvatore deleted the 2165-labda-decoupling branch August 12, 2022 14:33
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.

Refactor latest version check
2 participants