Skip to content

feat: add projections to optimize queries#650

Open
hdd wants to merge 2 commits into
mainfrom
backlog/connect-query-optimizations
Open

feat: add projections to optimize queries#650
hdd wants to merge 2 commits into
mainfrom
backlog/connect-query-optimizations

Conversation

@hdd
Copy link
Copy Markdown
Collaborator

@hdd hdd commented Jun 1, 2026

@dennisweil this could potentially superseed : #648

Summary by CodeRabbit

  • New Features

    • Added support for PySide6 alongside existing PySide2 for the configuration UI.
  • Improvements

    • Improved project listing accuracy in the entity tree to return more precise project data.
    • Consistent UI text and overlay messaging for action discovery and launch flows.
  • Chores

    • Standardized docstrings, string quoting, and UI text formatting across multiple modules.

@hdd hdd requested a review from a team as a code owner June 1, 2026 08:54
@hdd hdd requested a review from dennisweil June 1, 2026 08:54
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6cba4933-dcd2-40f2-b464-b2c28bfaa137

📥 Commits

Reviewing files that changed from the base of the PR and between e209d7c and 5cfe3d0.

📒 Files selected for processing (1)
  • apps/connect/source/ftrack_connect/ui/model/entity_tree.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/connect/source/ftrack_connect/ui/model/entity_tree.py

📝 Walkthrough

Walkthrough

Standardizes docstrings and string quoting in the action launcher and storage-scenario UI, adds a PySide6/PySide2 Qt import fallback, and replaces a shorthand Project query with an explicit SELECT fetching id, full_name, and name. Functional behavior is unchanged.

Changes

Action Launcher Widget Standardization

Layer / File(s) Summary
Class contracts and signal definitions
apps/connect/source/ftrack_connect/action_launcher/actions.py
ActionBase and ActionSection receive proper docstrings. Signal declarations and forwarding method signatures adopt consistent double-quoted strings.
Widget initialization and UI labels
apps/connect/source/ftrack_connect/action_launcher/actions.py
UI labels for "Recent" and "Discovering actions" sections, plus the busy overlay message, are reformatted to use consistent double-quoted strings.
Action discovery and loading
apps/connect/source/ftrack_connect/action_launcher/actions.py
Action discovery flow remains unchanged: publishes ftrack.action.discover, wraps results in ActionBase, groups by label, and displays loading overlay. Sort key and loading callback formatting is normalized.
Action launch and Rosetta handling
apps/connect/source/ftrack_connect/action_launcher/actions.py
Pre-launch checks for Rosetta compatibility on Apple Silicon, displays warning dialog, and persists acknowledged apps to preferences. Formatting and quoting are standardized; logic flow is unchanged.
Result handling and recent actions management
apps/connect/source/ftrack_connect/action_launcher/actions.py
Post-launch callbacks log actions, update recent actions metadata, persist via session.ensure, and display results. Recent actions list is filtered, truncated, sorted, and displayed; message detection and overlay behavior preserved.

Entity Tree Query Refinement

Layer / File(s) Summary
Explicit Project query fields
apps/connect/source/ftrack_connect/ui/model/entity_tree.py
Root._fetchChildren changes from shorthand query syntax ("Project where status is active") to an explicit SELECT statement retrieving id, full_name, and name for active projects.

Storage Scenario Configuration Compatibility

Layer / File(s) Summary
Qt binding compatibility
apps/connect/source/ftrack_connect/ui/widget/configure_scenario.py
Import logic conditionally loads QtWidgets and QtCore from PySide6, with automatic fallback to PySide2 if unavailable.
Class docstrings and initialization
apps/connect/source/ftrack_connect/ui/widget/configure_scenario.py
Class and constructor docstrings convert to triple-double-quote style. Settings query string is reformatted while maintaining identical selection criteria for storage_scenario.
Configuration UI construction
apps/connect/source/ftrack_connect/ui/widget/configure_scenario.py
Header, button, lead label, and learn-more link are reformatted with consistent double-quoted objectName values and multiline string formatting. Text content, alignment, word-wrap, and event subscription to ftrack.storage-scenario.configure-done are unchanged.

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely incomplete, missing critical sections from the template including overview, implementation details, testing information, and issue references (CLICKUP/FT/SENTRY/ZENDESK links). Add a comprehensive description following the template: include issue references, purpose/scope sections, implementation details, testing information, and manual test instructions.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding projections to optimize queries in ftrack_connect, which is clearly evident from the entity_tree.py changes converting a shorthand query to an explicit SELECT with specific fields.
Docstring Coverage ✅ Passed Docstring coverage is 92.86% which is sufficient. The required threshold is 50.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backlog/connect-query-optimizations

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Coverage report

This PR does not seem to contain any modification to coverable code.

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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/connect/source/ftrack_connect/action_launcher/actions.py`:
- Around line 337-338: The query currently interpolates self.session.api_user
directly into the raw predicate string (the select id from User where
username=... call), which risks injection and quote-breaking; change it to use a
parameterized or escaped query mechanism instead—e.g., pass the username as a
bound parameter (or use the session/query API that accepts parameters) rather
than f-strings, locating the construction where self.session.api_user is
embedded and replacing it with a parameter placeholder and a parameters dict or
with a proper quoting/escaping helper.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f9824291-2398-47f8-9714-4884fb26cf8a

📥 Commits

Reviewing files that changed from the base of the PR and between 843bde9 and e209d7c.

📒 Files selected for processing (3)
  • apps/connect/source/ftrack_connect/action_launcher/actions.py
  • apps/connect/source/ftrack_connect/ui/model/entity_tree.py
  • apps/connect/source/ftrack_connect/ui/widget/configure_scenario.py

Comment on lines +337 to 338
f'select id from User where username="{self.session.api_user}"'
).one()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid raw query interpolation for self.session.api_user.

Directly embedding self.session.api_user into the query can break on quotes and is query-injection-prone. Escape/sanitize before constructing the predicate.

Proposed fix
-            user = self.session.query(
-                f'select id from User where username="{self.session.api_user}"'
-            ).one()
+            api_user = str(self.session.api_user).replace("\\", "\\\\").replace('"', '\\"')
+            user = self.session.query(
+                f'select id from User where username="{api_user}"'
+            ).one()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/connect/source/ftrack_connect/action_launcher/actions.py` around lines
337 - 338, The query currently interpolates self.session.api_user directly into
the raw predicate string (the select id from User where username=... call),
which risks injection and quote-breaking; change it to use a parameterized or
escaped query mechanism instead—e.g., pass the username as a bound parameter (or
use the session/query API that accepts parameters) rather than f-strings,
locating the construction where self.session.api_user is embedded and replacing
it with a parameter placeholder and a parameters dict or with a proper
quoting/escaping helper.

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.

1 participant