Commit graph

427 commits

Author SHA1 Message Date
rhymes
dd0ee3dd72
Optimize Admin::FeedbackMessagesController by adding proper indexes (#12415)
DEV has 30+ million email messages, to display some of them to the admin, they
all are scanned to find those that belong to the requested feedback messages.
This results in SQL queries that can take up to 15 seconds.

By adding an index, we cut the SQL response time to milliseconds.
2021-01-25 17:02:06 +01:00
Ridhwana
2dad0c42f8
Save Data Update Script errors to database and show them on http://localhost:3000/admin/data_update_scripts (#12348)
* feat: add an error column to the data update script

* feat: save the error to the error field

* feat: save the error when the script fails

* feat: show the script error on the data update script page

* chore: pass the error to mark_as_failed instead of having its own function

* refactor: use presence

* test: ensure that we test an error case of a data update script

* chore: rename errorneous to failing

* test: update some specs, working on the others

* chore: update tests now that there are two files

* chore: change error from a string to a text to allow for more char
2021-01-21 14:48:34 +01:00
Andy Zhao
8d462801ec
Add new cache key for article sidebar & bottom_content (#12185)
* Add new cache key for article sidebar & bottom_content

* Trigger build

* Undo automatic changes from 'merge conflict fixes' commit

* Revert to actual previous version, oops

* Trying again...

* Trying again...

* Trying again...

* Remove unnecessary variable

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

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2021-01-19 14:03:15 -05:00
Michael Kohl
b5a9eeb95e
Remove contact_consent from users (#12196) 2021-01-12 16:18:47 -05:00
rhymes
3c78c66f7d
Feeds::Import: add index to users.feed_fetched_at (#12201) 2021-01-11 17:05:10 +01:00
Michael Kohl
2e202b0399
Remove looking for work columns (#12173)
* Remove looking for work columns

* Fix schema.rb

* Undo accidental change

* Update spec
2021-01-11 11:22:39 +07:00
Arit Amana
ad52f7b0f3
Rollback Listing Endorsements implementation (#12136)
* all but schema and mig file

* drop ListingEndorsements table

* actually drop the table (sheesh!)
2021-01-06 11:01:29 -05:00
Fernando Valverde
fcc5c0d2a1
Add Sign in with Apple (#11934)
* Add gem omniauth-apple

* Integrate omniauth-apple

* Integrate callback

* Add fields

* Add tests, fix bugs and make it all work

* Show only enabled providers for the current user

* Add default profile image for Apple

* Remove localhost patch

* Bring over the changed Apple username if the user changes it

* More specs fixed

* Incorporate feedback from PR

* Fix specs

* Simplify code and fix spec

* Fix Broadcast generators to take into account the new provider

* Fix spec

* Generate a truly unique apple_username

* Fix user specs

* Add omniauth-apple-0.0.2 to vendor cache

* Fix merge conflict and spec

* Update VCR fastly sloan cassette

* Revert "Generate a truly unique apple_username"

This reverts commit 2462875575b0bbd6b3c1d56b25afcd3189671608.

* Fix user specs

* Fix specs

* Fix specs

* Hide Connect Apple button behind a feature flag

* Revert "Hide Connect Apple button behind a feature flag"

This reverts commit 105bde0373389a4eb9b6e948f60734c7e0e99cba.

* Fix line lengths

* Fix spec

* ES tag

* CSRF bypass for Apple callback

* custom user_nickname in Apple provider with small tweaks + omniauth-apple bump

* Fixes username specs

* Makes Apple users default image Users::ProfileImageGenerator

* Fallback to mascot_image_url in test environment to avoid breaking Travis

* Fixes Apple CSRF error + makes default nickname more readable

* Trigger Travis

* Better devise config

* Apple SiteConfig entires in /admin/config

* Fixing specs

* Adds beta_access? to Authentication::Providers::Provider

* Fixes specs

* Codeclimate double quote fix in Gemfile

* Fixes /admin/config allowed params & adds feature flag for provider beta_access?

* Remove Enfile & adds temporary docs

* Adds custom apple auth provider settings

* Fix authenticator spec

* Fix configs spec (use last instead of first to avoid apple special case)

* Remove dangling fields from /admin/config

* updates feature flag

* More test fixes

* Hide config behind feature flag too

* omniauth-apple bump

* Takes care of edge case fallback

* Reverse apple_username update

* Adds auth_time to info hash in apple omniauth mock

* Switch to next instead of nesting for feature flag

* Fixes CVE-2015-9284

* Fixes specs after auth providers initiatior refactor from GET to POST

* Spec fixes

* More spec fixes

* Fix Rails codebase reference link

Co-authored-by: rhymes <rhymesete@gmail.com>
Co-authored-by: rhymes <rhymes@hey.com>
2020-12-18 10:22:33 -06:00
Anna Buianova
5430448305
Confirmations that users GDPR data was deleted (#11039)
* Display gdpr delete requests for deleted users in admin

* Added a test for destroy a gdpr request

* Reorganized gdpr requests menu

* Update schema version

* Added a link to the flash notice after user delete by admin

* Fix namespace for tests

* Aligh schema.rb with master

* Added a missing newline

* Removed unused partial

* Fix typo

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

* Replaced string with symbols for AR

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

* Added an AuditLog record on gdpr delete confirmation

* Make email and user_id required in Users::GdprDeleteRequest

* Checked out package.json from master

* Fix Gdpr => GDPR

* Added missing space

* Remove unneeded freeze

Co-authored-by: Michael Kohl <me@citizen428.net>
2020-12-14 12:49:45 +03:00
Jacob Herrington
692acd3cb2
Render Profile Fields on user profiles (#11485)
* Render left sidebar attributes on profile

* Display header profile fields

* Make changes to protect DEV data

* Don't render DEV header fields twice

* Wrap profile UI changes in a FeatureFlag

* Add spec to test mulitple display areas

* Use select over reject

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

* Move comment for documentation generators

* Update dev profile fields csv data

Co-authored-by: Michael Kohl <me@citizen428.net>
Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
2020-12-09 09:41:11 -06:00
Michael Kohl
de119f59c1
Remove unused index_notifications_on_json_data (#11725)
Co-authored-by: rhymes <rhymes@hey.com>
2020-12-04 15:31:16 -05:00
rhymes
41fbe24235
Fix schema.db whitespace (#11729)
* Fix schema.db whitespace

* Disable flaky spec
2020-12-03 15:35:29 +01:00
Michael Kohl
8f5cfa2c0f
Drop profile columns from user (#10707)
* Prepare to drop profile columns from user

* Update code and factory

* Also remove unused constant

* Move validation from user to profile

* Remove Profiles::ExtractData service object

* Add more comments

* Simplify sameAs attribute generation

* Obey me machine, I am your master

* Fix condition order in guard clause

* Temporarily disable callback

* Fix specs

* Reduce usage of Profile#refresh_attributes!

* Remove leftover comment

* Handle social media links differently

* More spec fixes

* Fix specs for admin profile fields controller

* Fix specs after merge

* Fix remaining specs

* Update user show request spec

* Add comment for follow_hiring_tag

* Only save profile when user is valid

* Fix seeds.rb for profile fields

* Switch from before_save to after_save

* Undo unrelated formattin change

* Update spec/fixtures/files/profile_fields.csv

Co-authored-by: Molly Struve <mollylbs@gmail.com>

* Remove data update script and spec

* Fix spec

* Fix typo in comment

* Fix typo in comment

* Move article resave logic to service object

* Move profile field creation to before(:suite)

* Refactor error handling in Profiles::Update

* Fix Profiles::Update specs and refactor

* Temporarily disable spec

* Add ProfileValidator

* Clean up

* Move DB ready check into app/lib

* Refresh attributes after importing from CSV

* Fix specs

* Remove unused file

* A girl has no name. A profile neither.

* Fix specs

* Add responds_to? check

* Spec fix

* Add name to user fields in profile settings page

Co-authored-by: Molly Struve <mollylbs@gmail.com>
2020-12-03 08:14:38 +07:00
Nenad Pantelić
ad04158b90
Add podcast_appearances joined table (forem#82) (#11354)
* Add podcast_appearances joined table (forem#82)

* Add podcast appearances keys unique constraint and creator property (forem#82)

* Add podcast_appearance role validation forem(#82)

* Add spec test for podcast_appearances model (forem#82)

* Small refactoring - place podcast appearance association by alphabetical order

* Adapt m2m association to pass rspec test (forem#82)

* Rename podcast appearance model to podcast episode appearance and remove fk indexing

* Rename podcast appearance model to podcast episode appearance and remove fk indexing

* Rename podcast episode appearance models and spec models. Update podcast episode and user spec tests (forem#82)

* Rename podcast episode appearances composite index to follow Rails naming pattern (forem#82)

* Remove ddl_transaction disabling and conurrent index adding from appearance migration

* Add role validation in model spec (forem#82)
2020-11-30 17:12:52 +01:00
Ben Halpern
d759ac4627
Add implicit points to follows to improve feed relevancy (in all algorithms) (#11513)
* Fix menu dropdown disable issue

* Initial base work

* Add real algorithm

* Add working object and test

* Fix schema

* Fix schema

* Fix schema

* Finalize

* Add update script and explict_points

* Proper implicit/explicit points

* Fix tests

* Add docs

* Fix tests

* Fix data update script test

* Fix data update script test

* Fix typo

* Improve efficiency and add more logic

* Changed to find_each

* Change to bulk insert

* Update tests and refactor logic

* Various improvements

* Fix typo

* Fix tests

* Remove extra line

* Fix tests

* Fix test typo

* Cache site-wide tag names
2020-11-25 16:09:51 -05:00
Thomas Bnt
3d8049697a
Edited URLs settings/ux to settings/customization (#11618) 2020-11-25 12:29:12 -05:00
Manasa
b015690f4f
Podcast ownership join table (MLH Fellowship #81) (#11410)
* added podcast_ownership route

* added podcast_ownership table

* added podcast_ownership controller and pundit policy

* fixed codeclimate

* removed controller and pundit policy

* codeclimate

* codeclimate

* schema.rb

* schema.rb

* schema.rb

* user.rb

* made the suggested changes

* added validations

* fixed build error

* changed name to owned_podcasts

* added validation and tests

* added tests

* added tests

* changed spec

* added factory

* added factory

* merge conflict

* factory

* factory

* factory

* modified spec file

* modified spec file

* fix build error

* added class_name

* adjusted m2m relations

* made suggested changes

* fixed build error

* added subject

* schema

* ran migration

* removed index:true from singular fields

* changed schema file

* set index: false
2020-11-19 12:41:17 +01:00
rhymes
f40975701b
Add partial index on users.feed_url (#11411) 2020-11-16 17:10:48 +01:00
Alexandre Ruban
ad747a271f
Fix rails db:seed error (#11272)
rails db:seed sometimes tries to create two 'vomit'
reactions on the same Article which is prohibited by the
validations on the Reaction model.
2020-11-04 10:55:05 -06:00
Molly Struve
de94a3fb9d
[deploy] Schema Fix:Removed accidentally added changes (#11168) 2020-10-29 16:14:00 -05:00
ludwiczakpawel
5d3691bcc5
Notifications redesign (#11084)
* notifications

* fix

* .

* REVERT

* .

* drop ccss

* REVERT

* specs

* drop colons

* fixse

* fix

* spec 1

* eh

* Fix notification specs

Co-authored-by: Molly Struve <mollylbs@gmail.com>
2020-10-29 20:38:17 +01:00
Jacob Herrington
8c3c4fb951
Explicitly set a resource type in seeds (#11050) 2020-10-26 12:27:51 +01:00
Jacob Herrington
4dde307a43
Fix NoMethodError for tag moderators channel (#11047)
* Fix NoMethodError for tag moderators channel

In development, it is possible to hit a NoMethodError when adding a tag
moderator because the "tag-moderator" slug is hard-coded.

This change helps mitigate that by adding a safe navigation operator. We
can always remove it if we decide to get rid of the hard-coded value.

Secondarily, it adds this channel to the seeds file, since we pretty
much expect it to exist.

* Move nested conditional
2020-10-23 21:02:54 -05:00
Ben Halpern
2d75d6d5ea
Fix missing registration data change (#11008)
* Fix missing registration acknowledgment

* Add backfill script and seeds adjustment

* Update lib/data_update_scripts/20201022161311_backfill_user_registrations_in_registrations_controller_path.rb

Co-authored-by: Molly Struve <mollylbs@gmail.com>

Co-authored-by: Molly Struve <mollylbs@gmail.com>
2020-10-22 19:21:03 -04:00
Jacob Herrington
c3a98db026
Make default admin a super admin (#10966) 2020-10-20 13:22:01 -05:00
Molly Struve
bd96abcd1e
[deploy] Fix Reading List Counter Without last_reacted_at Default (#10933) 2020-10-19 13:26:19 -05:00
Molly Struve
4dbfc21407
[deploy] Revert "Fix reading list counter (#10763)" (#10932)
This reverts commit 1f17451c8e.
2020-10-19 12:54:31 -05:00
Takuma
1f17451c8e
[deploy] Fix reading list counter (#10763) 2020-10-19 11:22:57 -05:00
Michael Kohl
adb41a0a15
Uncheck email preferences by default (#10919)
* Uncheck email preferences by default

* Fix specs

* Update app/javascript/onboarding/components/__tests__/EmailPreferencesForm.test.jsx

Co-authored-by: Molly Struve <mollylbs@gmail.com>

Co-authored-by: Molly Struve <mollylbs@gmail.com>
2020-10-19 10:20:03 -04:00
Ridhwana
66b14fc0bf
[deploy] Dynamic frontend for the sidebar navigation Items (#10754)
* feat: configure the frontend for sidebar nav links

* chore: add a comment

* changes to the admin interface

* feat: move the temporary task to be in the rake tasks and use it in the dev seeds

* feat: use the task in the rake seeds

* refactor: reuse the form across two modals

* refactor: use the form partial

* feat: change the modal to be large

* fix: naming

* Update db/seeds.rb

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

* chore: make the file readable

* chore: removed the if else as the rake task was run on all forems + i sent out a message to new communities

* oops

* refactor: add a scope

* chore: oops removed this

* feat: add navigation links specs

* spec: fix two failing ones

Co-authored-by: Michael Kohl <me@citizen428.net>
2020-10-12 16:05:47 -04:00
Michael Kohl
621d9a2bf1
Remove Twitch-related columns from users table (#10750) 2020-10-09 14:17:35 -04:00
Ridhwana
19c78d6072
[deploy] Prepare the database for the configurable navigation items (#10662)
* feat: add the order of the navigational items to the database + admin interface

* refactor: rename :display_when_signed_in to :display_only_when_signed_in

* chore: rename all instances of display_when_signed_in to display_only_when_signed_in

* feat: add a data script that will setup the base urls

* feat: add a temporary rake file that will allow us to seed prod db's

* chore: oops rename file

* chore: remove the index for now

* chore: remove validation

* feat: change the order field to position and add an index o the name and url

* feat: update everything that uses order to position

* refactor: order by name as a secondary attr
2020-10-07 11:20:32 -04:00
Josh Puetz
c0272357c0
Add default admin to seeds file (#10620)
* Add default admin to seeds file

* Docs
2020-10-06 08:25:25 -05:00
Julianna Tetreault
8a01ed6a2c
Removes second_user_id and third_user_id From the Articles Table (#10383) [deploy]
* Removes second_user_id and third_user_id from the Articles table

* Adds updated schema file to (fingers crossed) resolve Travis failure

* Adds gaurd clause to data_update script to mitigate db issues
2020-10-02 13:14:32 -06:00
Ridhwana
21389ab05d
Admin Panel for Configurable Navigational Links (#9444) 2020-10-02 11:11:21 -04:00
Julianna Tetreault
c87974b7ac
[deploy] Add co_author_ids to Articles (#10339)
* Replaces second_user_id and third_user_id with co_author_ids on the Articles table

* Adjusts migration that adds co_author_ids to also add array: true

* Replaces second_user_id and third_user_id with co_author_ids in all applicable files
  - Use co_author_ids in _individual_article view
  - Use co_author_ids in articles and stories controllers
  - Use co_author_ids in article and podcast_episode models
  - Use co_author_ids in article_dashboard
  - Use co_author_ids in comments_helper
  - Use co_author_ids in articles_spec

* Replaces second_user_id and third_user_id with co_author_ids in article.rb model

* Remove unused #assign_co_authors method from the Stories::Controller

* Add #co_authors and #co_author_name_and_path to article_decorator.rb

* Adds a descriptive form field for co_author_ids for Admins in /admin/articles

* Adds a conditional in article/show.html.erb to render co_author names on an Article in a human-readable way

* Replaces get_co_author_name_and_path with proper method name, co_author_name_and_path in show.html.erb

* Adds latest schema to (hopefully) resolve Travis conflicts

* Adds the safe operator to show.html.erb

* Adjusts articles_spec.rb to use an array in the first test

* Replaces unless &.empty? with if ./present? in articles/show.html.erb

* Replaces second_user_id with co_author_ids in stories_show_spec.rb test

* Replaces elsif with else in articles/show.html.erb

* Cleans up show.html.erb by removing conditional in favor of decorator method

* Refactors splitting of params in Articles::Controller and optimizes query in #co_authors

* Reverts removal of second_user_id and third_user_id and migration file

* Adds a data_update script to update co_author_ids with existing second and third user_ids

* Adds validations to co_authors and flash_messages to indicate whether an update was successful or not
  - Adds to methods to article.rb to validate the IDs of co_authors and authors
  - Adds flash messages to the Admin::Articles::Controller and a redirect to the show page
  - Removes the JS highlighting upon submit when updating an Article in Admin
  - Refactors #update action in Admin::Articles::Controller

* Adds tests to article_spec.rb around co_author_id validations in article.rb

* Adjusts #validate_co_authors_must_not_be_the_same to use .include? instead

* Uses Field::Select.with_options in article_dashboard.rb to properly display co_author_ids

* Reverts removal of assigning co_author_ids in the Stories::Controller

* Adjusts error message and adjusts return logic in article.rb (thanks, Fernando!)

* Fixes failing article_spec.rb test that checks for co_author_ids uniqueness

* Adds a default array to co_author_ids and checks if they are .blank?

* Refactor data_update script to use a single SQL statement (thank you, Michael)

* Preserve array order of co_author_ids in article_decorator.rb

* Add db file for default: []

* Add validation to fix bug related to text inputs and invalid users when adding co_authors

* Adds tests to ensure that co_author_ids are both an integer and an integer > 0

* Updates admin/articles_spec.rb to default [] instead of nil

* Adjusts validations in article.rb to be DRY-er and more consistent

* Consolidates validations further

* Refactors validations in article.rb to use procs

* Refactors data_update script to remove nil values from array
2020-10-02 11:06:11 -04:00
rhymes
4e352020a9
[deploy] Remove additional superfluous indexes (#10530) 2020-10-02 16:20:08 +02:00
rhymes
aac94bb576
[deploy] Remove superfluous indexes on notifications (#10514) 2020-10-01 13:25:44 -04:00
rhymes
d7976a75d6
[deploy] Add missing FKs to BadgeAchievements BanishedUsers BufferUpdates (#10366)
* Add missing FKs to BackupData BadgeAchievements BanishedUsers BufferUpdates

* Add relations and specs

* Fix specs

* Trigger Travis CI

* Remove traces of backup_data has it has been removed on master

* Fix trailing whitespace
2020-09-29 21:43:14 +02:00
rhymes
0ca4e8b371
[deploy] Add missing FKs to FeedbackMessage, Note, Taggings, Tag, and UserRole (#10376)
* Add missing FKs to FeedbackMessage, Note, Taggings, Tag, and UserRole

* Add missing relations and specs

* Fix spec
2020-09-29 16:49:47 +02:00
Molly Struve
1a88905465
Refactor:Remove BackupData Table from Postgres (#10422) 2020-09-24 10:09:20 +07:00
Rafi
d570edcf07
Showing date in listing tile (#10217)
* Showing date in listing tile

* Displaying date in listing tile

1. Sending created_at in listing search API
2. Global util functions for short and long date formatting
3. New date util functions extend timestampToLocalDateTime
4. Converting div to time tag
5. Adding title attribute for date

* originally_published_at column

* Displaying originally_published_at date

* Fixing test in modal

* Fixing all listing test

* Fixing casing of dateTime

* Adding tests for originally_published_at

* Reverting to bumped_at

* Backfilling only published listing

* Removing ReIndexListingWithOriginallyPublishedAt
2020-09-21 10:14:26 +02:00
Lennart Melzer
b24c96010d
add image in podcast seeds in suggested way (#10371)
as described in [the carrierwave wiki](7041728c73)

otherwise seeding fails on Podcast validations:

```
ActiveRecord::RecordInvalid: Validation failed: Image Image has an unsupported type, Image can't be blank
/opt/apps/bundle/gems/activerecord-6.0.3.3/lib/active_record/validations.rb:80:in `raise_validation_error'
/opt/apps/bundle/gems/activerecord-6.0.3.3/lib/active_record/validations.rb:53:in `save!'
...
/opt/apps/forem/db/seeds.rb:267:in `block (2 levels) in <main>'
/opt/apps/forem/db/seeds.rb:266:in `each'
/opt/apps/forem/db/seeds.rb:266:in `block in <main>'
/opt/apps/forem/db/seeds.rb:19:in `create_if_none'
/opt/apps/forem/db/seeds.rb:206:in `<main>'
```
2020-09-18 09:06:37 +02:00
rhymes
5ba8c44b05
[deploy] Add missing foreign keys to ahoy_messages and articles (#10321)
* Add FK between ahoy_messages and feedback_messages

* Add FKs between articles.second_user_id, articles.third_user_id and users

* Fix associations and specs

* Add more validations

* Remove FKs to articles.second_user_id and .third_user_id as they are about to be removed
2020-09-16 19:47:03 +02:00
rhymes
f0b124cc26
[deploy] Add unique index on articles user_id, title and body_markdown (#10284)
* Add unique index on articles user_id, title and body_markdown

* Add test
2020-09-14 16:11:12 +02:00
Molly Struve
111dc4ea9d
[deploy] Bug Fix: Add New Migration to Remove Active from Profile Fields (#10279) 2020-09-11 08:49:27 +02:00
Michael Kohl
4ae59b56e3
Add custom profile fields (#10202)
* Add custom_profile_fields table

* Add CustomProfileField model and refactor

* Remove trailing whitespace

* Stop ignoring removed column

* Add explanatory comment

* Update service object

* Fix bug in service object

* Refactor and fix specs

* Increase limit from 3 to 5

* Update comment to reflect code changes
2020-09-09 14:37:15 +00:00
rhymes
5c7fc79507
[deploy] Add unique index on articles feed_source_url (#10208)
Co-authored-by: Molly Struve <mollylbs@gmail.com>
2020-09-08 14:34:34 -05:00
rhymes
99b239bb80
[deploy] Add unique index on articles canonical_url (#10161) 2020-09-04 14:19:13 -05:00
Jacob Herrington
00c75d0bb2
Add sponsorships to seed data (#10189) 2020-09-03 13:34:00 -04:00