-
Notifications
You must be signed in to change notification settings - Fork 211
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
feat: 🎸 methods and db changes to publish single map and batch-publish multiple maps (no interface yet) #1772
feat: 🎸 methods and db changes to publish single map and batch-publish multiple maps (no interface yet) #1772
Conversation
Code Climate has analyzed commit 0eec279 and detected 4 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
Codecov Report
@@ Coverage Diff @@
## main #1772 +/- ##
==========================================
+ Coverage 64.72% 65.43% +0.70%
==========================================
Files 40 40
Lines 1219 1244 +25
==========================================
+ Hits 789 814 +25
Misses 430 430
|
app/controllers/spam_controller.rb
Outdated
@map = Map.find(params[:id]) | ||
if publish_check(@map) | ||
notice_text = 'Map published.' | ||
notice_text.chop! << ' and author unbanned.' if unban_check(@map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the use of #chop
here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, very nice!!!
app/controllers/spam_controller.rb
Outdated
unbanned_authors << map.user.id if unban_check(map) | ||
end | ||
end | ||
flash[:notice] = helpers.pluralize(published_maps, 'map') + ' published and ' + helpers.pluralize(unbanned_authors.size, 'author') + ' unbanned.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're only using the unbaned_authors
variable for pluralization, maybe we should keep count of the unbanned authors instead of the authors themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry @TildaDares, but could you please explain further as I'm not exactly sure what to change? I am keeping count of the unbanned authors and not the total number of authors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not clarifying. I mean the unbanned_authors
is currently storing an array of unbanned author's ids. Since we're only using the unbanned_authors
variable for pluralization, we don't actually need the unbanned author's object. We only need to keep count of how many authors are being unbanned just like you did for published_maps
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I totally get now. Made the change. Does this work fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this works. Thanks @PeculiarE!
@@ -53,7 +53,7 @@ def logged_in? | |||
|
|||
def logged_in_as(roles, action) | |||
unless current_user && roles.any? { |role| current_user.role == role } | |||
flash[:error] = "Only #{roles.collect { |role| role.pluralize }.join(' and ')} can #{action}." | |||
flash[:error] = "Only #{roles.collect(&:pluralize).join(" and ")} can #{action}." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooh cool!
@PeculiarE Seems like Rubocop has a few complaints about the comments. Not really important. |
Yeah. I've fixed it though in the latest commit I just pushed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought on method naming. If you prefer to just leave as-is, let me know! Otherwise are we ready to merge? Thank you!!!
app/controllers/spam_controller.rb
Outdated
map.user.ban unless map.anonymous? || map.user.status == User::Status::BANNED | ||
end | ||
|
||
def publish_check(map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it's worth using a longer method name that reads more like human speech, like check_and_publish
? Just an idea. The comments make it clear but i'm thinking when it's used in other files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's definitely worth it. I'm all for longer method-names for better readability. Will use your suggestions and re-push. Thank you ❤️
app/controllers/spam_controller.rb
Outdated
@map = Map.find(params[:id]) | ||
if publish_check(@map) | ||
notice_text = 'Map published.' | ||
notice_text.chop! << ' and author unbanned.' if unban_check(@map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, very nice!!!
|
||
user.unban | ||
assert_equal User::Status::NORMAL, user.status | ||
assert user.status_updated_at.to_f >= old_time.to_f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love all the tests, very thorough. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 😄 !
I've renamed the methods, and I believe we're ready to merge 😄...Thank you! |
Looks super, thank you!!! |
…h multiple maps (no interface yet) (publiclab#1772) * feat: 🎸 publish single map and batch-publish multiple maps * style: 💄 implemented code style suggestions & refactored routes * refactor: 💡 discarded authors' object and used count instead * refactor: 💡 made method names more readable
Fixes #1771
rake test
@publiclab/mapknitter-reviewers
for help, in a comment below