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

User segment for users that haven't supported in budget #2540

Merged
merged 1 commit into from
Mar 27, 2018

Conversation

bertocq
Copy link
Collaborator

@bertocq bertocq commented Mar 15, 2018

Created not_supported_on_current_budget at UserSegment along with model
spec scenario and translation strings.

References

This is a backport from madrid's fork AyuntamientoMadrid#1369

Objectives

Create a segment that returns all users that haven't supported investments on current budget

Visual Changes (if any)

None

Notes

Query looks ugly but after trying in preproduction servers

users = Vote.where(votable_type: 'Budget::Investment', votable: Budget.current.investments).select(:voter_id).distinct.pluck(:voter_id)
User.active.where.not(id: users)

It became clear that for installations with more than half million users it would take an overkill time to complete the where.not query.

Created not_supported_on_current_budget at UserSegment along with model
spec scenario and translation strings.
@bertocq bertocq requested a review from MariaCheca March 15, 2018 20:29
Copy link
Member

@voodoorai2000 voodoorai2000 left a comment

Choose a reason for hiding this comment

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

👏

@voodoorai2000 voodoorai2000 merged commit f76ad2b into master Mar 27, 2018
@voodoorai2000 voodoorai2000 deleted the user_segment_except_budget_supporters branch March 27, 2018 18:14
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.

None yet

2 participants