Skip to content

[597] Connected tags to category#101

Merged
Anton-88 merged 5 commits into
mainfrom
597-connect-tags-to-categories-for-case-study-entity
May 23, 2025
Merged

[597] Connected tags to category#101
Anton-88 merged 5 commits into
mainfrom
597-connect-tags-to-categories-for-case-study-entity

Conversation

@Anton-88
Copy link
Copy Markdown
Contributor

Connected tags to category and updated display in case of several tags for one category

@Anton-88 Anton-88 requested a review from killev as a code owner May 20, 2025 14:04
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2025

📝 Walkthrough

Walkthrough

The changes refactor the case studies module to replace plain string fields for stack, case study type, and industry with relationship fields referencing categorized tags. This update is reflected in both the data model and template rendering logic, enabling support for multiple values per article and filtering capabilities in related modules.

Changes

File(s) Change Summary
website/modules/case-studies-page/views/index.html
website/modules/case-studies-page/views/show.html
Updated template logic to iterate over arrays for caseStudyType, industry, and stack fields, supporting multiple values per article. Loops render the title of each related tag, separated by commas, replacing previous single-value rendering.
website/modules/case-studies/index.js Renamed fields stack, caseStudyType, and industry to _stack, _caseStudyType, and _industry, changing their types from strings to relationships with cases-tags filtered by category. Updated field grouping, columns, and help text. The _stack column uses a custom component for tag display.
website/modules/cases-tags/index.js Added a filters property with an _category filter, allowing filtering of tags by their associated category.
website/modules/categories/index.js Added a required categoryType select field with predefined choices ("Technology," "Case Study Type," "Industry") to the category schema. Included this field in the basics group, columns, and filters for the category listing interface.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CaseStudiesPage
    participant CaseStudiesModule
    participant CasesTagsModule
    participant CategoriesModule

    User->>CaseStudiesPage: Request case study list
    CaseStudiesPage->>CaseStudiesModule: Query case studies
    CaseStudiesModule->>CasesTagsModule: Fetch related tags (_stack, _caseStudyType, _industry)
    CasesTagsModule->>CategoriesModule: Filter tags by category (Technology, Case Study Type, Industry)
    CasesTagsModule-->>CaseStudiesModule: Return filtered tags
    CaseStudiesModule-->>CaseStudiesPage: Return case studies with related tags
    CaseStudiesPage-->>User: Render case studies with multiple tags per field
Loading

Possibly related PRs

Suggested reviewers

  • VitalyyP
  • IhorMasechko
  • killev

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Anton-88 Anton-88 changed the title Connected tags to category [597] Connected tags to category May 20, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2025

🔍 Vulnerabilities of apostrophe-cms:test

📦 Image Reference apostrophe-cms:test
digestsha256:3b30e056eb61d6b53036c34f5e62507f96cce467769d45fdd26a50eadc9f407b
vulnerabilitiescritical: 0 high: 3 medium: 0 low: 0
platformlinux/amd64
size284 MB
packages935
📦 Base Image node:23-alpine
also known as
  • 23-alpine3.21
  • 23.11-alpine
  • 23.11-alpine3.21
  • 23.11.1-alpine
  • 23.11.1-alpine3.21
digestsha256:169ee1b69bd3f5c7c8508a9919e8b367bba9dc7fa9a03097ec9f85d2e8179631
vulnerabilitiescritical: 0 high: 0 medium: 0 low: 0
critical: 0 high: 1 medium: 0 low: 0 connect-multiparty 2.2.0 (npm)

pkg:npm/connect-multiparty@2.2.0

high 7.8: CVE--2022--29623 Unrestricted Upload of File with Dangerous Type

Affected range<=2.2.0
Fixed versionNot Fixed
CVSS Score7.8
CVSS VectorCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
EPSS Score0.100%
EPSS Percentile29th percentile
Description

An arbitrary file upload vulnerability in the file upload module of Express Connect-Multiparty 2.2.0 allows attackers to execute arbitrary code via a crafted PDF file. NOTE: the Supplier has not verified this vulnerability report.

critical: 0 high: 1 medium: 0 low: 0 async 0.9.2 (npm)

pkg:npm/async@0.9.2

high 7.8: CVE--2021--43138 OWASP Top Ten 2017 Category A9 - Using Components with Known Vulnerabilities

Affected range<2.6.4
Fixed version2.6.4, 3.2.2
CVSS Score7.8
CVSS VectorCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
EPSS Score1.061%
EPSS Percentile77th percentile
Description

A vulnerability exists in Async through 3.2.1 (fixed in 3.2.2), which could let a malicious user obtain privileges via the mapValues() method.

critical: 0 high: 1 medium: 0 low: 0 async 1.5.2 (npm)

pkg:npm/async@1.5.2

high 7.8: CVE--2021--43138 OWASP Top Ten 2017 Category A9 - Using Components with Known Vulnerabilities

Affected range<2.6.4
Fixed version2.6.4, 3.2.2
CVSS Score7.8
CVSS VectorCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
EPSS Score1.061%
EPSS Percentile77th percentile
Description

A vulnerability exists in Async through 3.2.1 (fixed in 3.2.2), which could let a malicious user obtain privileges via the mapValues() method.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
website/modules/case-studies/index.js (2)

234-238: Consider adding filters for new relationship fields

While you've updated the fields to use relationships, you might want to consider adding filters for the new relationship fields (_stack, _caseStudyType, and _industry) similar to the existing _tags filter. This would provide consistent filtering capabilities across all tag-based fields.

  filters: {
    add: {
      _tags: {
        label: 'Tags',
      },
+     _stack: {
+       label: 'Tech Stack',
+     },
+     _caseStudyType: {
+       label: 'Case Study Type',
+     },
+     _industry: {
+       label: 'Industry',
+     },
    },
  },

139-149: Consider updating _tags implementation for consistency

The existing _tags relationship field uses a simpler configuration than the newly added relationship fields. For consistency, you might want to consider updating it to match the pattern used for the other fields, including projections for category information and possibly filtering options.

  _tags: {
    type: 'relationship',
    label: 'Tags',
    withType: 'cases-tags',
    builders: {
      project: {
        title: 1,
        slug: 1,
+       '_category.title': 1,
      },
    },
+   withRelationships: ['_category'],
+   browser: {
+     projection: {
+       'title': 1,
+       '_category._id': 1,
+       '_category.title': 1,
+     },
+   },
  },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bce0e0f and e8ac5d9.

📒 Files selected for processing (5)
  • website/modules/case-studies-page/views/index.html (1 hunks)
  • website/modules/case-studies-page/views/show.html (2 hunks)
  • website/modules/case-studies/index.js (3 hunks)
  • website/modules/cases-tags/index.js (1 hunks)
  • website/modules/categories/index.js (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: yuramax
PR: speedandfunction/website#84
File: website/modules/case-studies-page/views/index.html:87-90
Timestamp: 2025-05-14T09:44:56.398Z
Learning: For the Case Study cards in website/modules/case-studies-page/views/index.html, the "type" and "industry" fields are temporarily hard-coded with values "Mobile Development" and "Manufacturing" as placeholders. These will be replaced with dynamic data ({{ article.type }} and {{ article.industry }}) in a future task.
website/modules/case-studies-page/views/index.html (1)
Learnt from: yuramax
PR: speedandfunction/website#84
File: website/modules/case-studies-page/views/index.html:87-90
Timestamp: 2025-05-14T09:44:56.398Z
Learning: For the Case Study cards in website/modules/case-studies-page/views/index.html, the "type" and "industry" fields are temporarily hard-coded with values "Mobile Development" and "Manufacturing" as placeholders. These will be replaced with dynamic data ({{ article.type }} and {{ article.industry }}) in a future task.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: security-scan
🔇 Additional comments (15)
website/modules/cases-tags/index.js (1)

46-52: Well-implemented filter for tag categories

The addition of the _category filter enhances the admin interface by allowing users to filter tags based on their associated category, which aligns perfectly with the new relationship model established in this PR.

website/modules/categories/index.js (2)

13-31: Good implementation of category types

The addition of the categoryType field with predefined choices ("Technology", "Case Study Type", "Industry") provides a clear structure for categorizing tags. This is essential for the tag-category relationship model and supports the filtering capabilities implemented in the case studies module.


40-51: Appropriate admin UI enhancements

Adding the categoryType as both a column and filter in the admin interface improves usability for content editors, making it easier to organize and find categories.

website/modules/case-studies-page/views/index.html (3)

126-132: Successfully implemented dynamic case study types

The template now correctly handles multiple case study types by iterating through the _caseStudyType relationship array. This replaces the previously hardcoded values as noted in the learning from PR #84.


133-139: Successfully implemented dynamic industry values

The template now correctly handles multiple industry tags by iterating through the _industry relationship array. This replaces the previously hardcoded values as noted in the learning from PR #84.


147-153: Well-implemented stack rendering

The code now properly handles multiple technology stack items by iterating through the _stack relationship array and joining them with commas.

website/modules/case-studies-page/views/show.html (3)

43-49: Properly implemented multiple industry display

The template now correctly handles and displays multiple industry tags in the detail view, using a consistent pattern for iteration and comma separation.


55-61: Well-implemented case study type display

The code properly renders multiple case study types with appropriate comma separation, maintaining consistency with the industry and stack implementations.


97-105: Successfully implemented tech stack display

The template now correctly handles multiple technology stack items in the detail view, consistent with the implementation for industry and case study types.

website/modules/case-studies/index.js (6)

40-66: Good architecture improvement converting string field to relationship

The change from a simple string field to a relationship field for _stack is a significant improvement. This enables multiple technology selections per case study and better data organization through categorization.

The implementation correctly:

  • References the cases-tags piece type
  • Filters by the appropriate category ("Technology")
  • Includes necessary projections for displaying relationship data

67-93: Well-structured relationship field configuration

The implementation for _caseStudyType follows best practices for relationship fields in ApostropheCMS:

  • Properly configured builders and projections
  • Appropriate category filtering
  • Clear help text explaining the field's purpose

This addresses the learning note that mentioned replacing hardcoded values with dynamic data.


94-120: Consistent implementation of relationship fields

The _industry field follows the same pattern as the other relationship fields, maintaining consistency throughout the codebase. The help text is clear and the filtering by Industry category is correctly implemented.


202-204: Updated group configuration reflects new field names

The group configuration has been correctly updated to reference the new relationship field names with leading underscores.


223-226: Appropriate component selection for relationship display

Using the AposCellTags component for displaying the _stack relationship field is appropriate, as this component is designed to handle the display of tag relationships (as evidenced by its use for _tags below).


3-240:

Details

✅ Verification successful

Verify template updates handle the new data structure

The AI summary mentions that templates in the case-studies-page module have been updated to render the new relationship fields. Ensure that all templates are updated to iterate over these fields as arrays rather than displaying them as single string values.

This relates to the learning note about replacing hardcoded values with dynamic data in the templates.


🏁 Script executed:

#!/bin/bash
# Check if the templates have been updated to handle the new relationship field structure

echo "Checking template files for relationship field rendering..."

# Search for templates that might be using the stack, caseStudyType, or industry fields
fd -e html | xargs grep -l 'article\._\(stack\|caseStudyType\|industry\)'

# Look specifically at the previously identified templates
echo "Examining the case-studies-page templates mentioned in the AI summary:"
if [ -f "website/modules/case-studies-page/views/index.html" ]; then
  echo "Content of index.html template:"
  grep -A 5 -B 5 'article\._\(stack\|caseStudyType\|industry\)' website/modules/case-studies-page/views/index.html
fi

if [ -f "website/modules/case-studies-page/views/show.html" ]; then
  echo "Content of show.html template:"
  grep -A 5 -B 5 'article\._\(stack\|caseStudyType\|industry\)' website/modules/case-studies-page/views/show.html
fi

Length of output: 1995


🏁 Script executed:

#!/bin/bash
# Verify show.html template handles the new relationship fields as arrays

echo "Searching for loops over _caseStudyType, _industry, _stack in show.html..."
grep -n "{% *for .* in article\._caseStudyType" -R website/modules/case-studies-page/views/show.html || true
grep -n "{% *for .* in article\._industry" -R website/modules/case-studies-page/views/show.html || true
grep -n "{% *for .* in article\._stack" -R website/modules/case-studies-page/views/show.html || true

echo -e "\nShowing first 200 lines of show.html for manual inspection:"
sed -n '1,200p' website/modules/case-studies-page/views/show.html

Length of output: 4053


Templates correctly iterate new relationship fields

Both index.html and show.html in website/modules/case-studies-page/views/ now use {% for %} loops over article._stack, article._caseStudyType and article._industry (and their data.piece equivalents), confirming they render these as arrays rather than single strings. No further changes are needed.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 20, 2025
@Anton-88 Anton-88 self-assigned this May 20, 2025
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@yuramax yuramax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, @Anton-88! 👍

Copy link
Copy Markdown
Contributor

@VitalyyP VitalyyP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Anton-88 Anton-88 enabled auto-merge (squash) May 23, 2025 12:49
Copy link
Copy Markdown
Collaborator

@killev killev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Anton-88 Anton-88 merged commit 093c899 into main May 23, 2025
12 checks passed
@Anton-88 Anton-88 deleted the 597-connect-tags-to-categories-for-case-study-entity branch May 23, 2025 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants