Commit Graph

34 Commits

Author SHA1 Message Date
Earlopain
fc7d84affd
[RuboCop] Enable Style/FrozenStringLiteralComment
This reduces allocations on the posts page by about 5%, from basic testing
2024-02-25 18:15:55 +01:00
Earlopain
c2d224cba9
[Votes] Unify index view code 2022-10-08 23:59:33 +02:00
Earlopain
696ae62ef6
[Votes] Deduplicate Comment/Post vote code 2022-10-08 12:04:17 +02:00
Earlopain
2d45fda8fe
[Votes] Improve search
* search by ip and score
* search by comment creator name
* display email and signup date
2022-03-30 15:08:52 +02:00
Earlopain
1f52f7beeb
[Votes] Add option to only show duplicates 2022-03-21 13:35:03 +01:00
Earlopain
9e6327c8ad
[Votes] Limit complex parameters to only post/comment search 2022-03-21 10:46:22 +01:00
Earlopain
de0311a268
[Cleanup] Remove a few unused files 2022-02-19 17:19:44 +01:00
Earlopain
2bf48d3236
[Votes] Allow ordering by ip and limiting timeframe 2021-11-17 18:09:45 +01:00
Kira
03a9dd0567 Sort post votes 2020-04-08 13:47:25 -07:00
Kira
e600df2357 Add link to user post votes page 2020-04-08 11:41:14 -07:00
Kira
bc43b857df Fix post voting, again
More creator vs user nonsense.
2019-09-18 12:36:05 -07:00
Kira
bcda5326bd Update age checks to use new framework 2019-09-15 10:36:04 -07:00
Kira
b64d223b46 Update validations to use new syntax 2019-09-05 05:59:51 -07:00
Kira
c17daab83c Fix up validations, artists and tag name validator 2019-09-04 05:30:37 -07:00
Kira
e94bb0f30e User limit 2019-09-03 21:56:41 -07:00
Kira
511e2aa267 Make post votes work like comment votes 2019-04-10 20:08:36 -07:00
Kira
44ab7b1a8c Comment votes and vote fixups and interface 2019-04-09 13:04:40 -07:00
Kira
4513516e76 Post vote view and locking support 2019-04-06 13:13:50 -07:00
Kira
99f8e9addd Moved favs/voting out into managers to consolidate logic
While the logic was not particularly complex or spread out it was
made more complicated by the models being dependant on one another.

This creates a central entry point for voting and favorites and
coordinates all transactions.

TODO: upvote/downvote/fav metatags in tag section result in an error
because they attempt to change the transaction isolation mode during
an outer transaction.
2019-03-31 13:25:55 -07:00
Kira
bd85b5404c Fix race condition in favorites and voting on posts
This resolves the case where the model update job would be triggered
too soon and miss the committed state for favorites and votes on posts.

The cause of this was larger transaction blocks surrounding updates
and the jobs being queued on the first column update before commit.

This ensures that the post is fully committed before it is queued
for an index update and that all changes are visible in the table.
2019-03-30 01:59:48 -07:00
r888888888
abce4d2551 Raise error on unpermitted params.
Fail loudly if we forget to whitelist a param instead of silently
ignoring it.

misc models: convert to strong params.

artist commentaries: convert to strong params.

* Disallow changing or setting post_id to a nonexistent post.

artists: convert to strong params.

* Disallow setting `is_banned` in create/update actions. Changing it
  this way instead of with the ban/unban actions would leave the artist in
  a partially banned state.

bans: convert to strong params.

* Disallow changing the user_id after the ban has been created.

comments: convert to strong params.

favorite groups: convert to strong params.

news updates: convert to strong params.

post appeals: convert to strong params.

post flags: convert to strong params.

* Disallow users from setting the `is_deleted` / `is_resolved` flags.

ip bans: convert to strong params.

user feedbacks: convert to strong params.

* Disallow users from setting `disable_dmail_notification` when creating feedbacks.
* Disallow changing the user_id after the feedback has been created.

notes: convert to strong params.

wiki pages: convert to strong params.

* Also fix non-Builders being able to delete wiki pages.

saved searches: convert to strong params.

pools: convert to strong params.

* Disallow setting `post_count` or `is_deleted` in create/update actions.

janitor trials: convert to strong params.

post disapprovals: convert to strong params.

* Factor out quick-mod bar to shared partial.
* Fix quick-mod bar to use `Post#is_approvable?` to determine visibility
  of Approve button.

dmail filters: convert to strong params.

password resets: convert to strong params.

user name change requests: convert to strong params.

posts: convert to strong params.

users: convert to strong params.

* Disallow setting password_hash, last_logged_in_at, last_forum_read_at,
  has_mail, and dmail_filter_attributes[user_id].

* Remove initialize_default_image_size (dead code).

uploads: convert to strong params.

* Remove `initialize_status` because status already defaults to pending
  in the database.

tag aliases/implications: convert to strong params.

tags: convert to strong params.

forum posts: convert to strong params.

* Disallow changing the topic_id after creating the post.
* Disallow setting is_deleted (destroy/undelete actions should be used instead).
* Remove is_sticky / is_locked (nonexistent attributes).

forum topics: convert to strong params.

* merges https://github.com/evazion/danbooru/tree/wip-rails-5.1
* lock pg gem to 0.21 (1.0.0 is incompatible with rails 5.1.4)
* switch to factorybot and change all references

Co-authored-by: r888888888 <r888888888@gmail.com>
Co-authored-by: evazion <noizave@gmail.com>

add diffs
2018-04-06 18:09:57 -07:00
evazion
c1834ab8dd Inherit models from ApplicationRecord instead of ActiveRecord::Base. 2017-06-16 13:28:31 -05:00
evazion
3dc854c0c8 post_vote.rb: determine vote magnitude from voter, not CurrentUser.
Bug: when moving favorites, the parent is given an upvote for each gold+
favoriter, but the magnitude of these upvotes was based on the
CurrentUser, rather than the upvoter. This meant that upvotes for
supervoter favorites weren't given correctly.

To fix this, `magnitude` is changed to use the voting `user` instead of
CurrentUser.

New problem: when setting the score, `score=` calls `magnitude`, but
`user` isn't initialized yet. So we also refactor so that

    1. `initialize_attributes` initializes `user` before setting `score`
    2. the vote direction is given by `vote`, so it's separate from `score`
    3. updating the score on the post happens in a callback instead of
       directly in `score=`.
2017-03-24 15:43:55 -05:00
evazion
fd24ea5876 posts.rb: vote on behalf of correct user when moving favorites.
Bug: when an approver moves the favorites of a post, each favorite is
removed from the child post and added to the parent post. For gold+
users, this triggers an upvote, but these upvotes were performed by the
approver rather than the favoriter.
2017-03-24 15:43:28 -05:00
r888888888
09ec2dfc08 remove anti voters, extend post vote lifetime to 90 days, add minimum score threshold for super voters 2016-09-23 11:03:09 -07:00
r888888888
bf2246f895 move vote similarity code into danbooru, add listing for super voters 2016-09-19 16:43:29 -07:00
r888888888
d27807c23a store supervoter scores in post vote score 2016-02-24 14:35:07 -08:00
r888888888
2a87aad34e implement super voters 2016-02-22 14:11:25 -08:00
r888888888
fad0ab7c93 fixes #2133 2014-04-16 17:43:34 -07:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
fc0a076aca * Missing files
* Work on post exploration code by traversing dates
2010-10-27 20:16:43 -04:00
albert
ad39553aac updated tests, switched to rails 3.0.0rc2 2010-08-26 14:36:02 -04:00
albert
23656e3fa9 * Continued work on improving post view templates
* Added statistics-based estimator for related tag calculator
* Fleshed out IpBan class based on changes to Danbooru 1.xx
2010-04-29 17:32:15 -04:00
albert
9f353c32f4 added post voting 2010-02-15 17:45:09 -05:00