Skip to content

feat: added used preset names to query settings#2504

Open
stolpeo wants to merge 1 commit intomainfrom
feat-added-used-preset-names-to-query
Open

feat: added used preset names to query settings#2504
stolpeo wants to merge 1 commit intomainfrom
feat-added-used-preset-names-to-query

Conversation

@stolpeo
Copy link
Contributor

@stolpeo stolpeo commented Dec 4, 2025

Summary by CodeRabbit

Release Notes

  • New Features
    • Added Quick Preset and Category Presets display support throughout the application
    • Quick Preset labels and Category Preset mappings now appear in PDF and DOCX exports
    • Quick Preset badge now displays in filter results with version information
    • Added ability to export filter settings in multiple formats

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Walkthrough

The PR adds preset labeling metadata and category preset tracking throughout the system. Three new optional fields are added to the CaseQuery schema with corresponding JSON schema definitions. Frontend UI components track selected quick preset labels and category preset labels, propagated through store state and submitted with queries. Export functionality in PDF and DOCX formats now displays preset labels alongside existing metadata.

Changes

Cohort / File(s) Summary
Backend Schema & Data Model
backend/variants/query_schemas.py, backend/variants/schemas/case-query-v1.json
Adds three new fields to CaseQuery: _quick_preset_label (string or null), _quick_preset_label_version (integer, default 1), and _category_preset_labels (object mapping category names to label strings or null). Extends JSON schema with validation and metadata for these fields.
Backend Export Logic
backend/variants/views/api/export.py
Integrates Quick Preset label and Category Presets display into PDF and DOCX exports. Appends Quick Preset row (defaults to "custom" if absent) and conditionally renders Category Presets table with predefined category ordering and user-friendly names below existing metadata.
Frontend Store & State Management
frontend/src/variants/stores/variantQuery.js, frontend/src/variants/stores/variantResultSet.ts
Extends store state with selectedQuickPresetLabel, selectedQuickPresetLabelVersion, and categoryPresetLabels. Updates submitQuery to augment query settings with preset metadata. Adds async query retrieval in loadResultSetViaQuery to access preset information from executed queries.
Frontend UI Components
frontend/src/variants/components/FilterForm/QuickPresets.vue, frontend/src/variants/components/FilterResultsTable.vue
QuickPresets.vue introduces updateCategoryPresetLabels helper to compute and store preset labels at multiple lifecycle points (preset selection, filter changes, refresh). FilterResultsTable.vue adds computed queryPresetLabel and queryPresetLabelVersion, displays Quick Preset badge with tooltip, and implements exportFilterSettings function to download exports.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Areas requiring extra attention during review:

  • Export logic (export.py): Verify consistent rendering of Quick Preset and Category Presets across both PDF and DOCX export paths, including proper fallback handling and formatting alignment
  • Label update coverage (QuickPresets.vue): Confirm updateCategoryPresetLabels is called at all necessary trigger points (inheritance changes, quality changes, generic value updates, preset selection) and clears labels appropriately in custom mode
  • Async data flow (variantResultSet.ts): Validate that the new retrieveQuery call properly awaits and integrates with existing error handling and refresh logic

Possibly related PRs

Poem

🐰 A preset path now marked with care,
Labels stored in data fair,
Quick and custom, both display,
Category presets light the way,
Export now shows the preset's name—
Our burrow queries shine with fame! 🌟

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding preset names (quick preset label and category preset labels) to query settings across both backend and frontend.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-added-used-preset-names-to-query

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

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

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

deps-report 🔍

Commit scanned: e46dd0e
ℹ️ Python version 3.11 is used by your project but the latest version is 3.14.

Vulnerable dependencies

4 dependencies have vulnerabilities 😱
Dependency Advisory Versions impacted
setuptools (transitive) Affected versions of Setuptools are vulnerable to Path Traversal via PackageIndex.download(). The impact is Arbitrary File Overwrite: An attacker would be allowed to write files to arbitrary locations on the filesystem with the permissions of the process running the Python code, which could escalate to RCE depending on the context. <78.1.1
social-auth-app-django (transitive) Affected versions of the social-auth-app-django package are vulnerable to Authentication Bypass due to unintended email-based account association during the authentication pipeline. In social_django.storage.create_user (invoked by social_core.pipeline.user.create_user), an IntegrityError during user creation triggers a fallback that returns an existing User looked up by e-mail, effectively performing social_core.pipeline.social_auth.associate_by_email even when that step is disabled. <5.6.0
sqlalchemy Sqlalchemy 2.0.0b1 avoids leaking cleartext passwords to the open for careless uses of str(engine.URL()) in logs and prints. sqlalchemy/sqlalchemy#8563 <2.0.0b1
xmltodict (transitive) Affected versions of the xmltodict package are vulnerable to Improper Input Validation due to insufficient validation of XML element, attribute, and xmlns prefix names. The xmltodict._validate_name function did not reject the ", ', and = characters, allowing unparse to serialize keys into tag or attribute names containing illegal tokens and produce ill-formed XML. <0.15.1

Outdated dependencies

49 outdated dependencies found (including 17 outdated major versions)😢
Dependency Installed version Latest version
alabaster (transitive) 0.7.16 1.0.0
aldjemy 2.6 3.2
argon2-cffi (transitive) 21.3.0 25.1.0
crispy-bootstrap4 (transitive) 2024.1 2025.6
django 4.2.27 6.0
django-model-utils (transitive) 4.4.0 5.0.0
django-rest-knox (transitive) 4.2.0 5.0.2
ipython (dev,transitive) 8.37.0 9.8.0
packaging (transitive) 23.2 25.0
protobuf 5.29.5 6.33.1
setuptools (transitive) 70.0.0 80.9.0
sphinx (transitive) 7.2.6 9.0.4
sphinx-rtd-theme (transitive) 2.0.0 3.0.2
sqlalchemy 1.4.54 2.0.44
unidecode (transitive) 0.4.21 1.4.0
wrapt 1.17.3 2.0.1
xmltodict (transitive) 0.13.0 1.0.2
Dependency Installed version Latest version
aiobotocore (transitive) 2.25.2 2.26.0
anyio (transitive) 4.11.0 4.12.0
beautifulsoup4 4.14.2 4.14.3
billiard (transitive) 4.2.3 4.2.4
botocore (transitive) 1.40.70 1.42.2
celery (transitive) 5.3.6 5.6.0
django-autocomplete-light (transitive) 3.11.0 3.12.1
django-coverage-plugin (dev) 3.1.1 3.2.0
django-crispy-forms (transitive) 2.1 2.5
django-environ (transitive) 0.11.2 0.12.0
django-iconify (transitive) 0.3 0.4.1
django-postgres-copy 2.3.7 2.8.0
django-sodar-core 1.0.6 1.3.0
djangorestframework 3.15.2 3.16.1
docutils (transitive) 0.20.1 0.22.3
drf-spectacular-sidecar (transitive) 2025.10.1 2025.12.1
flake8-pyproject (dev) 1.2.3 1.2.4
fsspec (transitive) 2025.10.0 2025.12.0
markdown (transitive) 3.5.2 3.10
mistune (transitive) 3.0.2 3.1.4
numpy 2.2.6 2.3.5
pydantic 2.12.4 2.12.5
requests-http-signature 0.2.0 0.7.1
rpds-py (transitive) 0.29.0 0.30.0
rules (transitive) 3.3 3.5
s3fs 2025.10.0 2025.12.0
sentry-sdk 2.46.0 2.47.0
social-auth-app-django (transitive) 5.4.3 5.6.0
sphinx-jsonschema 1.19.1 1.19.2
universal-pathlib 0.3.6 0.3.7
vcfpy 0.13.8 0.14.2
wheel (transitive) 0.42.0 0.46.1

Logs

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/src/variants/stores/variantQuery.js (1)

635-678: New preset label state is not reset in $reset (state leak across cases)

$reset clears many store fields but leaves selectedQuickPresetLabel, selectedQuickPresetLabelVersion, and categoryPresetLabels untouched. This can leak preset label metadata from a previous case/query into subsequent ones, affecting both UI and exported metadata.

Recommend resetting these alongside the other query‑related fields:

     queryLogs.value = null
     quickPresets.value = null
+    selectedQuickPresetLabel.value = null
+    selectedQuickPresetLabelVersion.value = 1
+    categoryPresetLabels.value = null
     categoryPresets.value = {
       inheritance: null,
       frequency: null,
       impact: null,
       quality: null,
       chromosomes: null,
       flagsetc: null,
     }
🧹 Nitpick comments (2)
backend/variants/query_schemas.py (1)

486-491: Consider coupling version with label presence.

The _quick_preset_label_version is written independently of _quick_preset_label. Since the version is meaningless without a label, consider conditionally writing it only when the label is also present:

         # Preserve the quick preset label and version if present
         if query._quick_preset_label is not None:
             result["_quick_preset_label"] = query._quick_preset_label
-        if query._quick_preset_label_version is not None:
-            result["_quick_preset_label_version"] = query._quick_preset_label_version
+            if query._quick_preset_label_version is not None:
+                result["_quick_preset_label_version"] = query._quick_preset_label_version
         if query._category_preset_labels is not None:
             result["_category_preset_labels"] = query._category_preset_labels
backend/variants/views/api/export.py (1)

484-499: Consider extracting duplicated preset display mappings.

The preset_order and preset_display_names are duplicated between PDF and DOCX export sections. Consider extracting these to module-level constants alongside existing ones like FREQUENCY_DATABASES:

# Near line 1271 with other constants
CATEGORY_PRESET_ORDER = [
    "inheritance",
    "frequency",
    "impact",
    "quality",
    "chromosomes",
    "flagsetc",
]

CATEGORY_PRESET_DISPLAY_NAMES = {
    "inheritance": "Inheritance",
    "frequency": "Frequency",
    "impact": "Impact",
    "quality": "Quality",
    "chromosomes": "Chromosomes",
    "flagsetc": "Flags etc.",
}

Also applies to: 2445-2453

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ca3a65 and e46dd0e.

📒 Files selected for processing (7)
  • backend/variants/query_schemas.py (2 hunks)
  • backend/variants/schemas/case-query-v1.json (1 hunks)
  • backend/variants/views/api/export.py (2 hunks)
  • frontend/src/variants/components/FilterForm/QuickPresets.vue (7 hunks)
  • frontend/src/variants/components/FilterResultsTable.vue (2 hunks)
  • frontend/src/variants/stores/variantQuery.js (3 hunks)
  • frontend/src/variants/stores/variantResultSet.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2024-10-09T06:48:09.413Z
Learnt from: holtgrewe
Repo: varfish-org/varfish-server PR: 1957
File: frontend/src/seqvars/queries/seqvarResultRow.ts:110-112
Timestamp: 2024-10-09T06:48:09.413Z
Learning: In `frontend/src/seqvars/queries/seqvarResultRow.ts`, within the `useSeqvarResultRowRetrieveQueries` function, using `toValue(resultRowUuids)?.length` in the `enabled` function is necessary for transparent access into refs or getters.

Applied to files:

  • frontend/src/variants/stores/variantResultSet.ts
📚 Learning: 2024-10-10T10:50:55.833Z
Learnt from: holtgrewe
Repo: varfish-org/varfish-server PR: 1957
File: frontend/src/seqvars/views/SeqvarsQuery/SeqvarsQuery.vue:74-87
Timestamp: 2024-10-10T10:50:55.833Z
Learning: Currently, it's not necessary to implement removal logic for `openQueryUuids` in `frontend/src/seqvars/views/SeqvarsQuery/SeqvarsQuery.vue`.

Applied to files:

  • frontend/src/variants/stores/variantResultSet.ts
  • frontend/src/variants/components/FilterResultsTable.vue
📚 Learning: 2024-10-22T09:14:05.541Z
Learnt from: holtgrewe
Repo: varfish-org/varfish-server PR: 2046
File: frontend/src/seqvars/components/QueryEditor/QueryEditor.vue:481-496
Timestamp: 2024-10-22T09:14:05.541Z
Learning: In `frontend/src/seqvars/components/QueryEditor/QueryEditor.vue`, when comparing column settings in the `columnsMatchPreset` function, the order of columns is significant and should not be altered. Do not sort the column arrays before comparison because the order matters.

Applied to files:

  • frontend/src/variants/components/FilterForm/QuickPresets.vue
  • frontend/src/variants/components/FilterResultsTable.vue
📚 Learning: 2024-10-22T09:13:36.978Z
Learnt from: holtgrewe
Repo: varfish-org/varfish-server PR: 2046
File: frontend/src/seqvars/components/PresetsEditor/CategoryPresetsColumnsEditor.vue:304-304
Timestamp: 2024-10-22T09:13:36.978Z
Learning: In the `varfish-server` project using Vue.js version 3, the non-null assertion operator `!` is allowed in template expressions. Therefore, using `data.column_settings!.length` in `CategoryPresetsColumnsEditor.vue` is acceptable.

Applied to files:

  • frontend/src/variants/components/FilterResultsTable.vue
🧬 Code graph analysis (3)
frontend/src/variants/stores/variantResultSet.ts (2)
frontend/src/variants/stores/variantQuery.js (4)
  • variantClient (24-24)
  • variantClient (121-121)
  • variantClient (157-157)
  • variantClient (169-169)
backend/seqvars/protos/output_pb2.pyi (1)
  • query (343-344)
backend/variants/views/api/export.py (1)
backend/variants/views/api/__init__.py (5)
  • get (690-691)
  • get (710-718)
  • get (737-745)
  • get (781-821)
  • get (863-883)
frontend/src/variants/stores/variantQuery.js (1)
frontend/src/varfish/helpers.ts (1)
  • copy (249-251)
⏰ 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). (6)
  • GitHub Check: build-and-push-image
  • GitHub Check: Python-Lint
  • GitHub Check: Python-Test
  • GitHub Check: Analyze (python)
  • GitHub Check: Python-Test
  • GitHub Check: Python-Lint
🔇 Additional comments (14)
frontend/src/variants/stores/variantResultSet.ts (1)

134-136: LGTM - Query loading for preset metadata access.

The addition correctly fetches the query to access preset label settings. The implementation follows the existing pattern in fetchResultSetViaRow (lines 178-182) where query retrieval is already performed.

backend/variants/query_schemas.py (1)

330-333: New metadata fields for preset tracking look good.

The underscore prefix convention appropriately marks these as internal metadata fields. The implementation correctly uses Optional types and reasonable defaults.

frontend/src/variants/components/FilterResultsTable.vue (3)

586-608: Computed properties for preset display are well-implemented.

Good fallback handling: returns the stored label, defaults to 'custom' for queries without preset metadata, and shows '-' when no query is loaded yet. The version property correctly returns null when unavailable.


620-719: Export functionality is robust with appropriate fallbacks.

The implementation includes:

  • Proper source detection (applied query vs current settings)
  • Correct CSRF token handling
  • Content-Disposition header parsing for filename
  • Graceful JSON fallback when backend export fails

One minor observation: the endpoint URL is hardcoded. Consider extracting to a constant or using a route configuration if this pattern is used elsewhere.


787-805: Quick Preset badge UI is well-integrated.

The badge displays the preset label with a dynamic tooltip that conditionally includes the version number. The styling is consistent with the existing UI patterns.

frontend/src/variants/components/FilterForm/QuickPresets.vue (3)

419-458: Category preset labels function is well-structured.

The implementation correctly:

  • Checks each category preset for non-custom values
  • Falls back to the preset name if no label is available
  • Cleans up by setting to null when no labels are present
  • Uses optional chaining for safe property access

346-354: Quick preset label synchronization is correct.

The store's selectedQuickPresetLabel is properly updated both when a matching preset is found and when falling back to 'custom'.


373-382: Handle custom preset selection correctly.

Good handling of the custom case by clearing categoryPresetLabels to null when the user explicitly selects custom mode.

backend/variants/views/api/export.py (2)

446-533: PDF export correctly renders preset metadata.

The implementation properly:

  • Defaults to "custom" when no quick preset label is set
  • Formats version conditionally (only when present)
  • Renders category presets in a consistent order with user-friendly names
  • Only creates the category table when data exists

2427-2485: DOCX export preset additions are consistent with PDF implementation.

The logic mirrors the PDF export changes, maintaining consistency across export formats. Header styling for the category presets table correctly applies bold formatting.

frontend/src/variants/stores/variantQuery.js (3)

296-301: State fields for preset labels look reasonable

The three new refs for selectedQuickPresetLabel, selectedQuickPresetLabelVersion, and categoryPresetLabels are well‑documented and fit the existing store pattern. No functional issues here.


361-371: Query payload enrichment with preset metadata is correct

Using a deep copy via copy(querySettings.value) and then attaching _quick_preset_label, _quick_preset_label_version, and _category_preset_labels before submission is a clean approach and avoids mutating querySettings.value. This aligns with the new backend schema.


703-706: Exposing new preset label fields from the store is consistent

Exporting selectedQuickPresetLabel, selectedQuickPresetLabelVersion, and categoryPresetLabels in the returned object is consistent with how other reactive state is surfaced and should integrate cleanly with the updated components.

backend/variants/schemas/case-query-v1.json (1)

1504-1535: New preset label schema fields are well‑typed and consistent

The additions for _quick_preset_label, _quick_preset_label_version, and _category_preset_labels are JSON‑Schema‑correct, optional, and match the intended semantics (string/integer or null, with sensible defaults). Restricting _category_preset_labels to the known category keys with additionalProperties: false is a good choice for keeping the public surface precise.

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