Skip to content

Conversation

jakubno
Copy link
Member

@jakubno jakubno commented Oct 10, 2025

  • Add addons table
  • Simplifies types for team, moves the querying to db and types to dedicated module, limits the usage of generated types

Note

Adds addons table and refactors API to use a unified types.Team with computed limits (replacing tier usage) across auth, handlers, orchestration, and template flows.

  • DB:
    • Addons: New public.addons table and migration with RLS; aggregates extra limits into team queries.
    • Queries: Consolidate team fetches into teams__get.sql returning tier + addon extras; remove old tier-specific queries.
  • Types/Models:
    • New internal/db/types: adds Team, TeamLimits, TeamWithDefault; builds limits from tier + addons.
    • Removes Tier ent schema and related generated code; Team retains tier as string.
  • Auth/Cache:
    • Auth cache returns *types.Team (drops tier in cache); authentication functions updated to use *types.Team.
  • API Handlers:
    • Switch from GetTeamAndTier to GetTeamAndLimits; all handlers use *types.Team and enforce team.Limits (timeout, CPU/RAM checks, metrics, logs, lists, template ops).
  • DB Access Layer:
    • New helpers: GetTeamAuth, GetTeamByUser, GetTeamByIDAndUserIDAuth constructing types.Team with limits.
  • Orchestrator/Template:
    • Sandbox creation and accounting use team.Limits (concurrency, max length).
    • Template build registration limits build concurrency and resources via team.Limits.
  • Misc:
    • LaunchDarkly context now uses team tier string; request logging updated to deref *types.Team.

Written by Cursor Bugbot for commit bd08a5e. This will update automatically on new commits. Configure here.

@jakubno jakubno added the improvement Improvement for current functionality label Oct 10, 2025
Copy link

linear bot commented Oct 10, 2025

@jakubno jakubno force-pushed the refactor-api-to-use-the-new-add-ons-table-eng-3069 branch 5 times, most recently from 61c521c to dd8cc31 Compare October 13, 2025 08:21
@jakubno jakubno marked this pull request as ready for review October 13, 2025 09:53
@sitole sitole self-assigned this Oct 13, 2025
cursor[bot]

This comment was marked as outdated.

@jakubno jakubno force-pushed the refactor-api-to-use-the-new-add-ons-table-eng-3069 branch from a006852 to bd08a5e Compare October 15, 2025 08:38
AND addon.valid_from <= now()
AND (addon.valid_to IS NULL OR addon.valid_to > now())
) a ON true
WHERE ut.user_id = $1 AND t.id = $2;
Copy link
Member

Choose a reason for hiding this comment

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

Can we create view that will precalculate addon values per team so we dont need to do this sum in multiple queries?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe sqlc comes with some way how to re-use part of query

ctx := c.Request.Context()

teams, err := a.sqlcDB.GetTeamsWithUsersTeamsWithTier(ctx, userID)
teams, err := dbapi.GetTeamByUser(ctx, a.sqlcDB, userID)
Copy link
Member

Choose a reason for hiding this comment

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

GetTeamByUser -> GetTeamsByUser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement for current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants