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

Count contributions prior to user joining event #202

Merged
merged 26 commits into from
Apr 15, 2024
Merged

Conversation

psrpinto
Copy link
Member

@psrpinto psrpinto commented Apr 10, 2024

Fix #161

Summary of changes

  • Move stats-related code to a Stats namespace
  • Add is_active() and is_past() methods to Event
  • Add a Stats_Importer for importing stats
  • Add Stats_Importer::import_for_user_and_event( $user_id, $event_id )
  • When a user attends an event that is active at that moment, call import_for_user_and_event()
  • Make sure it's not possible to attend/un-attend past events

Testing instructions

  1. Login as User A
  2. Create a translation
  3. Login as User B
  4. Create an event and make it start now
  5. Login as User A
  6. Navigate to the page of the event you created above, and click the "Attend" button
  7. Create a translation
  8. You should now be listed as a contributor, and the stats table should show a single translation (it should not count the first translation, created above in 2., as the event hadn't started yet)

@psrpinto psrpinto self-assigned this Apr 10, 2024
@psrpinto psrpinto force-pushed the early-contributions branch from fc50c1f to eaab479 Compare April 10, 2024 16:16
@psrpinto psrpinto force-pushed the early-contributions branch from eaab479 to 649b9ba Compare April 11, 2024 10:46
@psrpinto psrpinto marked this pull request as ready for review April 11, 2024 13:56
includes/event/event.php Outdated Show resolved Hide resolved
templates/event.php Show resolved Hide resolved
tests/stats/stats-importer.php Outdated Show resolved Hide resolved
Copy link
Member

@akirk akirk left a comment

Choose a reason for hiding this comment

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

Works well! I took the liberty to add fb3ddfc as it verifies that translations added before the event are not added retroactively.

@akirk
Copy link
Member

akirk commented Apr 11, 2024

Apologies, you already had a translation before the event started but it was made ineffective by my other suggestion to just create the event in the past. Fixed it now.

Co-authored-by: Alex Kirk <[email protected]>
@psrpinto
Copy link
Member Author

psrpinto commented Apr 11, 2024

Thanks for removing the sleep()! I couldn't figure out how to manipulate the date_added of the translation, so that's why I resorted to using the sleep(). Much better now.

includes/stats/stats-importer.php Outdated Show resolved Hide resolved
@psrpinto psrpinto requested a review from trymebytes April 12, 2024 09:29
@amieiro
Copy link
Collaborator

amieiro commented Apr 15, 2024

In the translations table (GlotPress plugin), if you have a row with user_id != user_id_last_modified, this means this string has been reviewed by a validator, so we should add this work to the event_actions table, only if the validator is assisting to the event.

@psrpinto psrpinto dismissed trymebytes’s stale review April 15, 2024 13:42

Issue has been fixed

@psrpinto psrpinto requested review from amieiro and akirk April 15, 2024 13:44
psrpinto and others added 2 commits April 15, 2024 15:10
Co-authored-by: Alex Kirk <[email protected]>
Co-authored-by: Alex Kirk <[email protected]>
@psrpinto psrpinto merged commit 88c3ec4 into trunk Apr 15, 2024
3 checks passed
@psrpinto psrpinto deleted the early-contributions branch April 15, 2024 14:15
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.

When joining an event late, make the earlier contributions after event start count
4 participants