Skip to content

Conversation

@pierredup
Copy link
Member

Fixes #1811

@pierredup pierredup added this to the 2.3.8 milestone Jun 18, 2025
@pierredup pierredup self-assigned this Jun 18, 2025
@pierredup pierredup added the bug label Jun 18, 2025
@solidinvoice-bot
Copy link

solidinvoice-bot bot commented Jun 18, 2025

The preview deployment failed. 🔴

Open Build Logs

Last updated at: 2025-06-18 18:12:36 CET

@codecov
Copy link

codecov bot commented Jun 18, 2025

Bundle Report

Bundle size has no change ✅

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

Walkthrough

The code refactors the retrieval of API tokens and their usage history for a user. It replaces a single joined query with two separate queries—one for tokens and one for their usage history—then merges the results in PHP. Type annotations and imports are updated to reflect more generic types.

Changes

File(s) Change Summary
src/UserBundle/Repository/ApiTokenRepository.php Refactored getApiTokensForUser to use two queries and PHP post-processing; updated return type and imports.
src/UserBundle/Twig/Components/ApiTokens.php Updated PHPDoc for apiTokens() method to use generic/mixed array types; removed specific type imports.

Sequence Diagram(s)

sequenceDiagram
    participant Controller
    participant ApiTokenRepository
    participant DB

    Controller->>ApiTokenRepository: getApiTokensForUser(user)
    ApiTokenRepository->>DB: Query 1: Fetch tokens for user
    DB-->>ApiTokenRepository: List of tokens
    ApiTokenRepository->>DB: Query 2: Fetch last usage per token
    DB-->>ApiTokenRepository: Map of token IDs to last usage info
    ApiTokenRepository->>Controller: Combined token info with last usage
Loading

Assessment against linked issues

Objective Addressed Explanation
Prevent duplicate API tokens in UI when rapid requests are made (1811)
Improve performance of API token retrieval to avoid delays/timeouts with large api_tokens_history table (1811)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

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

Copy link
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: 1

🧹 Nitpick comments (1)
src/UserBundle/Twig/Components/ApiTokens.php (1)

38-40: Typed array downgraded to mixed – consider a small DTO instead

Loosening the return type sacrifices static analysis & autocomplete benefits across the template layer.
Wrapping the five fields in a readonly value-object (e.g. ApiTokenView) keeps type safety without re-introducing the heavy join you just removed.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 987d128 and 3d79542.

📒 Files selected for processing (2)
  • src/UserBundle/Repository/ApiTokenRepository.php (2 hunks)
  • src/UserBundle/Twig/Components/ApiTokens.php (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: DB (MariaDB pdo_mysql 11.0)
  • GitHub Check: Lint
  • GitHub Check: DB (PostgreSQL pdo_pgsql 16)
  • GitHub Check: DB (MariaDB pdo_mysql 11.4)
  • GitHub Check: DB (PostgreSQL pdo_pgsql 17)
  • GitHub Check: DB (MariaDB pdo_mysql 11)
  • GitHub Check: DB (MySQL pdo_mysql 9)
  • GitHub Check: DB (MariaDB pdo_mysql 10.6)
  • GitHub Check: DB (MySQL pdo_mysql 5.7)
  • GitHub Check: DB (MariaDB pdo_mysql 10.11)
  • GitHub Check: DB (MariaDB pdo_mysql 10.5)
  • GitHub Check: DB (MySQL pdo_mysql 8.0)
  • GitHub Check: DB (MySQL pdo_mysql 8.3)
  • GitHub Check: DB (MySQL pdo_mysql 8.4)
  • GitHub Check: DB (MariaDB pdo_mysql 10.4)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Unit ( PHP 8.3 )
  • GitHub Check: Unit ( PHP 8.3 )
  • GitHub Check: Unit ( PHP 8.4 )
  • GitHub Check: PHPStan
🔇 Additional comments (1)
src/UserBundle/Repository/ApiTokenRepository.php (1)

77-85: [web_search]

What database column type does Symfony\Bridge\Doctrine\Types\UlidType map to by default?

@pierredup pierredup changed the base branch from 2.4.x to 2.3.x June 18, 2025 18:14
@codecov
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

Attention: Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.

Project coverage is 48.85%. Comparing base (33c4592) to head (3d79542).
Report is 1 commits behind head on 2.3.x.

Files with missing lines Patch % Lines
src/UserBundle/Repository/ApiTokenRepository.php 0.00% 21 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              2.3.x    #1812      +/-   ##
============================================
+ Coverage     48.32%   48.85%   +0.52%     
- Complexity     2749     2800      +51     
============================================
  Files           501      510       +9     
  Lines          9936    10111     +175     
============================================
+ Hits           4802     4940     +138     
- Misses         5134     5171      +37     
Flag Coverage Δ
unittests 48.85% <0.00%> (+0.52%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pierredup pierredup merged commit 4104350 into 2.3.x Jun 19, 2025
24 of 29 checks passed
@pierredup pierredup deleted the fix-api-token-list branch June 19, 2025 10:13
@coderabbitai coderabbitai bot mentioned this pull request Nov 3, 2025
@coderabbitai coderabbitai bot mentioned this pull request Dec 9, 2025
@coderabbitai coderabbitai bot mentioned this pull request Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Api token duplication , profile/api loading time.

2 participants