Commit graph

329 commits

Author SHA1 Message Date
Mac Siri
d587ba962d
Add AlgoliaSearchable for User (#20869)
* Add AlgoliaSearchable::SearchableUser

* Update spec

* Refactor

* Refactor

* Add more test

* Refactor

* Update seeder to clear Algolia index if it exist

* All Algolia directly in update_score

* Fix broken spec

* Remove new queue

* Account for more user statuses

* Remove unncessary test for now
2024-04-19 14:03:04 +00:00
Ben Halpern
cbae624b5e
Add billboards to digest emails (#20862)
* Initial bb work

* Add billboards to digest

* Clean up tests and formatting

* Clean up tests and formatting
2024-04-15 12:01:00 -04:00
Anna Buianova
51316c747f
Comments count according to display rules in feed (#20753)
* Move calculating comments score from worker to a service

* Display displayed comments count in feed

* Recalculating displayed comments counts on article show (if needed)

* Rubocop fixes

* Fixed lambda
2024-03-28 12:12:05 +00:00
Anna Buianova
ed1b4045d3
Auto confirm flag reactions when spam role is assigned (#20797)
* Auto confirm flag reactions when spam role is assigned

* Renamed method according to its point

---------

Co-authored-by: Mac Siri <mac@forem.com>
2024-03-27 13:03:41 +00:00
Anna Buianova
1008f0af7d
Automatically resolve spam reports when the offending user is marked as spam (#20781)
* Start resolving spam reports automatically after assigning spam role

* Specs for resolving spam reports + async resolving
2024-03-21 17:31:43 +00:00
Mac Siri
092ee4a425
Implement PageViewRollup (#20670)
* Refactor

* Create PageViewRollup WIP

* Create PageViewRollupWorker and specs

* Add spec WIP

* Write spec

* Refactor

* Add spec

* Prevent retry

* Update baseline date

* Improve specs

* Update ATTRIBUTES_

* Update spec again
2024-03-18 20:33:12 +00:00
Ben Halpern
78f9bec3e7
Allow admin to declare whether to include the badge description in message (#20684)
* Allow admin to declare whether to include the badge description in badge achievement message

* Update spec/services/badges/award_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Add proper acceptance to tests

* Tweak tests

* Switch to kwargs

* Clean up test acceptance

* Change interface

* Update spec/requests/admin/badge_achievements_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/services/badges/award.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Adjust interface

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-02-28 11:02:58 -05:00
Anna Buianova
d0f3fb6fff
Optimize and test comments cache after score change (#20640)
* Add specs for caching article comments, use cache_key_with_version

* Optimize cache busting for spammer comments, reorganized related specs
2024-02-16 14:53:11 +00:00
Anna Buianova
fb09a75352
Update comment updated_at when changing score (#20622)
* Change comment updated_at when updating comment score

* Rubocop fixes
2024-02-13 13:17:24 +00:00
Anna Buianova
b43cb38d40
Remove notifications related to spammer actions (after the role is assigned) (#20593) 2024-02-07 17:36:19 +00:00
Ben Halpern
9b93b12f05
Fix AudienceSegmentRefreshAllWorker args issue (#20576)
* Fix AudienceSegmentRefreshAllWorker args issue

* Update test

* Fix

* Fix test

---------

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2024-01-31 13:48:13 -05:00
Philip How
7d47ffef78
Remove calls to trigger round robin notifications (#20506)
* remove calls to trigger round robin notifications

* remove tests
2024-01-10 13:44:57 +00:00
Ben Halpern
04d4b2340d
Add downstream score effects from spam role (#20498)
* Add downstream score effects from spam role

* Move async score calc down low

* Add tests

* Add stub

* Fix typo

* No need for guard

* No need for guard
2024-01-08 16:25:28 +00:00
Dambar Pun
e5b4f6a7d0
rename to new name to avoid confusion (#20163)
Co-authored-by: Dambar Pun <dambarpun@Dambars-MacBook-Pro.local>
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2023-09-26 08:29:05 -04:00
PJ
da73343540
Skip round robin mod notifications for limited users (#20128)
* return early if user is limited

* fix worker specs
2023-09-19 15:03:20 +01:00
Ben Halpern
3324bf47f1
Add http_header to FastText for Fastly compatibility (#19999)
* Add http_header to FastText for Fastly compatibility

* Update app/services/articles/enrich_image_attributes.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/services/html/parser.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/models/display_ad_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix rubocop

* Also accept canges to main image for this re-calc

* Rename display_ad_spec for compatibility with main

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-08-28 09:34:59 -04:00
Anna Buianova
2d6b740940
Renamed DisplayAd model to Billboard (#19993)
* Renamed Resource Admin: DisplayAd to Billboard

* Renamed DisplayAd to Billboard

* Added a data update script for roles
2023-08-28 08:09:36 -04:00
Ben Halpern
c9af090af0
Prefer Minimagick for social image generation (#19826)
* Prefer Minimagick for social image generation

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Reformat main file

* Fix user tests

* Finish up tests

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Change asset path syntax

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Refactor magickally file

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix style issues

* Remove pure black

* Test color swap

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Add more test coverage to service

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix doubled spec name

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Add upload spec

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/services/images/generate_social_image_magickally_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Swap out magickally in social image worker

* Add test stub and rescue

* Update spec/rails_helper.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix regex

* Add cache busting and error logging

* Update app/services/images/generate_social_image_magickally.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix style issues

* Add more test coverage

* Add feature flag

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-08-11 08:22:06 -04:00
Anna Buianova
e659dbfc00
Renamed display_ad_events variables and associations (#19788)
* Renamed stuff related to display_ad_events (except the model)

* Updated user billboard_events association spec

* Fixed display_ad_event factory
2023-07-21 14:59:28 +03:00
Ridhwana
272aea6127
Allow admins to delete an organization (#19699)
* feat: update the layout for organizations

* feat: update the layout for an organization

* feat: organization logos are square

* feat: change the text on the org visit button

* feat: initialize the dropdown menu

* feat: trigger the  modal

* feat: update the text in the model

* feat: tweak wording

* WIP/feat: hook up a route with an action that calls an organization delete worker.

* feat: redirect after showing the notice

* feat: update the authorization required to be super admin

* feat: add the notice to localization

* spec: integration test

* spec: fix

* spec: delete worker

* chore: update the link

* feat: add safe navigation

* feat: make sure that we show an error if the organization has credits

* fix: error message for modal unspent credits

* feat add the spec for the helper

* fix: remove rspec preface

* fix: small fixes to tests and I18n

* fix: updated the number of orgs

* feat: update the message

* feat: update the message

* chore: remove inclusion of helper

* feat: change the name of the parameter

* chore: newline
2023-07-17 12:09:24 +02:00
Joshua Wehner
bd2e349d86
Fix bugs with article moderator notifications (and make tests less flaky) (#19688)
* Try to mitigate flaky spec by clearing mock space

* Fix for flaky article published spec

* Rubocop

* Tidy up the specs a bit, update the comment

* Modernize article factory (thanks, rubocop)

* Update update spec to use factory

* Use PublishWorker instead of callback

* nth_published_at -> from_newish_author

* Separate published/unpublished specs

* published_at is correct if unchanged

* Add spec for scheduled post
2023-07-14 17:29:45 +02:00
Duke Greene
1798a1f845
notify mod on new user articles (#19478)
* update moderation notification view and message for articles

* update models to allow first published articles to notify mod after create

* update mod notifications worker and spec to support articles

* update mod notification send service and spec to support articles

* update helper and request spec to support article mod notifications

* update spec language to match updated notification message

* Update spec/workers/notifications/create_round_robin_moderation_notifications_worker_spec.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Update spec/workers/notifications/create_round_robin_moderation_notifications_worker_spec.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Update spec/workers/notifications/create_round_robin_moderation_notifications_worker_spec.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Update spec/workers/notifications/create_round_robin_moderation_notifications_worker_spec.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* fix comment and refactor order of send_moderation_notification steps

* add fr.yml article mod notification config

* fix spacing around equal sign per rubocop

* fix spacing around equal sign per rubocop

* Update spec/workers/notifications/create_round_robin_moderation_notifications_worker_spec.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

---------

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2023-05-23 10:51:46 -04:00
Joshua Wehner
375cbfe946
Refresh audience segment for 'active' user (#19470)
* Refresh an individual user's segmentation

* Refresh segment if creating a published article

* Quick refactor

* Refresh segment if update publishing

* Quick refactor

* Refresh segment if update user settings

* Refresh segments after user update + role change

* Using latest_article_updated_at

* Sidekiq uses JSON for arguments, needs basic types

* Fix test issues with last_updated_at and sidekiq params

* Tests update continues

* Consolidate dependencies

* Method names acknowledging manual exclusive

* Fix test name copypasta

* Rubocop

* Try to clarify Creator#series

* Try to avoid naming predicate

* Remove erroneously included helper
2023-05-19 14:16:07 +02:00
Joshua Wehner
dc1ab81401
Allow DisplayAd to target users via audience segmentation (#19284)
* Trying some models for audience segmentation

* AudienceSegment basics

* Attach AudienceSegment to DisplayAd

* Possibly use a DUS to populate AudienceSegments

* Add to display ad form UI

* Add to display ad API

* Refresh strategy for audience segments

* Add user_id to async ads query

* Maybe :testing -> :manual, for no-refresh segment

* Test & tweak segment refresh

* Testing audience_segment#refresh logic

* Coverage: testing human_readable

* Scope segment refresh to recently active users

* Tweak logic for when to refresh

* Tweak experience levels to match SettingsHelper

* Test for front-end logic

* Fix test, hope this helps coverage?

* Better test names

* One worker for all, many workers for each, perform_bulk

* Fix audience segment UI, needs to use id, not enum

* cron/schedule should RefreshAll

* Singular id in RefreshWorker
2023-04-25 08:41:10 -04:00
Ben Halpern
df4568d275
Bust article on initial reactions to fix cached HTML issue (#19149)
* Bust article on initial reactions to fix cached HTML issue

* Fix whitespace issue

* Move cache-busting logic to worker

* Update app/workers/reactions/bust_reactable_cache_worker.rb

Co-authored-by: Joshua Wehner <joshua@forem.com>

---------

Co-authored-by: Joshua Wehner <joshua@forem.com>
2023-02-20 16:31:38 -05:00
Ridhwana
686976ced8
Round Robin Notifications Refactor (#19026)
* chore: rubocop

* feat: rename the worker in accordance to our guidelines and to be more verbose

* refactor: move the NotificationsModeration service to be a users query, and move the constants out to new files

* refactor: removed subscribed_to_mod_roundrobin_notifications? which was only being used once in a test

* refactor: remove the aliass from the user method and add them to notification_setting + update references
2023-02-01 15:21:36 +02:00
Ridhwana
9ba3df4453
Round Robin Notification Tweaks (#18995)
* Remove jQuery

* Added jquery back to videos

* feat: increase the available moderator count

* Removed jquery code

* Nit fix

* Revert incorrect code

* Updated jquery code to javascript

* Removed jquery from comments

* feat: updates the last_reacted_at value when saving a creation

* feat: update the query for available moderators

* spec: write a test for the available moderators

* fic: update the reaction spec with current time

* fix: add last_reacted_at to the send_spec

* fix: add last_reacted_at to the user

* chore: move the queries around

* fix: change timecop block

* fix: update the last_reacted_at for the user

* chore: try to fix timecop

* Update app/services/notifications/moderation.rb

Co-authored-by: Mac Siri <mac@forem.com>

* feat: update the tests

Co-authored-by: rt4914 <rajattalesra4914@gmail.com>
Co-authored-by: Rajat Talesra <rajat@forem.com>
Co-authored-by: Mac Siri <mac@forem.com>
2023-01-26 19:31:45 +02:00
Fernando Valverde
c24e227f55
Extract Organization#conditionally_update_articles to worker (#18956)
* Extract conditionally_update_articles to worker

* Split to individual articles on workergits

* Fix some failed specs

* Fix another spec
2023-01-18 11:58:57 -06:00
Mac Siri
b5fbab0e31
Update ArticleFetchedFeed to use slack workflow (#18801) 2022-12-09 10:46:20 -05:00
Ben Halpern
6aacf2996a
Remove expensive query which is not necessary within app logic (#18689) 2022-11-07 17:04:54 -05:00
Joshua Wehner
3f26694976
Refactor reaction categories as abstract class collection (#18540)
* Try a ReactionCategory abstract 'model'

* Use ReactionCategory

* Lookup category, pre-reaction

* Lookup category > constant

* Category can sometimes be nil?

* Try something friendlier for code reloading

* Refactor: extract point calculation out of Reaction

* Reaction Category can have color

* Rename reaction points service to follow convention

* method signature changed as well, calculate -> call

* Fix typo, leading comment, and rename data structures for clarity
2022-11-01 10:50:37 +01:00
Anna Buianova
f7a93aabbb
Remove html variants tracking (#18594)
* Removed code related to tracking html_variants

* Remove code related to HtmlVariant#find_for_test

* Remove spec for HtmlVariant#success_rate
2022-10-21 14:57:20 +03:00
Joshua Wehner
1fcafbbd41
Rollup service to compact DisplayAdEvent records (#18508)
* Restore DisplayAdEvents.counts_for

* Try a rollup service for DisplayAdEvent

* Schedule daily rollup worker for one month prior

* Refactor aggregator

* More testing for rollup

* Add test for rollup attribute fidelity

* DisplayAd success_rate based on counts_for
2022-10-19 16:21:47 +02:00
Anna Buianova
9d755a9d2f
Save list of previously-published articles when user is subject to an "un-publish all" action (#18535)
* Moved logging and deleting comments to Moderator::UnpublishAllArticlesWorker

* Added logging for admin action (unpublish_all_articles)

* Extracted code from UnpublishAllArticlesWorker to the service

* Make it possible to add a note while unpublishing all via admin action

* Added ability to add notes for unpublishing all from moderator action panel

* Fixed setting slug for the AuditLog on unpublishing + spec
2022-10-06 14:17:20 +03:00
Joshua Wehner
2b24167fba
Try fixing comment like count bugs (#18438)
* Try fixing comment like count bugs

* Tests for the CommentCreator
2022-09-12 10:12:46 +02:00
Mac Siri
e358fdf347
Revert "Nullify published_at when unpublishing an article (#18298)" (#18353) 2022-08-18 13:58:58 -04:00
Anna Buianova
414e17aca6
Nullify published_at when unpublishing an article (#18298)
* Remove context_notifications when unpublishing all posts

* Nullify published_at when unpublishing an article
2022-08-15 20:59:20 +03:00
Anna Buianova
44a401643c
Remove context_notifications when unpublishing all posts (#18287)
* Remove context_notifications when unpublishing all posts

* Fixed typo

Co-authored-by: Mac Siri <krairit.siri@gmail.com>

* Fixed typo

Co-authored-by: Mac Siri <krairit.siri@gmail.com>

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2022-08-10 09:03:52 +03:00
Anna Buianova
cfc0406250
Save button text is always 'Save changes' for editor v1 (#18304) 2022-08-09 22:23:17 +03:00
Anna Buianova
ff76cdd3c5
Scheduling articles (#17939)
* Article query spec for scheduled articles

* Added scheduled article badge on the user dashboard

* Added published_at field to editor options

* Accept and validate published_at from editor

* Refactor published_at validation

* Allow 1-minute difference in published_at

* Notice on an unpublished article page

* Added specs for 'Click to edit' link on scheduled article preview page

* ContextNotification model

* Articles::Publish worker

* Added specs for articles publish worker

* Schedule publish articles worker

* Added tests to check for scheduled posts in feeds

* Don't allow managing scheduled articles

* Don't send notifications for scheduled articles

* Set published_at in Articles::Updater when publishing

* Published_at value in post options

* Pass timezone and set published_at accordingly

* Limit setting published_at to the future

* Readonly published_at for articles that were already published

* Chagning published_at format in editor v1 (start)

* Changed published_at format in frontmatter, specs

* Added specs for updating published_at from frontmatter

* Fixed accepting past published_at for articles published_from_feed

* Enabled published_at validation: don't allow updating published_at for already published articles

* Validate published_at on create

* Added a spec for updating published_at for exported articles

* Fixed specs related to creating articles with past published_at

* Fixed specs related to past published_at for articles

* Added a hack so that admins would be able to update published_at

* Switch button text schedule/publish when changin publishedAt

* Fixed saving published_at with timezone

* Added a feature flag for scheduling articles

* Default text in markdown editor depends on feature flag

* Enable article editor cache again

* Fixed the default value in the markdown editor

* Fix sitemaps spec

* Removed tooltip

* Fixed articles update specs

* Added missing locales

* Fixed article create specs

* Fixed spec

* Removed commented code

* Returned enabling extensions in the schema

* Returned accidentally deleted constraint

* Make articles query spec more stable

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>

* Removed commented code

* Removed unused code

* A clearer policy

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>

* Use StringInquirer for article current state

* Added a note and todo to articles factory past trait

* Remove duplicated PropType

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Refactor query in the Articles::PublishWorker

Co-authored-by: Mac Siri <krairit.siri@gmail.com>

* Refactor articleForm.jsx

Co-authored-by: Mac Siri <krairit.siri@gmail.com>

* Removed specs that are no longer relevant

* Removed useless onKeyUp on a hidden input

* Refactored articleForm

* Hide scheduling from post options when published_at is readonly

* Run sends notifications worker every 5 minutes instead of every minute

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2022-07-07 17:32:49 +03:00
Mac Siri
678dda8cf4
Routine Rubopcop lint fixes (#17844)
* Routine Rubopcop lint fixes

* Undo app_secrets_spec changes

* Fix broken spec
2022-06-07 10:17:16 -04:00
Ridhwana
e72957a913
feat: add an inflection and change instances of gdpr to GDPR (#17567) 2022-05-04 16:20:46 +02:00
Jeremy Friesen
fe2e53cc50
Moving Experiments into AbExperiment namespace (#17532)
* Moving Experiments into AbExperiment namespace

This commit entails two major concepts:

1. Extracting logic out of a worker.
2. Cleaning the conditions in which we convert experiments.

In addition, I revisited some spec names to tidy them up for
clarification and structure.

**Extracting Logic...**

For workers, my preference is that they be a simple router to another
object.  A non-worker object, with it's initialize method, can both
better manage instance variables.  Further, workers are somewhat "flat"
in hierarchy,

In this case, having the AbExperiment be knowledgeable both in setting
the experiment and handling conversions makes (to me) organizational
sense.  For example, the AbExperiment is constructed as a wrapper to the
FieldTest gem.  But the RecordFieldTestEventWorker had knowledge of
FieldTest.

With this refactor, it does not have that knowledge.  This also provided
an opportunity to replace magic strings with constants.

**Cleaning the conditions...**

This relates directly to and closes forem/forem#17530.  I was looking at
the experiments after 2 days, and realized that there shouldn't be
results for
`user_views_pages_on_at_least_nine_different_days_within_two_weeks`;
after all the experiment started 2 days ago, how can we have results
that look at 2 weeks.

By adding the "max" function calls, we ensure a clear boundary of
"before the experiment began" versus "while the experiment is running".

Closes forem/forem#17530

* Update spec/models/ab_experiment_spec.rb

Co-authored-by: Mac Siri <krairit.siri@gmail.com>

* Apply suggestions from code review

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
2022-05-03 21:34:12 -04:00
Ridhwana
3fc6108651
Remove GDPR from the "users" namespace (#17536)
* feat: update all the paths as a first order of business

* feat: update all the folders to no longer appear under users

* feat: update specs

* feat: update specs

* feat: remove User namespace

* feat: remove route namespace

* feat: path change

* feat: update url
2022-05-03 19:42:20 +02:00
Daniel Uber
b2c7f7a5a3
Use Sidekiq::Job module alias for Sidekiq::Worker (#17526) 2022-05-02 11:12:58 -05:00
Daniel Uber
6bf3e2aea9
Skip rescoring draft articles (#17379)
* Skip rescoring draft articles

* add spec for worker
2022-04-21 10:56:59 -05:00
Jeremy Friesen
f1e9e3ff65
Busting tag cache when space changes (#17384)
We avoid busting a user cache for 15 minutes but the tag cache is 5
hours.  So we want to "nudge things along".

What this is trying to solve is the server side rendering of whether we
hide or show a button.

Related to forem/forem#17324
Related to forem/forem#17119
2022-04-20 16:37:34 -04:00
Monica Mateiu
6818ef3ed0
Remove references to article.spaminess_rating (#17235)
* Remove references to article.spaminess

* Update app/models/article.rb

* Update spec/workers/comments/calculate_score_worker_spec.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* remove unnecessary BlackBox spec

* Update spec/workers/comments/calculate_score_worker_spec.rb

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>

* Remove references to calculate_spaminess

* Update app/workers/comments/calculate_score_worker.rb

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
Co-authored-by: Jamie Gaskins <jamie@forem.com>
2022-04-15 11:43:48 -04:00
Jeremy Friesen
3a08716ad3
Reducing subtle duplication of effort/logic (#17078)
Prior to this commit, when we change attributes for a user we might
resave each article.  The purpose of the resave is to update some of the
cached attributes of an article.

This removes some redundant code.  The following removed code has
an `article.save` call.  Which, the callbacks in the article (see below)
already clear the cache.

```ruby
def resave_articles
  articles.find_each do |article|
    if article.path
      cache_bust = EdgeCache::Bust.new
      cache_bust.call(article.path)
      cache_bust.call("#{article.path}?i=i")
    end
    article.save
  end
end
```

8e6981aac5/app/models/article.rb (L164)

8e6981aac5/app/models/article.rb (L881-L888)

This was discovered in triaging forem/forem#17041
2022-04-01 13:32:44 -04:00
Daniel Uber
cc7c342bb5
Limit per-user feed import fanout to users with feed urls set (#16831)
* Limit feeds import fanout to users with feeds

This filtering for feed settings occurs in
Feeds::Import#filter_users_from already, so the enqueued ForUser
jobs were mostly no-op, but the queue latency spiked as hundreds of
thousands of jobs were added to default.

Prescreen users to avoid enqueuing a noop job every hour for every single
user without a feed.

* Update tests to check only jobs for users with feeds are enqueued

* spec cleanup

Only include alice when we check no job is enqueued for her.

Assert no job is enqueued for alice.

Rename bob to user when alice isnt there to contrast.

* Update spec

Use update_columns to bypass setting validation (checking feed is
valid/reachable)

Remove unneeded timecop block when passing a set time

Remove sidekiq: fake and allow Import.call to be received

* Empty commit to trigger CI rebuild
2022-03-09 08:51:00 -06:00