Skip to content

feat: added locations transformers based on shortcodes#360

Merged
raven-wing merged 5 commits into
Problematy:mainfrom
raven-wing:plugin_fields
Jun 8, 2026
Merged

feat: added locations transformers based on shortcodes#360
raven-wing merged 5 commits into
Problematy:mainfrom
raven-wing:plugin_fields

Conversation

@raven-wing

@raven-wing raven-wing commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Refactor

    • Photo attachment system updated to use configuration-based handling
    • Location detail formatting improved with new field transformation capabilities
    • Updated API integration with revised photo attachment and data formatting system
  • Chores

    • Upgraded platzky dependency from 2.0.0a0 to 2.0.0a2

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@raven-wing, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 24 minutes and 33 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5b03173d-968c-4522-8444-ce22965e719f

📥 Commits

Reviewing files that changed from the base of the PR and between dab7013 and d6eaafe.

📒 Files selected for processing (6)
  • .github/workflows/tests.yml
  • goodmap/core_api.py
  • goodmap/formatter.py
  • goodmap/goodmap.py
  • tests/unit_tests/test_core_api.py
  • tests/unit_tests/test_formatter.py
📝 Walkthrough

Walkthrough

This PR refactors photo attachment creation and field rendering from class-based dependency injection and dict-based field renderers to configuration-driven and shortcode-based approaches, enabling the application to shift toward declarative configuration while maintaining the same public API contract for location detail responses.

Changes

Configuration-Driven Attachment and Field Rendering

Layer / File(s) Summary
Platzky dependency update
pyproject.toml
The platzky library is bumped from 2.0.0a0 to 2.0.0a2 to support the new create_attachment function and the relocated MIME validation module used by photo upload handlers.
Formatter refactoring – shortcode-based field transformation
goodmap/formatter.py, tests/unit_tests/test_formatter.py
prepare_pin() is refactored to accept shortcodes: dict[str, Shortcode] instead of field_plugins; the removed _apply_field_plugin helper and base64 import are replaced with direct calls to shortcode.transform_field_value() when a field name matches a shortcode. Tests are rewritten to validate scalar transformation and default merging instead of dict-wrapping and base64-encoding behavior.
Core API refactoring – attachment and pin formatting integration
goodmap/core_api.py, tests/unit_tests/test_core_api.py
core_pages() signature changes from photo_attachment_class and field_renderers to photo_attachment_config and shortcodes; the /suggest-new-point endpoint uses create_attachment(file, photo_attachment_config) instead of class instantiation, and /location/<location_id> passes shortcodes to prepare_pin(). Test mocks are updated to the new platzky MIME validation path.
App configuration – wiring new approaches
goodmap/goodmap.py
The create_attachment_class import is removed, eliminating the PhotoAttachment class construction; an inline photo_attachment_config is passed to core_pages() instead. The field_renderers initialization from app.shortcodes is removed, and shortcodes are now passed directly to core_pages().

Sequence Diagram

sequenceDiagram
  participant Client
  participant API as core_api
  participant Formatter as prepare_pin()
  participant Shortcodes as shortcodes
  Client->>API: POST /api/suggest-new-point (multipart photo)
  API->>API: create_attachment(file, config)
  API->>API: store suggestion
  Client->>API: GET /location/{id}
  API->>Formatter: prepare_pin(place, visible_fields, shortcodes)
  loop each visible field
    Formatter->>Shortcodes: lookup field in shortcodes
    alt shortcode exists
      Shortcodes->>Formatter: transform_field_value(value)
    end
  end
  Formatter->>API: formatted_data
  API->>Client: location detail JSON
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Problematy/goodmap#324: Both PRs modify goodmap/core_api.py's /suggest-new-point multipart photo handling and core_pages photo-attachment plumbing (one adds file validation via photo_attachment_class, the other refactors attachment creation to use photo_attachment_config/create_attachment).

Poem

🐰 A rabbit hops through tangled wires,
No more class injection feeds the fires,
Configuration smooths the way,
Shortcodes transform—hip hooray!
The photo flows, the fields align,
This refactor makes the API shine! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main refactoring: replacing field_renderers/field_plugins with a shortcodes-based transformation system across the codebase.
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 unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@goodmap/formatter.py`:
- Around line 34-38: Update the formatter module docstring to reflect current
behavior: state that dict-valued fields whose field name matches a shortcode are
transformed via Shortcode.transform_field_value(), and that when no matching
shortcode exists the value is passed through after safe_gettext (not dropped).
Reference the shortcodes mapping, Shortcode.transform_field_value, and
safe_gettext in the docstring so it accurately describes the behavior
implemented in the formatter functions.
🪄 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

Run ID: cf548db4-ae35-495f-adc0-3907a8d5739e

📥 Commits

Reviewing files that changed from the base of the PR and between de223e7 and dab7013.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • goodmap/core_api.py
  • goodmap/formatter.py
  • goodmap/goodmap.py
  • pyproject.toml
  • tests/unit_tests/test_core_api.py
  • tests/unit_tests/test_formatter.py

Comment thread goodmap/formatter.py Outdated
raven-wing and others added 2 commits June 8, 2026 00:26
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

🧪 E2E Test Results

📊 View full workflow run
🔗 Commit: a3b9740

⚠️ E2E Stress Test Results

Performance data not found. See workflow logs for details.

1 similar comment
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

🧪 E2E Test Results

📊 View full workflow run
🔗 Commit: a3b9740

⚠️ E2E Stress Test Results

Performance data not found. See workflow logs for details.

@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

🧪 E2E Test Results

📊 View full workflow run
🔗 Commit: d6eaafe

📊 E2E Stress Test Performance

Status: PASSED (12141.24ms max < 25000ms limit)

Metric Value
Average Time 11302.53ms
Minimum Time 10824.28ms
Maximum Time 12141.24ms
Completed Runs 5/5
Avg Markers Loaded 71
📈 Individual Run Times
Run Time (ms) Markers
Run 1 10881.38ms 71
Run 2 11562.49ms 71
Run 3 11103.28ms 71
Run 4 12141.24ms 71
Run 5 10824.28ms 71

@raven-wing raven-wing merged commit 23a7497 into Problematy:main Jun 8, 2026
11 checks passed
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