Skip to content

Conversation

rdonigian
Copy link
Contributor

Add usesAIAssistance boolean to Language which computes usingAIAssistedTranslation from related Engagements

Copy link

github-actions bot commented Aug 1, 2025

🗞 GraphQL Summary

View schema changes
@@ -2508,8 +2508,16 @@
 
   """The earliest start date from its engagements."""
   sponsorStartDate: SecuredDate!
   tags: SecuredTags!
+
+  """
+  Whether any engagement for this language is using AI-assisted translation.
+  
+  This is true if any engagement's "usingAIAssistedTranslation" property is not "None" or "Unknown".
+  Used to track and filter languages that have AI assistance in their translation process.
+  """
+  usesAIAssistance: SecuredBoolean!
 }
 
 type LanguageEngagement implements ChangesetAware & Commentable & Engagement & Resource {
   """Whether the requesting user can delete this resource"""
@@ -2625,8 +2633,11 @@
   registryOfLanguageVarietiesCode: String
 
   """Only these sensitivities"""
   sensitivity: [Sensitivity!]
+
+  """Only languages that have an AI-assisted translation engagement"""
+  usesAIAssistance: Boolean
 }
 
 input LanguageListInput {
   """The number of items to return in a single page"""

⚠️ Dangerous Changes

  • An optional field usesAIAssistance on input type LanguageFilters was added.

@rdonigian rdonigian force-pushed the ai-assistance-lang-field branch 2 times, most recently from 803a478 to 3eafd80 Compare August 4, 2025 21:41
@rdonigian rdonigian marked this pull request as ready for review August 4, 2025 21:42
@rdonigian rdonigian requested a review from CarsonF as a code owner August 4, 2025 21:42
Copy link

coderabbitai bot commented Aug 4, 2025

📝 Walkthrough

Walkthrough

A new calculated field, usesAIAssistance, is introduced to the Language entity and its DTOs, indicating whether any engagement for a language uses AI-assisted translation. Filtering and sorting capabilities based on this field are added to the repository, and the field is included in hydration and filter DTOs. Corresponding schema and migration changes define this computed property at the database level.

Changes

Cohort / File(s) Change Summary
Language DTOs
src/components/language/dto/language.dto.ts, src/components/language/dto/list-language.dto.ts
Added a new calculated field usesAIAssistance of type SecuredBoolean to the Language DTO and an optional boolean filter usesAIAssistance to LanguageFilters. These additions enable tracking and querying languages by AI-assisted translation usage.
Repository Hydration
src/components/language/language.gel.repository.ts
Added usesAIAssistance to the hydration mapping for the Language entity, setting it from the corresponding property without altering other logic.
Repository Query Logic
src/components/language/language.repository.ts
Introduced a private query fragment to detect usesAIAssistance by checking related engagements with AI-assisted translation. Integrated this fragment into the hydrate method and added filter and sorter implementations to support filtering and sorting languages by this field.
Database Schema and Migration
dbschema/language.gel, dbschema/migrations/00020-m1cpuxn.edgeql
Added a computed boolean property usesAIAssistance to the Language type in the database schema and created a migration that defines this property using an EXISTS query filtering engagements where usingAIAssistedTranslation is neither None nor Unknown.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3eafd80 and 4411d7f.

📒 Files selected for processing (6)
  • dbschema/language.gel (1 hunks)
  • dbschema/migrations/00020-m1cpuxn.edgeql (1 hunks)
  • src/components/language/dto/language.dto.ts (1 hunks)
  • src/components/language/dto/list-language.dto.ts (1 hunks)
  • src/components/language/language.gel.repository.ts (1 hunks)
  • src/components/language/language.repository.ts (5 hunks)
✅ Files skipped from review due to trivial changes (1)
  • dbschema/language.gel
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/components/language/dto/list-language.dto.ts
  • src/components/language/language.gel.repository.ts
  • src/components/language/dto/language.dto.ts
  • src/components/language/language.repository.ts
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: CarsonF
PR: SeedCompany/cord-api-v3#3438
File: src/components/language/migrations/add-flags.migration.ts:6-8
Timestamp: 2025-07-08T14:12:59.042Z
Learning: In the SeedCompany/cord-api-v3 project PR #3438, the isWiderComm field was initially planned to be added to the Language entity but was subsequently removed during development. Only the isAvailableForReporting field remained in the final implementation.
📚 Learning: in the seedcompany/cord-api-v3 project, edgedb/gel migrations are stored in `/dbschema/migrations/` ...
Learnt from: CarsonF
PR: SeedCompany/cord-api-v3#3438
File: src/components/language/migrations/add-flags.migration.ts:6-9
Timestamp: 2025-07-04T14:51:04.043Z
Learning: In the SeedCompany/cord-api-v3 project, EdgeDB/Gel migrations are stored in `/dbschema/migrations/` and handle database schema changes including entity links and properties. TypeScript migrations in component-specific migration folders (like `src/components/language/migrations/`) handle application-layer data transformations, not database schema changes.

Applied to files:

  • dbschema/migrations/00020-m1cpuxn.edgeql
📚 Learning: files in the migrations folder (e.g., dbschema/migrations/*.edgeql) are generated and not meant to b...
Learnt from: CarsonF
PR: SeedCompany/cord-api-v3#3370
File: dbschema/migrations/00014-m1n6adc.edgeql:5-6
Timestamp: 2025-03-25T03:48:38.994Z
Learning: Files in the migrations folder (e.g., dbschema/migrations/*.edgeql) are generated and not meant to be manually edited. Suggestions about refactoring or improving the code style in these files are not applicable.

Applied to files:

  • dbschema/migrations/00020-m1cpuxn.edgeql
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Clean
  • GitHub Check: E2E Tests (neo4j 5/6)
  • GitHub Check: E2E Tests (neo4j 1/6)
  • GitHub Check: E2E Tests (neo4j 4/6)
  • GitHub Check: E2E Tests (neo4j 6/6)
  • GitHub Check: E2E Tests (neo4j 3/6)
  • GitHub Check: E2E Tests (neo4j 2/6)
  • GitHub Check: Unit
  • GitHub Check: lint
  • GitHub Check: Generate (head)
  • GitHub Check: Generate (base)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
dbschema/migrations/00020-m1cpuxn.edgeql (2)

1-3: LGTM!

The migration structure follows EdgeDB conventions correctly with proper migration ID and parent reference.


4-10: LGTM!

The computed property logic correctly implements the intended behavior:

  • Uses EXISTS to return a boolean indicating if any related engagements use AI assistance
  • Properly filters out None and Unknown values from AIAssistedTranslation enum
  • The logic handles edge cases correctly (no engagements, all None/Unknown values, etc.)

This aligns perfectly with the PR objective to indicate whether a language utilizes AI-assisted translation.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ai-assistance-lang-field

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

Support

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

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 generate unit tests to generate unit tests 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

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 79cdbb0 and 3eafd80.

📒 Files selected for processing (4)
  • src/components/language/dto/language.dto.ts (1 hunks)
  • src/components/language/dto/list-language.dto.ts (1 hunks)
  • src/components/language/language.gel.repository.ts (1 hunks)
  • src/components/language/language.repository.ts (5 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CarsonF
PR: SeedCompany/cord-api-v3#3438
File: src/components/language/migrations/add-flags.migration.ts:6-8
Timestamp: 2025-07-08T14:12:59.042Z
Learning: In the SeedCompany/cord-api-v3 project PR #3438, the isWiderComm field was initially planned to be added to the Language entity but was subsequently removed during development. Only the isAvailableForReporting field remained in the final implementation.
📚 Learning: in the seedcompany/cord-api-v3 project pr #3438, the iswidercomm field was initially planned to be a...
Learnt from: CarsonF
PR: SeedCompany/cord-api-v3#3438
File: src/components/language/migrations/add-flags.migration.ts:6-8
Timestamp: 2025-07-08T14:12:59.042Z
Learning: In the SeedCompany/cord-api-v3 project PR #3438, the isWiderComm field was initially planned to be added to the Language entity but was subsequently removed during development. Only the isAvailableForReporting field remained in the final implementation.

Applied to files:

  • src/components/language/language.gel.repository.ts
  • src/components/language/dto/list-language.dto.ts
  • src/components/language/dto/language.dto.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: E2E Tests (neo4j 1/6)
  • GitHub Check: E2E Tests (neo4j 3/6)
  • GitHub Check: E2E Tests (neo4j 6/6)
  • GitHub Check: E2E Tests (neo4j 4/6)
  • GitHub Check: E2E Tests (neo4j 5/6)
  • GitHub Check: E2E Tests (neo4j 2/6)
  • GitHub Check: Unit
  • GitHub Check: Clean
  • GitHub Check: lint
  • GitHub Check: Generate (base)
  • GitHub Check: Generate (head)
🔇 Additional comments (5)
src/components/language/dto/language.dto.ts (1)

187-196: LGTM!

The new calculated field is well-implemented with proper decorators, clear documentation, and appropriate typing. The description accurately reflects the business logic for determining AI assistance usage.

src/components/language/language.repository.ts (4)

383-400: Query logic looks correct for detecting AI assistance usage.

The usingAIAssistance fragment correctly:

  • Matches language engagements through the proper relationship path
  • Checks the usingAIAssistedTranslation property values
  • Excludes null, "None", and "Unknown" values as specified in the DTO description
  • Uses any() function to return true if any engagement meets the criteria

212-212: Integration with hydrate method is properly implemented.

The fragment is correctly applied in the hydration pipeline and the result is properly included in the returned DTO fields.

Also applies to: 226-226


344-347: Filter implementation follows established patterns.

The filter correctly applies the usingAIAssistance fragment and uses the computed value for filtering. The implementation is consistent with other boolean filters in the codebase.


433-437: Sorter implementation is consistent and correct.

The sorter properly applies the usingAIAssistance fragment and uses the computed value for sorting, following the same pattern as other computed field sorters.

@rdonigian rdonigian force-pushed the ai-assistance-lang-field branch from 3eafd80 to 4411d7f Compare August 5, 2025 13:30
@sethmcknight sethmcknight linked an issue Aug 6, 2025 that may be closed by this pull request
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.

AI Assistance roll-up on Language
1 participant