Fix profiles count in home page category bar view#1560
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes profile counting in the home page category bar by ensuring that only profiles with tags in the current locale (or without locale restrictions) are counted. The changes include refactoring the factory patterns for locale languages and tags to use traits and transient attributes, updating the CategoriesProfilesStats interactor to filter by locale, and adding comprehensive test coverage for locale-specific counting behavior.
Changes:
- Refactored factory definitions to use traits (
:en,:de) and transientlocalesattribute for cleaner test setup - Updated
CategoriesProfilesStatsto filter profiles by current locale using LEFT OUTER JOINs - Added test coverage for locale-specific profile counting in different regions
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/system/tag_spec.rb | Updated to use new factory trait pattern and renamed variables for clarity |
| spec/system/searching_for_profiles_spec.rb | Updated locale language factory call to use trait |
| spec/system/profile_spec.rb | Updated locale language factory calls to use traits and removed trailing whitespace |
| spec/system/admin/tags_spec.rb | Updated to use new factory trait pattern and removed FactoryBot. prefix |
| spec/services/tag_filter_spec.rb | Updated locale language factory calls to use traits |
| spec/models/locale_language_spec.rb | Updated to use new factory trait pattern and renamed variables for clarity |
| spec/interactor/categories_profiles_stats_spec.rb | Added comprehensive tests for locale-specific profile counting across different regions |
| spec/factories/tags_factory.rb | Added transient locales attribute and after-create callback for tag-locale associations |
| spec/factories/tag_slocale_language_factory.rb | New factory for tags_locale_language join table records |
| spec/factories/locale_language_factory.rb | Converted nested factories to traits with default iso_code |
| app/interactor/categories_profiles_stats.rb | Refactored to filter profiles by locale and added locale to cache keys |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # frozen_string_literal: true | ||
|
|
||
| FactoryBot.define do | ||
| factory :tags_locale_language do |
There was a problem hiding this comment.
The filename 'tag_slocale_language_factory.rb' contains a typo. It should be 'tags_locale_language_factory.rb' to match the factory name and the join table model name.
* add the language (I18n) filter to the profiles count and tags count in the category bar * add not translated tags to the query --------- Co-authored-by: Maren Heltsche <[email protected]>
No description provided.