Commit Graph
100 Commits
Author SHA1 Message Date
evazion 27a118dfc8 tests: drop timecop gem. 2019-08-18 11:24:41 -05:00
evazion 51ca31ef8d Drop unused tag subscription model. 2019-08-17 02:47:49 -05:00
evazion 145894fe8b tests: fix alias/implication tests. 2019-08-17 02:41:07 -05:00
evazion 868a2256d1 jobs: migrate file deletion jobs to ActiveJob. 2019-08-16 20:49:35 -05:00
evazion 2b6361369e jobs: migrate aliases/implications to ActiveJob. 2019-08-16 20:49:35 -05:00
evazion 2bbdc5d143 jobs: migrate saved searches to ActiveJob.
* Fix tests to run the searches for real instead of mocking everything out.

* Fix SavedSearch.populate to only use the read only database in
  production because in breaks things in tests. Specifically:
  the posts get created in one db connection but searched for in
  another, but the second transaction doesn't see the uncommitted posts
  in the first transaction, so the search doesn't work.
2019-08-16 20:49:35 -05:00
evazion a68db501c2 jobs: migrate related tag updates to ActiveJob. 2019-08-16 20:49:35 -05:00
evazion 24eb1b155f jobs: migrate pool category updates to ActiveJob. 2019-08-16 20:49:34 -05:00
evazion 4e8b3d9310 jobs: migrate user deletions to ActiveJob. 2019-08-16 20:49:34 -05:00
evazion 822dce20ed jobs: add base ApplicationJob. 2019-08-16 20:49:34 -05:00
evazion 817f5ecf9c jobs: drop favgroup expunge job.
Make `Post#expunge!` remove favgroups synchronously.
2019-08-16 20:49:34 -05:00
evazion 798d524e60 Post#tag_match: clean up read_only param.
* Drop /posts?ro=true param (broken).
* Clean up tag_match (rescuing PG::ConnectionBad didn't do anything, we
  just build the query here, we don't run it).
2019-08-16 00:26:00 -05:00
evazion bb157f5d5b models: drop various unused #named methods. 2019-08-15 19:18:19 -05:00
evazion 0d7d2cac80 Drop unused AmazonBackup model. 2019-08-15 18:41:57 -05:00
evazion b9d35eaf2c Fix #3272: Unicode tags are still being allowed.
* Don't allow adding tags with invalid names when they already exist in
  the tags table.
* If an invalid tag is added, show an warning and ignore the tag instead
  of failing with a hard error.
* Move the _(cosplay) tag validation into the tag name validator.
2019-08-15 16:42:23 -05:00
evazion e85c6c3250 artists.js: replace 'check name' code with tag autocomplete.
Instead of having custom code check whether the artist name is already
in use, just enable autocomplete on the artist name field. This is an
easier and more robust way to indicate tag name conflicts.
2019-08-15 12:51:51 -05:00
evazion df8391aec0 Make /artists_versions and /artist_commentaries/search visible to all. 2019-08-15 12:51:51 -05:00
evazion a64cd50be4 profiles: add account upgrade link. 2019-08-15 12:51:51 -05:00
evazion 01c4395105 profiles: add 'refresh' link next to post changes count.
Remove the 'Refresh counts' link from the site map. Put it in the user's
profile instead.
2019-08-15 12:51:51 -05:00
evazion 5ceb71da8d sitemap: split 'users' section into 'profile' + 'users'.
Move everything related to the current user into it's own 'Profile'
section.
2019-08-15 12:51:51 -05:00
evazion f4db4b2eea sitemap: add missing pages to site map. 2019-08-15 12:51:51 -05:00
evazion 39d70ae5cf capistrano: simplify unicorn:terminate task.
Use the builtin task provided by capistrano3-unicorn. Ours failed with
invalid pidfile errors in some cases.
2019-08-15 12:51:51 -05:00
evazion 06b564cf76 Fix failure with did_you_mean in bundle install.
Deploying to production failed during `bundle install` because of an
incompatibility between did_you_mean-1.3.0 + ruby-2.6 + rubygems-3.0 +
bundler-2.0.

ref: `https://github.com/yuki24/did_you_mean/issues/117#issuecomment-482565387`
2019-08-15 01:23:10 -05:00
evazion 2b236a7111 unicorn: bump worker count (12 -> 16). 2019-08-15 00:36:25 -05:00
evazion 13dbdd5cd9 unicorn: clear environment variables during hot restarts.
Fixes an issue with zero downtime deployments (#4123). Hot restarting
didn't clear out BUNDLER_GEMFILE, which mean that new workers still used
the old Gemfile from previous deployments. This led to mysterious errors
with autoloading libraries (#4138).
2019-08-15 00:36:25 -05:00
evazion 5f1226ca92 Rename maintenance.rb -> danbooru_maintenance.rb.
Fixes random test failures caused by ambiguous constant lookup issues
(the `Maintenance` module name was used in multiple conflicting places).
2019-08-15 00:36:25 -05:00
evazion 247d825618 tests: fixup Post.fast_count test (a6163258b). 2019-08-15 00:36:25 -05:00
evazion 4833b8a63c Fix the circleci build. 2019-08-14 16:42:37 -05:00
evazion e29e5fe984 Fix #4131: Upgrade to Ruby 2.6.
Upgrade procedure:

    $ echo 2.6.3 > .ruby-version

    # upgrade ruby-build to know about the latest ruby versions.
    # see also: github.com/rkh/rbenv-update
    $ cd ~/.rbenv/plugins/ruby-build && git pull

    # install the version of ruby specified in .ruby-version.
    # see also: github.com/capistrano/rbenv/issues/83
    $ rbenv install --skip-existing

    # update the shell to use the latest version of ruby by default.
    $ rbenv global 2.6.3

    # update rubygems and bundler
    $ gem update --system

    # update the lockfile to use the latest version of bundler
    $ bundle update --bundler
2019-08-14 12:25:50 -05:00
evazion 38ab13f0b7 Remove unused sign up banner.
No longer used, probably broken in 98b31aafa6.
2019-08-14 01:46:44 -05:00
evazion 90fa67d4c1 Remove unused terms of service banner.
No longer used, inadvertently hidden in a6233f297e.
2019-08-14 01:46:44 -05:00
evazion 8d07ad7390 js: clean up notice/error messaging. 2019-08-14 01:46:44 -05:00
evazion e000bdb861 js: drop jquery-timeout plugin.
Replace with `Danbooru.Utility.delay`.
2019-08-14 01:46:44 -05:00
evazion d812020030 js: migrate stupidtable and jquery-hotkeys to yarn. 2019-08-14 01:46:43 -05:00
evazion fccb6cda27 js: migrate dropzone to yarn.
Also fixes a bug where sometimes the dropzone widget didn't work because
of late loading caused by the `<script async>` tag.
2019-08-14 01:46:43 -05:00
evazion 5e78e36537 fixup! application controller: clean up exception handling. 2019-08-14 01:46:43 -05:00
evazion d657624a80 Revert "application controller: fix errors in normalize_search."
This reverts commit 28a88cfa85.
2019-08-14 01:46:43 -05:00
evazion d0428da120 sessions: remove nonexistent GET /session route. 2019-08-14 01:46:43 -05:00
evazion dbfd6185f1 posts: fix error on /posts?md5=<does_not_exist>. 2019-08-13 21:30:21 -05:00
evazion 0f98631908 wiki pages: fix error in /wiki_pages/does_not_exist.json 2019-08-13 21:30:21 -05:00
evazion f6b737103a post votes: fix error handling.
* Clean up javascript.
* Return HTTP 422 instead of HTTP 500 on "you have already voted for
  this post" errors.
* In json/xml error responses, return the error message in the `message`
  field, not `reason`.
* In json/xml success responses, return the post itself instead of a
  plain `{ success: true }` object.
2019-08-13 21:30:20 -05:00
evazion 00239c4901 favorites: fix error handling.
* Return HTTP 422 instead of HTTP 500 on "You have already favorited
  this post" errors.

* Log unexpected errors in Ajax requests to the console.
2019-08-13 21:30:20 -05:00
evazion ca2e2c92b9 artist versions: fix uninitialized constant error.
Error appears intermittently depending on module load order.
2019-08-13 21:30:20 -05:00
evazion 0a5e04f015 dmail filters: fix uninitialized constant error. 2019-08-13 21:30:20 -05:00
evazion 28a88cfa85 application controller: fix errors in normalize_search.
Fix exceptions in `normalize_search` on e.g. `https://danbooru.donmai.us/users?search=blah`.
Caused when the `search` param is not a hash.
2019-08-13 21:30:20 -05:00
evazion d7fce22ee5 application controller: rescue Post::SearchError.
Raised when a member does a >2 tag search.
2019-08-13 21:30:20 -05:00
evazion e70cae457d application controller: clean up exception handling.
* Simplify code.
* Show backtraces for all users, not just builders.
* Show backtraces only for unexpected server errors (status 5xx), not
  for normal client errors (status 4xx).
* Log expected errors at info level (reduce noise in production logs).
2019-08-13 21:30:20 -05:00
evazion 84d311f366 autocomplete: add username autocomplete to /uploads search page. 2019-08-12 21:33:07 -05:00
evazion 434f1a0b85 favorites: fix LockWaitTimeout errors.
Favoriting posts sometimes fails with ActiveRecord::LockWaitTimeout
errors. This happens when a user tries to favorite multiple posts in
short succession. In that case we want the lock to block and wait for
the other favorite to go through, not to immediately fail.
2019-08-12 19:20:33 -05:00
evazion 601e58d5c5 Fix exception in legacy /post/index.xml endpoint.
Fixes intermittent `uninitialized constant LegacyController::Builder` exceptions.
2019-08-12 19:20:33 -05:00
evazion 9b57631046 capistrano: fix newrelic deployment tagging.
Override the appname in config/newrelic.yml so that we don't
accidentally tag deployments under the wrong app.
2019-08-12 19:20:33 -05:00
evazion 5acc75d21b capistrano: fix sleep calls.
Minor optimization for `cap production deploy --dry-run`. Sleep on the
server instead of in the client.
2019-08-12 18:22:44 -05:00
evazion d0d71fcdc8 posts/index: disable next page prefetching.
This causes the browser to prefetch the next page in a search, which may
make browsing seem faster to the end user, but it effectively doubles
the load on the server.
2019-08-12 18:17:04 -05:00
evazion b50b7f2a91 tag aliases: fix bug in alias resolution.
Bug: Searching for an aliased tag returns an empty page instead of
showing the results for the real tag.

Cause: The query parsing code runs the search string through
`.mb_chars.downcase` before calling `TagAlias.to_aliased`, so the input
to `to_aliased` is actually a ActiveSupport::Multibyte::Chars object.
This breaks the `aliases[name]` hash lookup because `name` is not a
plain string.

Fixup for c7bcce429.
2019-08-12 18:10:49 -05:00
evazion a71899559a tests: fix ip ban test regression. 2019-08-12 14:17:00 -05:00
evazion a28a58c1f6 tests: add more posts/index controller tests. 2019-08-12 13:38:45 -05:00
evazion d8749e7dfe search: save a query in fast_count (#4120).
During single-tag searches we look up the tag once in Post.fast_count
and later on when rendering the wiki excerpt. Doing a raw query here
meant that Rails couldn't cache the query, so it got ran again when
rendering the excerpt.
2019-08-12 13:38:45 -05:00
evazion 43e8a8a01b search: reduce queries in wiki excerpts (#4120).
Using `any?` here translated each lookup into two queries, one to check
if the aliases/implications existed and one to actually load them. Using
`present?` avoids the existence check.
2019-08-12 13:38:45 -05:00
evazion 14da425564 search: reduce queries in single tag searches (#4120).
Avoid some queries used in wiki page excerpts:

* Only try to load the artist if the tag is an artist tag.
* Avoid using `exists?` queries for wiki pages.
* Bugfix: don't show wiki excerpts for deleted wikis.
2019-08-12 13:38:45 -05:00
evazion bda69315ff search: optimize related tag calc in multi-tag searches (#4120).
In multi-tag searches, we calculated the tags in the sidebar by sampling
300 random posts from within the search and finding the most frequently
used tags. This meant we were effectively doing two searches on every
page load, one for the actual search and one for the sidebar. This is
not so bad for fast searches, but very bad for slow searches.

Instead, now we calculate the related tags from the current page of
results. This is much faster, at the cost of slightly lower accuracy and
the tag list changing slightly as you browse between pages.

We could use caching here, which would help when browsing between pages,
but we would still have to calculate the tags on the first page load,
which can be very slow in the worst case.
2019-08-12 13:38:45 -05:00
evazion a6163258bf Post.fast_count: skip alias normalization.
Post.fast_count calls Tag.normalize_query to normalize the tag string
used for the pfc cache key. This slightly improves cache sharing at the
expense of an extra query during tag searches. The extra query isn't
worth it.
2019-08-12 13:38:45 -05:00
evazion 30a378865e TagAlias.to_aliased: avoid query on blank arguments.
PostQueryBuilder calls `to_aliased` with empty arguments in some cases.
Return early to avoid a query in those cases.
2019-08-12 13:38:45 -05:00
evazion f268293105 delayed jobs: log to stdout.
Log to stdout because we now run workers under systemd and we want
errors to go to the journal, not to log/production.log.
2019-08-12 13:38:45 -05:00
evazion 7316f41d1d Fix #4106: Allow moderators to IP ban subnets. 2019-08-12 02:12:56 -05:00
evazion 9729eeb829 ip bans: remove unused code. 2019-08-11 23:38:03 -05:00
evazion fa19047220 autocomplete: add username autocompletion sitewide. 2019-08-11 15:38:39 -05:00
evazion cab36c307f upload tags report: clean up tag list rendering. 2019-08-10 23:49:36 -05:00
evazion d76be490f2 Remove tag alias corrections controller tests (fixup 18a216c67). 2019-08-10 23:49:32 -05:00
evazion 18a216c67a Fix #4130: Remove tag alias corrections. 2019-08-10 22:46:49 -05:00
evazion c7bcce429e Fix #4129: Remove tag alias caching. 2019-08-10 22:04:55 -05:00
evazion 96b28a77e7 delayed jobs: drop failed jobs email alert.
Usually when jobs aren't working it's not because the jobs themselves
are failing, it's because the workers crashed and aren't processing jobs
at all.
2019-08-10 12:06:23 -05:00
evazion 072885bbf8 delayed jobs: run dj workers under systemd (fix #4108). 2019-08-10 02:57:32 -05:00
evazion 30401f6599 aliases, implications: fix N+1 query in listing pages. 2019-08-09 00:05:50 -05:00
evazion 4f024d2360 pools/show: fix N+1 query on pool show page.
Fix a N+1 query when fetching posts to render thumbnails. Also adds
support for the `limit` url param on the posts show page.
2019-08-09 00:05:50 -05:00
evazion 6d171f44c4 pools/show: remove unused related tags calculation. 2019-08-09 00:05:50 -05:00
evazion 266259de54 gems: add pry-rails, meta_request, rack-mini-profiler. 2019-08-09 00:05:50 -05:00
evazion 48a4f3c26c application controller: catch more common exceptions. 2019-08-08 22:16:39 -05:00
evazion df433bda9c newrelic: log more request context. 2019-08-08 22:16:39 -05:00
evazion 9a6add9730 newrelic: refactor error logging.
* Factor out New Relic logging to DanbooruLogger class.
* Log all exceptions to New Relic, not just statement timeouts.
2019-08-08 22:16:39 -05:00
evazion 35dfc704bc application controller: fix bad file extension errors.
Fix requests with bad file extensions not always returning errors correctly:

* https://danbooru.donmai.us/posts.jpg
* https://danbooru.donmai.us/posts.blah
* https://danbooru.donmai.us/posts/bad.jpg
* https://danbooru.donmai.us/posts/bad.blah
2019-08-08 22:16:39 -05:00
evazion 8d706f4fd7 session controller: remove dead session[:previous_uri] cookie.
session[:previous_uri] is never set so it's always nil.
2019-08-08 14:00:46 -05:00
evazion 083283906e application controller: remove unused secure_cookies_check. 2019-08-08 14:00:46 -05:00
evazion 50fdb9fe92 Update gems. 2019-08-08 14:00:46 -05:00
evazion 853becbcfc circleci: try to fix the build. 2019-08-08 01:07:57 -05:00
evazion d45e199586 Merge branch 'fix-4123' 2019-08-07 22:39:03 -05:00
evazion bfffb57c13 capistrano: clean up unicorn:terminate task.
Do a SIGQUIT (graceful shutdown, allow workers to finish current
request) before doing a SIGTERM (immediate shutdown).
2019-08-07 22:36:12 -05:00
evazion 5231371100 posts: drop img.ly source normalization.
There are only two posts from this site and the site itself is defunct:

* https://danbooru.donmai.us/posts/1561685
* https://danbooru.donmai.us/posts/1412508
* https://img.ly/ofxl
2019-08-07 22:11:07 -05:00
evazion c225d54de1 capistrano: add deploy:rolling task (fix #4123). 2019-08-07 22:11:07 -05:00
evazion c7cd43d30e Drop unused mrtg view. 2019-08-07 22:11:07 -05:00
evazion 223e5f1e81 capistrano: enable conditional migrations. 2019-08-07 22:11:07 -05:00
evazion 1be4ca5a98 Drop unused gems. 2019-08-07 22:11:07 -05:00
evazion 9996dd40bb capistrano: only log newrelic deployment in production.
Fix local development deployments getting logged in New Relic.
2019-08-07 22:11:07 -05:00
evazion ef68d42dbe Drop unused query tracer code + term-ansicolor gem. 2019-08-07 22:11:07 -05:00
evazion 2beb79166e capistrano: fix git deprecation warning. 2019-08-07 22:11:07 -05:00
evazion 8db9d700ef daily maintenance: fix 'vacuum analyze' failure during tests.
Fixup for 2df6bf41f.
2019-08-06 15:22:08 -05:00
evazion 7f482dc35b deviantart: normalize wixmp.com sources to page urls.
Normalize sources like this:

   https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/ab917938-d8c1-4b58-933d-0d38c390461f/ddcyi98-cbd39da2-f528-4b26-aadb-a16fe91442b2.jpg/v1/fill/w_1280,h_1760,q_100,strp/tifa_by_chubymi_ddcyi98-fullview.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9MTc2MCIsInBhdGgiOiJcL2ZcL2FiOTE3OTM4LWQ4YzEtNGI1OC05MzNkLTBkMzhjMzkwNDYxZlwvZGRjeWk5OC1jYmQzOWRhMi1mNTI4LTRiMjYtYWFkYi1hMTZmZTkxNDQyYjIuanBnIiwid2lkdGgiOiI8PTEyODAifV1dLCJhdWQiOlsidXJuOnNlcnZpY2U6aW1hZ2Uub3BlcmF0aW9ucyJdfQ.Uochlma4QJmLwL2ZGMmvTr4HMva4m4bCeF3vnyPSw4I

to this:

   https://www.deviantart.com/chubymi/art/Tifa-807825644

on the sidebar of the posts show page.
2019-08-06 12:04:05 -05:00
evazion a8896b664d twitter: fix batch bookmarklet selecting wrong image.
Fix regression in 7e465aeda.

https://danbooru.donmai.us/forum_topics/9127?page=276#forum_post_158779
2019-08-06 10:42:45 -05:00
evazion 0c6d9f60bd Remove unused mailers. 2019-08-06 10:42:45 -05:00
evazion b0da649b09 Remove obsolete scripts.
These are mostly old files mostly related to maintenance of Danbooru 1
or the upgrade to Danbooru 2.
2019-08-06 10:42:45 -05:00
evazion 2df6bf41f6 cron: move 'vacuum analyze' to daily maintenance. 2019-08-06 10:42:45 -05:00