Skip to content

[INS-216] Add contract between frontend and backend for the activity types#110

Merged
borfast merged 3 commits intomainfrom
bugfix/ins-216-add-contract-for-activity-filters
Mar 18, 2025
Merged

[INS-216] Add contract between frontend and backend for the activity types#110
borfast merged 3 commits intomainfrom
bugfix/ins-216-add-contract-for-activity-filters

Conversation

@borfast
Copy link
Copy Markdown
Contributor

@borfast borfast commented Mar 17, 2025

Linear ticket.

This PR introduces enum values for the activity types and platforms, so that both the frontend and the backend can use the same values and not risk mismatches like the ones we've been having.

ℹ️ This PR is part of a stack

Please review them in order, as some of the first ones set the foundation for the later ones.

Summary by CodeRabbit

  • New Features

    • Introduced comprehensive definitions for various activity platforms, enhancing how different services (e.g., repository hosting and project management tools) are identified.
    • Added a structured representation of various activity types for better organization and type safety across multiple services.
  • Refactor

    • Standardized activity type values in contributor metrics for improved consistency and maintainability.

@borfast borfast added the bug Something isn't working label Mar 17, 2025
@borfast borfast self-assigned this Mar 17, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 17, 2025

Walkthrough

The updates centralize activity type and platform definitions by replacing hardcoded string values with dynamic enum calls. The contributors module now references activity types via the newly introduced ActivityTypes enum. Additionally, two new TypeScript enums—ActivityPlatforms and ActivityTypes—have been added to provide standardized string constants for various platforms and associated activities across the application.

Changes

File(s) Change Summary
frontend/.../contributors/config/metrics.ts Replaced hardcoded string values in metricsOptions with dynamic calls to ActivityTypes.<ActivityType>.valueOf(). Added import for ActivityTypes.
frontend/types/shared/activity-platforms.ts
frontend/types/shared/activity-types.ts
Introduced two new enums: ActivityPlatforms for activity platforms and ActivityTypes for detailed activity categorization.

Possibly related PRs

  • added all the metrics for the activity dropdown #98: The changes in the main PR, which involve replacing hardcoded string values with enumerated values from ActivityTypes, are directly related to the modifications in the retrieved PR that also deals with activity types in the metricsOptions array, as both PRs affect the same variable in the metrics.ts file.
  • Add Contributor Dependency widget endpoint #84: The changes in the main PR, which involve updating string values in the metricsOptions array to use the ActivityTypes enumeration, are related to the introduction of the ActivityTypes enum in the retrieved PR, as both modifications involve the same activity types and enhance code maintainability.
  • Refactor data sources #76: The changes in the main PR, which involve updating hardcoded string values to use an enumeration for activity types, are related to the introduction of the ActivityTypes enum in the retrieved PR, as both involve the same activity types across different components.

Suggested reviewers

  • gaspergrom
  • emlimlf

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

Copy link
Copy Markdown
Collaborator

@gaspergrom gaspergrom left a comment

Choose a reason for hiding this comment

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

please fix the lint and typescript

@borfast borfast force-pushed the improvement/pass-activity-platform branch 2 times, most recently from 1f0aea6 to 1e8a693 Compare March 18, 2025 10:34
Base automatically changed from improvement/pass-activity-platform to main March 18, 2025 10:35
Signed-off-by: Raúl Santos <4837+borfast@users.noreply.github.com>
@borfast borfast force-pushed the bugfix/ins-216-add-contract-for-activity-filters branch from 9c7ec42 to 240904b Compare March 18, 2025 10:35
@borfast
Copy link
Copy Markdown
Contributor Author

borfast commented Mar 18, 2025

please fix the lint and typescript

I fixed it in the last PR of the stack. I had to disable Husky's pre-commit hook because it was messing up my commits. (#118).

Copy link
Copy Markdown

@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: 6

🧹 Nitpick comments (4)
frontend/types/shared/activity-platforms.ts (1)

3-18: Consider using consistent capitalization for platform names

The platform names have inconsistent capitalization formats. Some are fully capitalized (ALL), some have title case (Github, Git), and others have mixed cases (GroupsIO). Consider standardizing the format across all platforms.

For example, you could use title case for all platform names:

 export enum ActivityPlatforms {
   ALL = 'all',
-  GITHUB = 'Github',
-  GIT = 'Git',
-  GERRIT = 'Gerrit',
-  GITLAB = 'Gitlab',
-  GROUPS_IO = 'GroupsIO',
-  CONFLUENCE = 'Confluence',
-  JIRA = 'Jira',
-  DEVTO = 'Devto',
-  DISCORD = 'Discord',
-  DISCOURSE = 'Discourse',
-  HACKERNEWS = 'Hackernews',
-  LINKEDIN = 'Linkedin',
-  REDDIT = 'Reddit',
-  SLACK = 'Slack',
-  STACKOVERFLOW = 'Stackoverflow',
-  TWITTER = 'Twitter'
+  GITHUB = 'GitHub',
+  GIT = 'Git',
+  GERRIT = 'Gerrit',
+  GITLAB = 'GitLab',
+  GROUPS_IO = 'GroupsIO',
+  CONFLUENCE = 'Confluence',
+  JIRA = 'Jira',
+  DEVTO = 'DevTo',
+  DISCORD = 'Discord',
+  DISCOURSE = 'Discourse',
+  HACKERNEWS = 'HackerNews',
+  LINKEDIN = 'LinkedIn',
+  REDDIT = 'Reddit',
+  SLACK = 'Slack',
+  STACKOVERFLOW = 'StackOverflow',
+  TWITTER = 'Twitter'
frontend/types/shared/activity-types.ts (1)

1-87: Add type documentation for the ActivityTypes enum

Consider adding JSDoc comments to document this enum, especially since it's a shared contract between frontend and backend. This will help improve code maintainability and understanding.

+/**
+ * Standardized activity types used across both frontend and backend
+ * This enum serves as a single source of truth for all activity types in the application
+ */
 export enum ActivityTypes {
   ALL = 'all',
frontend/app/components/modules/project/components/contributors/config/metrics.ts (2)

2-2: Use consistent import formatting

The import statement for ActivityTypes uses double quotes while the other import uses single quotes. Consider using consistent quote style for all imports.

import type { DropdownGroupOptions } from '~/components/uikit/dropdown/types/dropdown.types';
-import {ActivityTypes} from "~~/types/shared/activity-types";
+import { ActivityTypes } from '~~/types/shared/activity-types';

5-5: Use ActivityTypes.ALL for consistency

For the "All activities" option, consider using the ActivityTypes.ALL enum value for consistency.

-  { label: '', items: [{ label: 'All activities', value: 'all' }] },
+  { label: '', items: [{ label: 'All activities', value: ActivityTypes.ALL.valueOf() }] },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5be7753 and 240904b.

📒 Files selected for processing (3)
  • frontend/app/components/modules/project/components/contributors/config/metrics.ts (16 hunks)
  • frontend/types/shared/activity-platforms.ts (1 hunks)
  • frontend/types/shared/activity-types.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Lint & Typescript Check
frontend/types/shared/activity-platforms.ts

[error] 19-19: ESLint: Newline required at end of file but not found (eol-last)

🔇 Additional comments (1)
frontend/app/components/modules/project/components/contributors/config/metrics.ts (1)

10-10:

Details

❓ Verification inconclusive

Verify the consistency of AUTHORED_COMMIT usage

The AUTHORED_COMMIT activity type is used across multiple platforms (Github, Git, Gitlab). Verify that this is intentional and that the same activity type can be shared across different platforms.

Also applies to: 64-64, 186-186


🏁 Script executed:

#!/bin/bash
# Check if AUTHORED_COMMIT is used consistently across multiple platforms in the backend code

# Search for AUTHORED_COMMIT in backend code
rg -A 2 -B 2 "authored-commit" --glob="!frontend/**"

Length of output: 52


Action Required: Verify Cross-Platform Consistency of AUTHORED_COMMIT
It appears that outside of the frontend, no direct references to "authored-commit" were found with the executed command. Since the intended consistency of using ActivityTypes.AUTHORED_COMMIT across platforms (GitHub, Git, Gitlab) is critical, please manually verify that the same activity type is intended to be shared across these platforms. Ensure that the usage in the following locations is consistent:

  • File: frontend/app/components/modules/project/components/contributors/config/metrics.ts
    • Lines: 10, 64, 186

If the absence of references in the backend is by design, please confirm that this does not lead to any integration issues or mismatch in behavior across different platforms.

borfast added 2 commits March 18, 2025 10:43
Signed-off-by: Raúl Santos <4837+borfast@users.noreply.github.com>
Signed-off-by: Raúl Santos <4837+borfast@users.noreply.github.com>
@borfast borfast merged commit b7807a7 into main Mar 18, 2025
2 of 3 checks passed
@borfast borfast deleted the bugfix/ins-216-add-contract-for-activity-filters branch March 18, 2025 10:46
Copy link
Copy Markdown

@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)
frontend/app/components/modules/project/components/contributors/config/metrics.ts (2)

2-2: Consider consistent import quotes usage.

The import statement uses double quotes (") while the import on line 1 uses single quotes ('). Consider maintaining consistency across all imports.

-import {ActivityTypes} from "~~/types/shared/activity-types";
+import { ActivityTypes } from '~~/types/shared/activity-types';

7-7: Correct platform name capitalization

Some platform names have incorrect capitalization:

  • "Github" should be "GitHub"
  • "Gitlab" should be "GitLab"
  • "Stackoverflow" should be "Stack Overflow"

Consider updating these for accuracy and consistency.

-    label: 'Github',
+    label: 'GitHub',
-    label: 'Gitlab',
+    label: 'GitLab',
-    label: 'Stackoverflow',
+    label: 'Stack Overflow',

Also applies to: 151-151, 354-354

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 240904b and 535be4a.

📒 Files selected for processing (3)
  • frontend/app/components/modules/project/components/contributors/config/metrics.ts (16 hunks)
  • frontend/types/shared/activity-platforms.ts (1 hunks)
  • frontend/types/shared/activity-types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/types/shared/activity-platforms.ts
  • frontend/types/shared/activity-types.ts
🔇 Additional comments (3)
frontend/app/components/modules/project/components/contributors/config/metrics.ts (3)

113-119: Fix duplicate activity type references in Gerrit section

You're using both CHANGESET_NEW and CHANGESET_CREATED for the same label "Created a changeset". This is redundant and one of them should be removed.

      {
        value: ActivityTypes.CHANGESET_NEW.valueOf(),
        label: 'Created a changeset'
      },
-      {
-        value: ActivityTypes.CHANGESET_CREATED.valueOf(),
-        label: 'Created a changeset'
-      },

2-2: Consider importing ActivityPlatforms enum

Since the metrics are organized by platform labels (e.g., 'Github', 'Git', 'Gerrit', etc.), consider also importing and using the ActivityPlatforms enum for consistency.

import type { DropdownGroupOptions } from '~/components/uikit/dropdown/types/dropdown.types';
-import {ActivityTypes} from "~~/types/shared/activity-types";
+import { ActivityTypes } from '~~/types/shared/activity-types';
+import { ActivityPlatforms } from '~~/types/shared/activity-platforms';

Then update each platform label to use the enum:

  {
-    label: 'Github',
+    label: ActivityPlatforms.GITHUB.valueOf(),
    items: [

4-378: Good job centralizing activity type definitions

The replacement of hardcoded string values with enum references is a good improvement that will help maintain consistency between frontend and backend. This change directly addresses the PR objective of establishing a contract for activity types.

@borfast borfast assigned borfast and unassigned borfast May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants