Commit Graph

45 Commits

Author SHA1 Message Date
evazion
c3ad7f6112 Model#search: factor out username search. 2019-08-29 20:44:27 -05:00
evazion
59b277ead1 users: drop id_to_name, name_to_id caching.
Changes:

* Drop Users.id_to_name.
* Don't cache Users.name_to_id.
* Replace calls to name_to_id with find_by_name when possible.
* Don't autodefine creator_name in belongs_to_creator.
* Don't autodefine updater_name in belongs_to_updater.
* Instead manually define creator_name / updater_name only on models that need
  to return these fields in the api.

id_to_name was cached to reduce the impact of N+1 query patterns in
certain places, especially in api responses that return creator_name /
updater_name fields. But it still meant we were doing N calls to
memcache. Using `includes` to prefetch users avoids this N+1 pattern.

name_to_id had no need be cached, it was never used in any performance-
sensitive contexts.

Avoiding caching also avoids the need to keep these caches consistent.
2019-08-18 11:24:42 -05:00
evazion
a926b162be models: drop unnecessary presence validations.
In rails 5, belongs_to associations automatically validate that the
associated item is present, meaning that we don't need to validate these
things manually any more.
2019-08-04 14:40:37 -05:00
Albert Yi
e3bbc92b88 change feedback category 2018-09-11 14:36:48 -07:00
Albert Yi
452413a80e eliminate monthly janitor trial messages 2018-08-28 14:58:00 -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
f2a7d3c41a /janitor_trials, /ip_bans: fix default ordering. 2018-02-04 16:48:35 -06:00
evazion
c1834ab8dd Inherit models from ApplicationRecord instead of ActiveRecord::Base. 2017-06-16 13:28:31 -05:00
r888888888
8a57d38f38 remove statement about responding in automated messages 2017-02-24 10:36:45 -08:00
evazion
b1af644f67 dmails: send automated dmails from Danbooru.config.system_user.
Sends automated dmails from `Danbooru.config.system_user`, rather than
whichever user is performing the action happens to be (usually User.admins.first).

Also adds a notice in the view that the dmail was automated.
2017-02-23 22:51:17 -06:00
r888888888
cee6a8331a bug fix for janitor trial mailer 2017-02-01 10:49:59 -08:00
Albert Yi
2605da1037 lower requirements for janitor trial 2016-12-05 12:09:50 -08:00
r888888888
c8ffffc382 fixes #2470 2015-10-19 14:33:06 -07:00
r888888888
6480864718 fixes #2469 2015-10-15 15:24:24 -07:00
r888888888
23ece16314 increase janitor trial invites to 10/month 2015-08-14 14:02:00 -07:00
r888888888
2c427d5510 addresses #2470: create feedback when granting/removing approval privileges 2015-08-07 16:28:20 -07:00
r888888888
4a367b92ef enable janitor trial invite system, fix typo 2015-08-04 17:42:19 -07:00
r888888888
ba3e362fcf janitor trial inviter takes uploads into account #2408 2015-06-30 17:53:50 -07:00
r888888888
1d9596d7f2 fixes #2417 2015-06-29 18:17:59 -07:00
r888888888
b769f996be implement report 2015-06-16 17:42:04 -07:00
Toks
203b287b32 #2408 fix message 2015-06-13 10:34:38 -04:00
Toks
27101cf5d9 #2408 create feedback on promotion; don't send duplicate dmails 2015-06-13 10:31:12 -04:00
r888888888
2d34e8f4dd fix janitor trial form 2015-06-12 21:46:20 -07:00
r888888888
e01eef5366 fix tests 2015-06-12 18:33:16 -07:00
r888888888
5dbbc12fe1 add status field to janitor trials #2408 2015-06-12 18:11:39 -07:00
r888888888
5b0c84f393 update messaging, dont delete janitor trials on promotion/deletion #2408 2015-06-12 18:08:35 -07:00
r888888888
dc20385932 work on #2408 2015-06-12 12:57:01 -07:00
r888888888
fad0ab7c93 fixes #2133 2014-04-16 17:43:34 -07:00
Kevin Xiwei Zheng
5082c9ef8c Fix creation of user records after janitor trials
Previously, a negative "demoted from janitor trial" record would
always be created after a janitor trial ended, regardless of whether
or not the user in question was actually demoted or not.  This commit
removes the culprit, an overly aggressive after_destroy callback, and
instead directly invokes user record creation in the "demote!" method.
2013-07-01 21:31:01 -04:00
albert
85a5fcc658 fixes #1133 2013-03-29 16:45:59 -04:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
72b7651169 improved search methods 2013-01-11 17:13:55 -05:00
albert
8749c43b3e refactored search 2013-01-10 17:45:52 -05:00
albert
80f34d08d9 revert default scope change 2013-01-07 17:24:03 -05:00
albert
040059c491 add default scopes to every model 2013-01-07 17:12:43 -05:00
albert
6b5b1cf023 fixes #303 2012-02-24 17:45:07 -05:00
albert
b9ace89e53 fixes #143: Janitor trials issues 2011-10-17 00:29:22 -04:00
albert
5da43c54f0 fixed all tests 2011-07-22 19:25:56 -04:00
albert
58c3d2af13 fixing tests 2011-07-16 19:20:02 -04:00
albert
9c0a961ab2 major refactoring of javascripts 2011-03-10 17:59:42 -05:00
albert
f7e2344b9f * Reworked how post versioning works, now more closely resembles the 1.18 strategy 2011-01-26 18:10:49 -05:00
albert
3d5873c182 some fixes to janitor trials, implemented jan trial controller test 2011-01-14 16:45:10 -05:00
albert
f8ab736677 fixed tests 2010-11-19 17:20:13 -05:00
albert
6bc469b05d changes 2010-08-27 16:59:59 -04:00
albert
188c30eeea add janitor trials 2010-03-09 16:18:28 -05:00