Skip to content

Deep review and refactor#5198

Draft
IvanIvanoff wants to merge 3 commits into
masterfrom
deep-review
Draft

Deep review and refactor#5198
IvanIvanoff wants to merge 3 commits into
masterfrom
deep-review

Conversation

@IvanIvanoff

Copy link
Copy Markdown
Member

Changes

Add context modules / facades

  • Add Sanbase.Insights — single entry point for the insights domain (post CRUD, listings, images, pulse).
  • Add Sanbase.Accounts.Auth — eth-login, email-login send/verify, email-change orchestration.
  • Add Sanbase.Alerts — UserTrigger creation + Telegram notification + :tags preload.
  • Add Sanbase.AI.ContentCandidates — admin AI-description queries (list/count/pending/override/search).
  • Add Sanbase.Changelog — unified metric + asset changelog read facade.
  • Add Sanbase.MetricRegistry — thin facade over registry/category/UI-metadata (trimmed to used surface).
  • Extend Sanbase.Billing — Stripe/subscription facade (sanbase_plan_name, user_has_product_access?, payments, coupon, invoice, payment-instrument, setup-intent).
  • Extend Sanbase.Accounts — update_profile/2, update_terms_and_conditions/2 (field allowlists), reload_user_settings/1.
  • Add Sanbase.Transfers.enrich_with_labels/3 and Sanbase.Vote.dataloader_keys/1 (polymorphic vote dispatch).
  • Add Report.create/1 + update/2; rename new_changeset → change_report.

Refactor (thin the web layer onto the facades)

  • Reduce resolvers to argument-marshalling: auth, billing, insight, vote, user, user_trigger, changelog, blockchain_address, project_transfers, report, sheets_template, webinar,
    linked_user.
  • Collapse the 7-clause vote/voted_at struct dispatch into one Vote.dataloader_keys/1 path.
  • Move admin AiDescriptionLive off raw Repo/Ecto.Query onto ContentCandidates.

Rename / move

  • Sanbase.Webinar → Sanbase.Webinars.Webinar (+ all call sites).

Cleanup

  • Trim MetricRegistry facade 27→4 delegates; drop unused Insights.pulse?/1.

IvanIvanoff and others added 3 commits June 3, 2026 17:15
Replace direct cross-module access from the web/transport layer with
thin context-module facades, following the Phoenix context pattern.
Resolvers and LiveViews now talk to a single domain entry point per
concern instead of reaching into 3–5 sibling modules.

Changes

* Sanbase.AI.ContentCandidates
  - Drop raw Repo/Ecto.Query usage from ai_description_live.ex
  - Replace 13 inline queries with 6 context calls
    (list/4, pending_ids/2, count/2, override_descriptions/2,
    search_users/1, get_user/1)

* Sanbase.Insights
  - New facade hiding Insight.Post, PostImage, ImageUrl,
    PopularAuthor, Category, Tag
  - insight_resolver.ex shrunk from 312 to 141 LOC, now thin
    transport
  - Moves resolve_post_images and rate-limited create_post into
    the context

* Sanbase.Billing hides Stripe
  - 8 new wrappers: refresh_subscription_payment_intent,
    list_payments, retrieve_coupon, upcoming_invoice,
    default_payment_instrument, update_default_payment_instrument,
    delete_default_payment_instrument, create_setup_intent,
    san_credit_balance
  - Move transform_payments and choose_default_card into Billing
  - billing_resolver.ex: drop alias Sanbase.StripeApi; all
    StripeApi callsites routed through Billing

* Sanbase.MetricRegistry facade
  - New module re-exporting Registry, Sync, ChangeSuggestion,
    Category, UIMetadata, MetricVersions surface area
  - metric_display_order_resolver.ex migrated to the facade
  - Admin LiveView migration intentionally deferred to a
    follow-up sweep

* Sanbase.Changelog + Webinars rename
  - New Sanbase.Changelog unifies MetricVersions and
    ProjectVersions changelog reads
  - changelog_resolver.ex routes both metric and asset
    changelogs through the facade
  - Rename Sanbase.Webinar -> Sanbase.Webinars.Webinar across
    webinar.ex, registration.ex, generic_admin/webinar.ex,
    webinar_resolver.ex, test/support/factory/factory.ex
The MetricRegistry façade shipped 27 delegates but only 4 have a consumer
(metric_display_order_resolver); drop the 23 unused ones so the façade reflects
its actual call sites. Likewise remove the unused Insights.pulse?/1 delegate —
pulse_text/1 calls Post.pulse?/1 directly and nothing else references it.

Behavior-preserving: no call site referenced the removed functions (verified by
grep + a full test run across the touched facades).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 66a39b2f-c5c7-4e41-9870-c39df2f8d196

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch deep-review

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.

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