* Remove mock from specs to test the actual Suggester
* Fix articles API top articles n+1
* Fix n+1 in articles API with state parameter
* Remove eager loading for organization dashboard
* Eager load notifiables in notifications only when needed
* Algolia does not like this
Fragment caching does not support an explicit expiration date for simplicitly, which means that cached resources are tied to the update datetime of the model.
In this case unfortunately this is not sufficient: a cached time that potentially never gets expired can stale quickly when applied to a time sensitive item like a notification.
Since the "time ago" computation is not particularly heavy and notifications are paginated, I ended up removing that part from the cache altogether.
As a byproduct I created two new separate cache keys for the article notification, one of each section surrounding the time.
* Increase efficiency and fix pagination offset issue
Right now we filter recently aggregated notifications at runtime, which worked before when there was no pagination, but now filtering is not a good idea combined with offset pagination because it throws off the calculations.
The filtering should be done in the SQL query before paginating, which is what we've switched to. I added a bunch of scopes to make the code clearer as well.
To avoid nesting tags I've also updated the HTML and the JS logic to insert it in the right place.
* Add explanation for hiding the load more button for new users
* Use offset instead of page and explain things
* Make load more button work
* Add tests for admin view
* Restore the previous logged out behavior
* Modernize initNotifications.js
* Revert "Modernize initNotifications.js"
This reverts commit 4a112b797d7911c4ab63ad0c0a07111b4e7abe25.
* Fix elements presence errors
* Change load-more-button to only appear if 7 or more posts (and some notification copy adjustments)
* Allow user to have many orgs
* Allow users to handle multi orgs in settings
* Make rounded buttons inline
* Add multi org function to dashboards
* Fix merge conflicts
* Fix mistake in merge conflict fix oops
* Display the correct membership level
* Fix accessibility issues
* Display organizations for article editors
* Handle submitting org id with preact editors
* Make listings work with multiple organizations
* Allow listings to have multiple orgs on create
* Display the correct number of credits for each org
* Move script tag to Webpack
* Allow multi orgs for purchasing and viewing credits
* Use OrganizationMembership as authorization check
* Display multiple organizations for notifications
* Allow dashboard to be viewable under multi-orgs
* Remove unused method
* Add multi-org functionality for article editors
* Show pro dashboard buttons for member+ org levels
* Leave the correct organization
* Allow article API to change org id
* Add left-out authorization method oops
* Make nav buttons a bit more clear
* Fix merge conflict
* Fix adding org id for /api/articles and tests
* Fix tests for org policy
* Use proper logic for displaying org members
* Update org actions with new authorization
* Use correct org when creating a listing
* Remove additional payment charge oops
* Mark org notifications as read with authorization
* Remove deprecated post_as_organization attribute
* Use new org_admin syntax
* Remove deprecated org logic for article create and update
* Default all RSS posts to not belong to any org
* Render org_member page for guest users
* Update org policy spec to work with multi orgs
* Use org_membership for org traits and move identity code
* Use org_member trait
* Update to work with multi-orgs
* Validate article's org_id if param org_id is blank
* Make a let variable
* Remove unnecessary eager load for credits
* Fix HTML structure and org logic for non-org users
* Update credits spec for multi-org
* Add test for failed payment when purchased by org
* Lint listings_spec
* Test that the listing was created under the user
* Add tests for POST /listings multi-org
* Use double quotes for classes
* Fix /manage and a few other multi-org bugs
* Fix test for multi org
* Use correct method SQL exists? not Rails exist?
* Fix reads spec for multi-org
* Fix org_controller actions to work with multi org
* Test only multi org and not old usage and fix leave_org
* Fix org showing user profile img test for multi-org
* Fix org logic for users with no orgs
* Remove switch org functionality
* Update tests and add hidden param for org id
* Redirect to the specific organization
* Test other org button actions
* Use settings_notice instead of legacy notice and refactor
* Fix weird extra end issue prob from merge conflicts
* Test for with new flash key
* Fix user_views_org tests for multi-org
* Test for new flash message
* Update snapshot with new a11y html
* Move styling to stylesheet
* Add site admins functionality
* Move org_member? method in user model and refactor
* Use unspent_credits_count for organizations
* Add tests for /listings/new and minor bug fixes
* Use .present? in case of empty array
* Fix a lingering deprecated method
* Use greater than 1 for random numbers
* Add tests for counting spent and unspent credits
* Add spec for org reaction notification
* Add organization_id to notifications
* Add validations for user and org IDs
* Move comment json_data out of loop
* Use actual column names instead
* Add organization filters
* Remove extra text-align
* Add organization filtering
* Refactor to reduce complexity
* Add receiver argument to handle orgs
* Add has_many notifications for orgs
* Add follow notifications for orgs
* Add comment notifications for orgs
* Rename some tests for specificity
* Add mark org notifications as read functionality
* Add radix to parseInt
* Define json_data outside of loop
* Notify org followers of a new post as well
* Move test to proper location
* Add test for aggregated method
* Make send org reaction notification more readable
* Test the rest of the notification model
* Refactor tag adjustment spec
* Fix extra html
* Remove notifications synchronously on unpublish and destroy
* Asynchronously remove reaction notifications for article
* Remove all associated notifications when destroyed
* Fix edge case for reaction notifications
* Load new comment_box file instead of old one
* Delete legacy views
* Remove unused private declaration
* Use casecmp.zero? instead of downcase for speed, and use @user
* Add friendly error message for notifications
* Use delete all and not destroy b/c no callbacks
* Move follow and reaction aggregation into Notification model to avoid re-compute
* Ugh. Fixing schema
* Update tests
* Skip some tests in notifications_spec
* Remove stream and add new notification views
* Actually remove Stream
* Move followers query to async method
* Remove unused tests and fix query
* Try using without delay instead
* Add without delay and escape HTML
* Make all tests pending for now
* Initial automatic cleanup with rubocop
* Fix syntax error introduced by rubocop
* Cleanup seeds file
* Cleanup lib folder
* Exclude bin folder because it contains auto generated files
* Make Rubocop a little bit more chatty
* Block length should not include comments in the count
* Cleanup config folder
* Cleanup specs
* Updated Rubocop version and generated a todo file
* Fix broken ArticlesApi spec
* Fix tests
* Restored rubocop pre-commit hook
* added organization policy + spec
* user specs for is_org_admin?
* added authroize to organization controller
* admin policy + specs
* deleted enforce admin due to pundit policy redundancy
* applied admin policy to entire admin namespace
* refactoring analytics controller WIP - wanna test codeship
* Add protection against reactions to unpublished articles (#473)
* Add chat channel policy and spec (#474)
* Add comment policy and specs (#475)
* Fix edge case with apostrophes
* Add comment policy and specs
* Add login for deleting comment spec
* Change test to raise pundit error instead of 404
* Clean up comment destroy request specs
* Remove redundant raise
* Whitelist columns on to_json call (#477)
* Add pundit policy for several controllers (#476)
* Add pundit policy for several controllers
* Adjust video spec
* Fix tag request specs
* Add proper twilio tokens request specs
* Remove puts statements
* Add a couple basic request specs (#478)
* Add a few tests and fix user tag color bug (#482)
* Refactor handle_tag_index in stories_controller (#481)
* Modify valid_request_origin? (#483)
* Add misc specs and remove banned attribute from user model (#484)
* Fix missing Cloudinary tags and misc specs (#486)
* removing current_user_is_admin? to use .is_admin? method
* added missing org policy routes
* Add comment for all public controllers
* Fix edge case for test
* Authorize mod controller and add specs
* Refactor methods via inheritance and use only super_admin role
* Create policy method for analytics via article_policy and refactor
* Capitalize all buttons in dashboard page
* Fix org tests and remove old admin test
* Use only happy path for analytics
* Fix tests to use Pundit error
* Update org_policy spec