Skip to content

Commit

Permalink
fix: ci fail standardrb fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Waishnav committed Aug 14, 2024
1 parent 3a23e15 commit 834370f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions app/controllers/simple_discussion/forum_posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SimpleDiscussion::ForumPostsController < SimpleDiscussion::ApplicationCont
delete_post: -10, # on forum post deletion
marked_as_solution: 100, # if forum thread author/moderator marked the post as solved
unmarked_as_solution: -100, # undoing the marked as solution
delete_reported_post: -100, # if moderator deletes the post hence it is spam post
delete_reported_post: -100 # if moderator deletes the post hence it is spam post
}

def create
Expand Down Expand Up @@ -51,12 +51,12 @@ def destroy
end

# leaderboard points distribution
if is_moderator? and @forum_post.user != current_user
if is_moderator? && (@forum_post.user != current_user)
update_leaderboard(@forum_post.user, POINTS[:delete_reported_post])
# further we can distribute points if needed to the user who reported the post

#spam_report = SpamReport.find_by(forum_post: @forum_post)
#update_leaderboard(spam_report.user, POINTS[:report_spam]) if spam_report
# spam_report = SpamReport.find_by(forum_post: @forum_post)
# update_leaderboard(spam_report.user, POINTS[:report_spam]) if spam_report
else
update_leaderboard(@forum_post.user, POINTS[:delete_post])
end
Expand Down Expand Up @@ -141,4 +141,3 @@ def redirect_after_delete_path(is_first_post)
end
end
end

4 changes: 2 additions & 2 deletions app/controllers/simple_discussion/forum_threads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SimpleDiscussion::ForumThreadsController < SimpleDiscussion::ApplicationCo
POINTS = {
create_thread: 20, # on forum thread creation
delete_thread: -20, # on forum thread deletion
delete_reported_thread_by_moderator: -100, # if moderator deletes the thread hence it is spam post
delete_reported_thread_by_moderator: -100 # if moderator deletes the thread hence it is spam post
}

def index
Expand Down Expand Up @@ -82,7 +82,7 @@ def update
def destroy
ActiveRecord::Base.transaction do
@forum_thread.destroy!
if is_moderator? and @forum_thread.user != current_user
if is_moderator? && (@forum_thread.user != current_user)
update_leaderboard(@forum_thread.user, POINTS[:delete_reported_thread_by_moderator])
else
update_leaderboard(@forum_thread.user, POINTS[:delete_thread])
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20240808180738_create_forum_leaderboard.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class CreateForumLeaderboard < ActiveRecord::Migration[7.0]
def change
create_table :forum_leaderboards do |t|
t.references :user, null: false, foreign_key: true, index: { unique: true }
t.references :user, null: false, foreign_key: true, index: {unique: true}
t.integer :points, null: false, default: 0

t.timestamps
Expand Down

0 comments on commit 834370f

Please sign in to comment.