* First greedy algorithm approach to awarding community wellness badge
* Update app/services/badges/award_community_wellness.rb
I'm sorry I ignored you rubocop. It's still on draft for a reason 😅
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/badges/award_community_wellness.rb
Okay, whatever you say rubocop. This line will go away before merging anyways
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Use app/queries/comments/community_wellness_query.rb to replace greedy algorithm
* Query indenting + rename positive_reactions to negative_reactions in EXCEPT
* First step towards query spec
* Fix spec and make it more robust
* Slight cleanup/tweaks
* Badge reward & message
* copy edits + spec improvements + 3 days ago min for query
* Cron update to run daily + small tweak for FeatureFlag use
* inline comment tweaks
* Slight reorder of guard checks in service (FeatureFlag related)
* PR review feedback
* Fix specs from static method refactor
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
29 lines
675 B
Ruby
29 lines
675 B
Ruby
module CommentsHelpers
|
|
FLAGGED_CATEGORIES = %w[thumbsdown vomit].freeze
|
|
|
|
def create_comment_time_ago(user_id, time_ago, flagged_by: nil, commentable: nil)
|
|
comment = create(
|
|
:comment,
|
|
commentable: commentable || create(:article),
|
|
user_id: user_id,
|
|
created_at: time_ago,
|
|
)
|
|
# User default self-like
|
|
create(
|
|
:reaction,
|
|
user_id: user_id,
|
|
reactable_id: comment.id,
|
|
reactable_type: "Comment",
|
|
)
|
|
|
|
return if flagged_by.nil?
|
|
|
|
create(
|
|
:reaction,
|
|
user_id: flagged_by.id,
|
|
category: FLAGGED_CATEGORIES.sample,
|
|
reactable_id: comment.id,
|
|
reactable_type: "Comment",
|
|
)
|
|
end
|
|
end
|