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

Refactor User Stats Tests to Pipeline-Dependent and Independent Updates #1015

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TeachMeTW
Copy link
Contributor

Description

Updates our tests for user statistics to reflect the recent refactor that separates pipeline-dependent statistics (such as trip counts and pipeline range) from pipeline-independent statistics (such as last_call_ts). Simplified the comments for brevity and to match the new changes.

Changes

Pipeline-Dependent Stats:

The test now verifies that after running the intake pipeline via etc.runIntakePipeline, the user profile is updated with:

  • total_trips
  • labeled_trips
  • pipeline_range (with both start_ts and end_ts)

Pipeline-Independent Stats:

  • The test verifies that when a server API call is stored, the last_call_ts field is updated correctly in the user profile.

Testing

python -m unittest emission/tests/analysisTests/intakeTests/TestUserStat.py

Copy link
Contributor

@JGreenlee JGreenlee left a comment

Choose a reason for hiding this comment

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

Approved, given that it passes and the stats are now described accurately

Non-critical feedback below for learning. I know it is a hard habit to break, but there are still a lot of unnecessary inline comments.

There are some good reasons for inline comments:

  • documenting decisions and trade-offs; why one approach was taken over another, especially if the other approach may be relevant later/elsewhere in the project
  • flagging future changes or improvements to be made (TODO)
  • offering a deeper explanation to what code does iff it is not already obvious at a surface level

However, comments that restate the code in words (e.g. i += 1 # increment i by 1) add noise without value

Remember, the ideal code needs little to no comments; it is already readable due to splitting code into understandable chunks and choosing meaningful variable and function names

…ats. Independent User Stats updates last call ts while Dependent User Stats updates range and trips. The two test cases should handle both scenarios.
@TeachMeTW TeachMeTW force-pushed the Update_User_Stat_Tests branch from 9c56e08 to eedc1d5 Compare February 3, 2025 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready for review by Shankari
Development

Successfully merging this pull request may close these issues.

2 participants