Commit graph

71 commits

Author SHA1 Message Date
rhymes
d5057f7958 Show sponsorships in ledger (#3447) 2019-07-11 16:06:31 -04:00
Mac Siri
28e5ef1d12 Make RSS's self-referential link an option (#3428)
* Create migration

* Run migration

* Update validations

* Add additional form

* Update RssReader::Assembler#thorough_parsing

* Add spec for referential
2019-07-09 17:34:21 -04:00
rhymes
1f97669e66 Credits ledger (#3395)
* Add #purchase to Credit

* Assigns spent credits to the listing

* Add Credits::Ledger and use it

* Localize ledger datetimes

* Add organization to the ledger

* Add tests for ledger

* Remove unused class

* Fix scope error

* Compare UTC times

* Fix broken specs

* Wrap listing create in a transaction

* Wrap listings bump into a transaction

* Avoid microseconds issue with datetimes in tests

* Use .detect instead of .select.first

* Fix spec description
2019-07-09 10:11:18 -04:00
cyrillefr
5146532c82 Move messages send_push delay calls to ActiveJob (#3314) 2019-07-08 18:00:19 -04:00
Anna Buianova
c3ed38f832 Moved creating a new podcast to a separate ActiveJob #2952 (#3373)
* Podcasts reachable status #2952

* Specs for podcasts statuses

* Moved podcast episode create to a separate ActiveJob

* Use RssItemData wrapper in GetEpisode for consistency

* Reorganize services/podcasts
2019-07-04 13:10:54 -04:00
Anna Buianova
3d81753285 Rescue possible SSLError when fetching a podcast (#3374) 2019-07-03 10:36:36 -04:00
Anna Buianova
d6a151703c Podcasts reachable status #2952 (#3341)
* Podcasts reachable status #2952

* Specs for podcasts statuses
2019-07-02 09:18:27 -04:00
rhymes
9afdea06f5 Fix Rubocop Lint (#3361) [ci skip] 2019-07-01 14:07:39 -04:00
Anna Buianova
6395fe48e2 Moved podcast fixtures to their own folder (#3343) [ci skip] 2019-07-01 12:37:28 -04:00
rhymes
7da7a16d8d Pro: add referrers to dashboard and single article stats (#3295)
* Reorganize PageViewsController

* Add domain and path to PageView model

* Add before_create callback to populate domain and path

* Add list of referrers to AnalyticsService

* Add referrers to the UI

* Remove useless referrers card and tweak table line height

* Add referrer stats to article stats page

* Add not null and empty default to domain and path

* Refactor JS analytics client

* create_list is a step back here

* Revert "Add not null and empty default to domain and path"

This reverts commit bc02440076047a887c65d300bccd4661ecc8ffd0.

* Add index on domain concurrently

* Make the script more robust
2019-06-25 13:58:09 -04:00
Anna Buianova
bfa1bdc37f More specs and refactoring podcasts fetching (#3245)
* More specs and refactoring podcasts fetching

* Fixed PodcastFeed references in tests

* Pass podcast_id instead of podcast to CreateEpisode
2019-06-21 21:31:15 -04:00
rhymes
91de529705 Remove code for legacy mentoring feature (#3186) 2019-06-21 17:18:11 -04:00
Andy Zhao
1e61634499 Add backend functionality for muting users you follow (#3240)
* Add backend func. for muting users you follow

* Remove comment

* Add validations and update default value

* Send notifications to followers with all_articles
2019-06-20 11:28:50 -04:00
Anna Buianova
24328417ab Don't try to register webhook when twitch returns empty data (#3219) 2019-06-18 21:34:06 -04:00
Ben Halpern
e130400e9e
Finalize UI for all types of notification settings (#3164) 2019-06-14 18:28:38 -04:00
rhymes
aa29a5cb55 Fix analytics grouped by day with nil page views average (#3159) 2019-06-14 13:30:04 -04:00
Andy Zhao
b953f17d0c New Feature: Subscribe to posts! (#3149)
* Add MVP of notification subscriptions

* Add rate limiting for notification subscriptions

* Show modal for logged out users on subscribe click

* Add enter key functionality for checkbox

* Add relationships for notification subscriptions

* Add model test for notification subscription

* Deprecated article mutes in favor of notification subscriptions

* Deprecated comment mutes in favor of notification subscriptions

* Move comment muting tests and logic over

* Merge comment and article muting into subscriptions

* Remove redundant check

* Use database to check for rate limit instead of cache

* Test for subscriptions handling notifications properly

* Fix notification model spec for subscriptions

* Fix tests for subscriptions

* Remove rate limiting

* Properly handle logged out users getting subscription status

* Fix test for new pattern

* Update reserved words

* Add config column to notification subscriptions

* Add logic for top level config and move tests

* Test for top level subscribers getting notified

* Fix logic mistake oops

* Add index and refactor comment_user_ids
2019-06-14 12:03:43 -04:00
Anna Buianova
2c05bbc0c1 Change notifications unique indexes #2525 (#3012)
* Notifications unique indexes that take null values into account

* Specify import options for reaction notifications according to the indexes

* Fix specs: notifications have either user_id or organization_id

* Create notifications indexes concurrently
2019-06-13 15:17:50 -04:00
Kartikey Tanna
858ce184e5 Implement ActiveJob for Mention (#3055)
* Implemented ActiveJob for Mention#send_email_notification

* Implemented ActiveJob for Mention.create_all

* Fixed args while calling the job

* Changes as per the review
2019-06-13 11:05:22 -04:00
Mac Siri
bc7c23e241
Fix inconsistent spec (#3113) [ci skip]
* Fix inconsistent spec due to zonebie

* Update spec
2019-06-10 17:33:44 -04:00
rhymes
a8b7f6eea4 Analytics: refactoring for speed improvements (#3072)
* Use proper auth chain before checking parameters

* Refactor AnalyticsController

* Add a bunch of test and rewrite reactions counts with a single query

* Add tests for follows totals

* Use round and add more refactoring

* Add tests to group by day to fallback during refactoring

* Use group by to calculate comments count by day

* Use group by to calculate follows count by day

* Use group by to calculate reactions stats by day

* Use group by to calculate page_views stats by day

* Move calculations per day back in the cached block

* Add a few comments and a little bit of refactoring

* Add indexes (concurrently) for analytics

* Make tests more time robust

* Use a date range cache related to the requesting user or org

* Freezing time in UTC should help when tests are ran on time zones over the day line

* Remove explicit returns

* Page title is escaped, guard against that

* Move Analytics service spec in the proper place
2019-06-10 09:27:39 -04:00
cyrillefr
8c52d5c43f Move remove_each notifications method in own job (#2946) 2019-05-29 16:26:18 -04:00
Anna Buianova
c510f1510c Fix a validation error when creating notifications #2525 (#2999)
* Use activerecord-import upsert to deal with the race condition

* Return a more consistent result form Notifications::Reactions::Send
2019-05-29 11:19:37 -04:00
Mac Siri
6d1638ed68 Unskip all skipped specs (#2941)
* Change all login_as to sign_in

* Unskip comment spec

* Create new specs

* Turn on Webdriver caching

* Set logger for Omniauth in test

* Update editor system spec

* Fix editor approval file

* Update video_controller

* Update TagAdjustmentUpdateService's spec

* Update users api spec

* Update stories_index_spec

* Remove redundant spec file

* Remove residual code

* Change ClassifiedListing spec

* Update NotificationsIndex spec
2019-05-25 11:04:38 -04:00
Anna Buianova
a6091fe6c8 Moved notifying followers to a separate ActiveJob #1996 (#2935)
* Moved notifying followers to a service + specs

* Created an ActiveJob for notifiable action notifications

* Call the job from the Notification#send_to_followers

* Refactor creating notifiable action notification

* Handle possible nil followers while sending notifiable action notification

* Use activerecord import to bulk-create notifications

* Set notified_at for the bulk-created notifications

* Move compact to the appropriate place
2019-05-24 07:45:51 -04:00
cyrillefr
abb4831a53 Move remove_all notifications method in own job (#2882)
- that calls a service
    - spec for job + service
    - check actual integration spec
    - minor refactoring
2019-05-20 13:54:39 -04:00
Anna Buianova
265dc3761b Fix #2784, Don't fail when twitch returns no user data (#2865) 2019-05-17 10:54:29 -04:00
cyrillefr
68f06c2076 send_milestone_notification in own job (#2804)
- that calls a service
  - spec for job + move spec to service
  - minor refactoring
2019-05-16 13:46:50 -04:00
Anna Buianova
dd0fbf002b ActiveJob for updating notifications #1996 (#2839)
* Notifications::Update service

* Update notifications ActiveJob

* Raise an exception when wrong notifiable class passed to a job
2019-05-15 12:37:25 -04:00
Anna Buianova
24bdfb1ef5 Remove unused ModerationService (#2805) [ci skip] 2019-05-13 16:16:06 -04:00
cyrillefr
ecdbee64ab Move tag adjustment notification to Active Jobs (#2654) 2019-05-10 11:06:29 -04:00
rhymes
260fe901b8 Refactor Comments::BustCacheJob to use a service (#2655) 2019-05-09 10:10:37 -04:00
Corey Alexander
23ded947e3 Twitch Webhook Fixes (#2692)
* Twitch Webhook Registration Fix

This fixes the broken twitch webhook registration. I previously added
the `to_json` when I was switching to using HTTParty and working through
WebMock. I apparently forgot to test this manually however after and
relied on the specs that had some baked in bad assumptions.

This removes the `to_json` and configures the mocking properly in the
spec setup.

I tested locally that this can now succesfully register for webhooks
with Twitch!

* Fix Webhook verification digesting as well, hardcode the specs for durability

* Refactor to use shorter digest method

* Add cache buster lines from Bens branch
2019-05-05 11:52:43 -04:00
Anna Buianova
dd11478659 Change format of the user languages_settings #2369 (#2496)
* Change format of user preferred languages

* Make sure user language settings are set by default

* Add missing expect to the user spec

* Fix users/misc template

* Move existing languages to a constant

* Remove commented user code

* Move languages out of User model

* Update preferred languages accordingly to the available languages

* Set user estimated language only if the language is available

* Fix Portuguese spelling #2582
2019-04-30 17:01:19 -04:00
Corey Alexander
ec388804df Embed Twitch Live Streaming (#2591)
* Get a job created that can create a webhook subscription for a twitch user login

* Remove ngork url

* Refactor add store the access token in the cache

* Get a controller stood up to recieve the webhooks. Now they just need to be processed

* Get User columns added and got webhook controller bones working

* Update the webhook job to use the User

* Add a way for the User to input their Twitch User Name. Plus a linter fix

* Delay webhook registration when profile is updated

* Don't add _ in username

* Use String columns

* Quick fix and add some more requests specs

* Specs for the webhook job

* Get a show page Twitch Live Streams. Just a straight embed of the Twitch Everything Embed UI. Works surprisingly well responsively, and works on all screen sizes

* Fix Gemfile.lock from merge issues

* Add support for expired tokens and add spec

* Add secrets to webhook registration and clean up spec to remove token logic

* Verify webhook secret and spec it

* Add rake task to enqueue webhook registration for all Users. This can be used from Heroku Scheduler

* Update the lease seconds to be for 5 days

* Actually lets do 7 so we can refresh twice a week and try to make sure that we can always miss one

* Hijack the existing Twitch logo instead of making a duplicate one

* Remove comment and replace with log line

* Remove some white space

* Log to Airbrake when webhook errors occur

* Move to passing in an id instead of User object

* Extract logic from Job to Service object

* Capitilize in the view

* Move out of models and into services

* Remove letover stub

* Remove one usage of Faraday

* Use HTTParty for all the HTTP here
2019-04-29 18:11:53 -04:00
Anna Buianova
2ea6accec1 Fix name resolving error on export (#2612)
* Fix name resolving error on export

* Fix exporter service spec
2019-04-29 15:37:50 -04:00
rhymes
743316b528 Move send new badge achievement notification to ActiveJob (#2474) 2019-04-29 10:51:08 -04:00
cyrillefr
c3cb6d9b66 Move moderation notification to Active Jobs (#2550)
- send_moderation_notification in own job
    - that calls a service
    - specs for job + service
    - minor refactoring
2019-04-29 09:21:15 -04:00
cyrillefr
f3f8a51e35 Move Welcome Notification to Active Jobs (#2485)
- creation of welcome notification is in own service
  - which is called by an active job

Resolves: #1996
2019-04-22 13:49:18 -04:00
Anna Buianova
d27874adc9 Move estimating user default language to ActiveJob (#2373)
* Move estimating user language logic to a service object

* Call a service from a User#estimate_default_language!

* ActiveJob for estimating default user language

* Call ActiveJob from the User#estimate_default_language

* Handle nil user email when estimating default language

* Switch user.estimate_default_language_without_delay! to estimate_default_language! in specs
2019-04-13 15:54:22 -04:00
Andy Zhao
d1241d3c16 Touch profile_updated_at when updating social usernames (#2386)
* Use better description for test

* Test for new profile_updated_at touches

* Touch profile_updated_at when removing an auth

* Touch profile_updated_at when authing w/ new social username
2019-04-11 16:32:45 -04:00
Andy Zhao
8ef611f879 Remove Honeycomb from the app (#2366)
* Remove Honeycomb related gems

* Remove Honeycomb related code from controllers

* Remove Honeycomb from RSS Reader

* Remove Honeycomb related files

* Remove Honeycomb related tests

* Remove leftover Honeycomb methods
2019-04-11 10:49:35 -04:00
rhymes
d0441bb456 Enable Rails/TimeZone cop (#2334) [ci skip] 2019-04-09 15:38:28 -04:00
Andy Zhao
53d3091f73 Add single article functionality to articles analytics (#2339)
* Add specs for single article functionality

* Add single article functionality

* Use article_id instead of single_article_id

* Add published: true when querying for one article

* Use article_id in specs oops
2019-04-08 19:57:13 -04:00
Anna Buianova
4ef7635ae0 Don't make additional SQL query on remembering user (#2335)
* Don't save when remembering user on sign in (WIP)

* Specs for AuthorizationService
2019-04-08 10:12:19 -04:00
rhymes
3b4bda89df Upgrade Honeycomb gem, fix and improve RssReader tests (#2319)
* Switch from deprecated honeycomb-rails to honeycomb-beeline

* Improve error handling, tests and add refactoring

* Fix multiple fetching test and add one more

The test wasn't actually testing the correct behavior, because the class
by default force fetches. It worked because it wasn't reloading the user
from the database.

* Test that Honeycomb's client is doing its thing

* Use some defensive programming to avoid any possible problem during shutdown

* Fix typo

* Use the new API to add fields to the current measured event

* Use default instrumentation and add user info to event

* Replace user.email with user.username, less personal data around

* Use mocking instead of calling Honeycomb.init

* Freeze time before traveling

* Remove a flaky test dependent on rand
2019-04-07 15:27:53 -04:00
rhymes
5e9867ec56 Simplify AnalyticsService code (#2308)
* Add basic tests for Analytics service

* User/Organization are always required

* Add some data to the test

* Use queries and date times

* Fix AnalyticsService interface in the controller

* s/HTTP_API_KEY/api-key

* Defend against nils and support datetime objects

* Update app/services/analytics_service.rb

Co-Authored-By: rhymes <rhymesete@gmail.com>

* Use SQL sum, not Rails sum

* Group average_read_time

* Use SQL, not Rails

* Use ISO date

* Fix specs
2019-04-04 16:07:57 -04:00
Anna Buianova
509c11e86f New comment notifications to Active Jobs #1996 (#2287)
* Send new comment notification service + specs

* Call new comment notification service from the model

* Return to non-bang notifications create

* An ActiveJob for the new comment notifications

* Call comments notification ActiveJob from Notification
2019-04-03 11:38:30 -04:00
Anna Buianova
e1968e815b Extract new reaction notification to ActiveJob (#2122) 2019-03-25 13:54:21 -04:00
Tim Lange
3494264404 Enabled rubocop/lint (#2130)
* WIP: Enabled rubocop/lint

* FIX: Fixed failing test

* FIX: Small change to return

* FIX: Changed indent
2019-03-21 10:53:44 -04:00