Commit graph

30 commits

Author SHA1 Message Date
Daniel Uber
ba590c1750
Load article before creating a page view for an invalid one (#15898)
* Load article before creating a page view for an invalid one

This should resolve a validation error in PageView.create! when the
article does not exist (perhaps it was deleted, or the user suspended,
or it was invalid data sent from the client).

This had been happening dozens of times per day for the last 10
months.

* Use an intention revealing symbol instead of calculated id

Since we only require that find_by not find anything, pass a symbol
that's not going to be the id for any article under any conditions.

As an added benefit, this provides a clear indication of the purpose
of the symbol, without needing to mentally confirm that

```sql
  SELECT * FROM articles
  WHERE id IN (
    SELECT (1 + MAX(id)) FROM articles
  ) LIMIT 1
```

actually never gives any articles back.
2021-12-29 09:48:34 -06:00
Ben Halpern
2395693809
Asynchronously detect image aspect ratios and apply proper attributes (#15170)
* Initial work to expand detection functionality

* Finish up functionality and tests

* Fix class name

* Fix tests

* Update spec/services/articles/enrich_image_attributes_spec.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>

* Update spec/services/articles/enrich_image_attributes_spec.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>
2021-10-26 13:39:25 -07:00
rhymes
e2e923515f
Detect animated images in articles asynchronously (#13766)
* Add inline animated image detection

* Do not detect animation during preview

* Promote FastImage as a dependency

* Add Articles::DetectAnimatedImages service

* Restore previous parsing

* Add and use Articles::DetectAnimatedImagesWorker

* Remove obsolete poc

* Properly detect images in the after commit callback

* Simplify logic

* Use a second guard clause

* Fix parsing of relative paths and add tests

* Have Articles::DetectAnimatedImages correctly detect relative images uploaded locally

* Change Articles::DetectAnimatedImagesWorker priority to medium

* Only one & required
2021-06-01 10:34:04 +02:00
Alex
393ba00221
Remove Elasticsearch ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ (#13606)
* Attempt number 1

* Fix rack_attack specs

* Fix users_searches_users spec

* Fix display_users_search_spec

* Fix comment typo

* Remove search:destroy task from cypress

* Remove port 9300 from gitpod

* Stub response in attack_spec
2021-05-03 11:09:45 -04:00
Alex
d109b6824e
Refactor cache purging (#12811)
* Refactor caching

* Bring back old bust class

* Refactor with PR feedback

* Remove useless return values
2021-03-02 10:09:05 -05:00
rhymes
e7f9735354
Remove RssReader (#12169)
* Add script to remove feature flag

* Remove :feeds_import feature flag and RssReader and related classes

* Change Feeds::ImportArticlesWorker signature to support Sidekiq Cron serialization

* Replace RssReader::Assembler with Feeds::AssembleArticleMarkdown

* Removing Assembler
2021-01-08 11:45:15 -05:00
rhymes
4aaeb3e955
Feeds::Import: only import feeds that haven't been recently updated (#12126)
* Add earlier_than to Feeds::Import

* Ignore feeds that have been imported in the last 4 hours

* Make earlier_than mandatory in Feeds::ImportArticlesWorker
2021-01-06 16:58:42 +01:00
Molly Struve
f4315489b2
Refactor:Use dev_to? to Check for DEV (#12083) 2020-12-30 14:34:00 -06:00
Molly Struve
b94c95f164
Bug Fix:Update dev.to check to use DEV Community (#12082) 2020-12-30 12:41:51 -06:00
Alex
5d7fa454bd
Remove CacheBuster (#12080) 2020-12-30 11:55:16 -05:00
Alex
f70af66258
Update bust to EdgeCache::Bust (#12052)
* Update bust to EdgeCache::Bust

* Update specs

* Fix more specs

* Fix more specs :)
2020-12-29 09:53:15 +01:00
Alex
d03d03bc39
Update bust_article to BustArticle (#11931)
* Update bust_article to BustArticle

* Fix spec
2020-12-17 12:20:44 -05:00
Michael Kohl
59e2f5a025
Remove app/labor/color_from_image.rb (#11825)
* Remove app/labor/color_from_image.rb

* Remove miro gem

* Delete TODO
2020-12-10 10:08:06 +07:00
rhymes
1741e52e83
Add missing features to new feed importer (#11501)
* Add explanatory comment to how RssReaderFetchUserWorker works

* Add Feeds::ImportWorker worker

* Enable Feeds::Import for single user feed fetching behind a feature flag

* Add Feeds::ValidateUrl service

* Add feature flag to user's validate feed URL feature

* Remove todo notices

* Add feature flag to fetch_all_rss task

* Add feature flag to RssReaderWorker

* Bring back short-circuit for Articles::RssReaderWorker
2020-11-24 18:11:13 +01:00
rhymes
47624ddfcd
Add users param to Feeds::Import (#11234)
* Add users param to Feeds::Import

* Fix init and specs

* Replace explicit nil check

Co-authored-by: Michael Kohl <me@citizen428.net>

Co-authored-by: Michael Kohl <me@citizen428.net>
2020-11-03 07:02:17 -06:00
rhymes
51a4a35448
Add Feeds::Import service class (#10998)
* Add the parallel gem

* Add prototype version of Feeds::Import with parallel URL fetching and parsing

* Tune Feeds::Import and add rake task for local tests

* Add rough measurer tool

* Add specs

* Apply suggestions by @citizen428

* Replace silence with silent

* No need for eager loading

* Add temporary Articles::DevFeedsImportWorker

* Remove temporary rake task

* Add basic error handling, copied from RssReader

* Fix error handling

* Remove temporary measuring rake task

* Remove logging added for development purposes

* Add info and error logging on error level
2020-10-30 15:01:44 +01:00
rhymes
b6762fcc7b
[deploy] Add temporary RSS reader worker to gather monitoring data (#11037) 2020-10-23 12:02:08 -05:00
Molly Struve
4ab5bf5255
[deploy] Feature:Add Ability to Run RssReader via Sidekiq Cron, Prevent for DEV (#10066) 2020-08-28 14:57:22 -05:00
Molly Struve
b23374e737
[deploy] Revert "Refactor:Move RssReader Fetch Article task to Sidekiq (#9976)" (#9998) 2020-08-25 14:57:33 -05:00
Molly Struve
ff06454151
[deploy] Refactor:Move RssReader Fetch Article task to Sidekiq (#9976) 2020-08-25 13:47:13 -05:00
Vaidehi Joshi
9e40e68682
Allow Nginx cached static content to be purged (#9857) [deploy]
* Only bust_fastly_cache if fastly is enabled

* Conditionally bust nginx cache from CacheBuster#bust

* Don't _actually_ call out to openresty

* Remove redundant check for FASTLY_API_KEY in CacheBuster

* Clean up and add a spec

* Do not call .purge_ methods if fastly is not configured

* Add OPENRESTY_ ENV vars to .env_sample

* Remove extra / prepending path

* Remove ConfigurationError, clean up Purgeable concern

* Use raise instead of fail like fastly-ruby

* No longer check for Rails.env.production?

* Use let! to create article in BustMultipleCachesWorker spec
2020-08-21 09:31:23 -07:00
Ben Halpern
986eb87ce8
[deploy] Remove unneeded Analytics update script (#9852)
* Remove unneeded Analytics update script

* Remove constants
2020-08-19 15:57:27 -04:00
rhymes
f5d35c6506
Rubocop: Enable and fix Style/StringConcatenation (#9844) 2020-08-18 14:50:15 +02:00
Molly Struve
b40af82b66
Flaky Spec Fix:Remove let_it_be Test Prof Helper (#9556)
* Flaky Spec Fix:Remove let_it_be Test Prof Helper

* Spec cleanup and fixes
2020-07-29 11:31:01 +02:00
Molly Struve
05b6220e2d
[deploy] reindex articles to Elasticsearch in places where relations are updated or update_column is used (#7003) 2020-04-01 10:59:30 -05:00
codekatas
bae7ee8b73
Migrate update main image background job to sidekiq (#5345) [deploy]
* Add new UpdateMainImageBackgroundHexWorker worker class

This is a port of app/jobs/update_main_image_background_job.rb
that works with Sidekiq instead of DelayedJob.

* Update all references to UpdateMainImageBackgroundHexJob

This updates all references to UpdateMainImageBackgroundHexJob
so they now call UpdateMainImageBackgroundHexWorker, which works
with Sidekiq instead of DelayedJob.

* Move method call to after_commit callback

* Fix article specs with sidekiq helpers

Co-authored-by: Alex <alexandersmith223@gmail.com>
2020-02-04 17:51:09 -08:00
Alex
8168a5e8f5
Move Articles::ScoreCalcJob to Sidekiq (#5875) [deploy]
* Create Articles::ScoreCalcWorker

* Create Articles::ScoreCalcWorker spec

* Update references to the new ScoreCalcWorker

* Refactoring conditional callbacks and biz logic

- Move update_columns to a model method
- Move conditions on callback to guard clause in callback method
- Make article_destroy_spec more explicit
2020-02-04 10:01:46 -08:00
Cadu Ribeiro
93514e73df Migrate Articles/BustMultipleCachesJob to Sidekiq (#5309) [deploy]
Related to: #5305

In order to move all the jobs to Sidekiq, this commit creates a new
Articles/BustMultipleCachesWorker using Sidekiq based on the
Articles/BustMultipleCachesJob (this one is not removed until we know
that any job on this one will be performed).
2020-01-06 13:42:34 -05:00
Molly Struve
c1638cfd33
Create UpdateAnalyticsWorker to replace UpdateAnalyticsJob (#5331) 2020-01-02 13:05:12 -05:00
Molly Struve
8650f5c5aa
Create new BustCacheWorker and start sending jobs to it (#5302) [deploy] 2019-12-31 14:14:23 -05:00