Commit Graph

45 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
a321293777
[Users] Hide favorites of blocked users
Also show the error notice when searching by tag
2022-09-11 19:49:13 +02:00
Kira
05e4736bb5 User different table for cached counters
This does not make the required changes to redirect to these
new properties yet.
2019-06-02 07:49:38 -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
Kira
43c3381b43 Missing search options and some clean up. 2019-03-30 01:16:19 -07:00
Kira
9b4c19d1e0 Add explicit locking around high speed actions
This fixes issue #1.

Add explicit locking to modifying the favorite status of a post,
voting on a post, and voting on a comment.
2019-02-08 15:30:48 -08:00
evazion
fb91bbc6c5 Fix #3813: Favorite limit can be bypassed. 2018-08-12 14:22:08 -05:00
Albert Yi
72f319ccf3 rename lambda references to use shorthand syntax 2018-05-10 11:18:02 -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
r888888888
0bfd201973 simplify logic 2017-09-13 14:47:42 -07:00
r888888888
1f3bafc061 delegate removal from favorites and updating of user fav counts to delayed job 2017-09-13 14:19:54 -07:00
evazion
af42740ca9 expunge: decrement user favorite counts. 2017-09-13 13:29:35 -07:00
r888888888
d48ed95191 favoritescontroller#destroy should work even if the post doesn't exist, remove from favorites on expunge (fixes #3222) 2017-07-19 13:39:24 -07:00
evazion
c1834ab8dd Inherit models from ApplicationRecord instead of ActiveRecord::Base. 2017-06-16 13:28:31 -05:00
evazion
40feeb2411 Post#give_favorites_to_parent: fix exception (fixup 77793759)
Forgot the `belong_to :user` association in 77793759.
2017-04-04 20:42:31 -05:00
r888888888
bb3eb9f980 favoriting now triggers an upvote 2016-02-22 17:02:15 -08:00
r888888888
fb67525c28 add intro route shortcut, optimize Favorite.remove 2015-12-08 15:17:27 -08:00
r888888888
ab325d48bf optimize favorite delete, ignore statement timeout when expunging posts #2556 2015-12-07 14:53:15 -08:00
r888888888
1253592dc9 fixes #1210 2014-06-22 20:12:06 -07:00
r888888888
e15fb6eac9 Revert "potential fix for #1210"
This reverts commit d5f10f41fd.
2014-06-22 19:43:17 -07:00
r888888888
d5f10f41fd potential fix for #1210 2014-06-20 16:33:29 -07:00
r888888888
fad0ab7c93 fixes #2133 2014-04-16 17:43:34 -07:00
Toks
e8b92781c4 Use transaction when favoriting to prevent post from being half-favorited 2014-04-11 14:50:34 -04:00
r888888888
48ae3bcefd fixes #2116 2014-03-27 15:29:16 -07:00
Toks
4c520c1d16 fix score seeming to increase for member favoriting 2013-06-11 09:38:15 -04:00
r888888888
61f8c38d34 fixes #952 2013-06-10 18:12:57 -07:00
r888888888
7db85d8301 Merge branch 'master' into close-accounts 2013-05-16 14:16:47 -07:00
r888888888
8ba43c8cd1 fix regression with tag post counts 2013-05-06 18:15:27 -07:00
r888888888
890e11f532 potential fix for #1500 2013-05-06 13:33:04 -07:00
r888888888
51a62a8df6 add support for deleting user accounts 2013-04-29 22:47:08 -07:00
r888888888
d5f575159f rename references of privileged to gold 2013-04-28 00:04:52 -07:00
r888888888
00034f1a17 refactored favorites 2013-04-18 20:19:11 -07:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
073ab8ee96 * Fixed favorites deletion
* Fixed parenting when dealing with post deletion
2012-01-06 18:20:18 -05:00
albert
cce3fe0b64 added constraint for fav search 2011-11-16 13:12:02 -05:00
albert
e42ea9c608 added popular exploration, added order:rank 2011-08-11 15:39:51 -04:00
albert
469ae14805 fixed tests, implemented sql based partitioning for favorites 2011-07-16 20:16:34 -04:00
albert
2f1fdcb459 more work on paginators 2011-06-21 14:32:07 -04:00
albert
f67374da83 * Some major bug fixes related to post sets. Tests for pools and favorites were added.
* Refactored the favorites code a bit. Adding a favorite from either an user or a post now works and will update all necessary records.
2011-06-07 19:06:39 -04:00
albert
49b3d43ddd * meta_search now pulls directly from GitHub
* Updated gems
* [inprogress] New pagination helpers used instead of pagination presenters
* [inprogress] Favorites refactored to use ActiveRecord
* [inprogress] PostSets refactored to use a decorator/dependency injection pattern
* [inprogress] Made pool/post interaction more robust
* Pool#posts now returns an ActiveRelation object
* Fixed unit tests
2011-06-07 17:34:09 -04:00
albert
435d3bf6e2 fixed user tests 2011-06-05 04:05:21 -04:00
albert
e9c2d1e636 added artists, comments 2010-02-15 13:59:58 -05:00
albert
661c214094 added favorite unit tests 2010-02-12 18:46:43 -05:00
albert
bed94a4e30 updated tag unit tests 2010-02-11 14:59:58 -05:00