Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions backend/alembic/versions/d88681a7b3d0_add_tier_to_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('app_states')
op.drop_table('events')
op.drop_table('sessions')
op.drop_table('user_states')
conn = op.get_bind()
inspector = sa.inspect(conn)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 This is a good improvement to make the migration more robust by checking if tables exist before attempting to drop them. This prevents potential errors in environments where these tables might not be present.

existing = inspector.get_table_names()
for tbl in ('app_states', 'events', 'sessions', 'user_states'):
if tbl in existing:
op.drop_table(tbl)
with op.batch_alter_table('plans', schema=None) as batch_op:
batch_op.add_column(sa.Column('tier', sa.Integer(), server_default='0', nullable=False))

Expand Down
7 changes: 4 additions & 3 deletions frontend/src/app/dashboard/widget-settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ export default function WidgetSettingsPage() {
const res = await getBusinessProfile();
if (res.status === 'success' && res.data) {
setBusiness(res.data);
const d = res.data as unknown as Record<string, number | undefined>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Introducing a temporary variable d to hold the casted res.data improves readability and reduces repetitive type assertions.

setLimits({
allocated_messages_per_session: (res.data as Record<string, unknown>).allocated_messages_per_session,
allocated_daily_sessions: (res.data as Record<string, unknown>).allocated_daily_sessions,
allocated_whitelisted_domains: (res.data as Record<string, unknown>).allocated_whitelisted_domains,
allocated_messages_per_session: d.allocated_messages_per_session,
allocated_daily_sessions: d.allocated_daily_sessions,
allocated_whitelisted_domains: d.allocated_whitelisted_domains,
});
Comment on lines +82 to 87

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The double type assertion (as unknown as Record<string, number | undefined>) is redundant and bypasses TypeScript's type safety. Since getBusinessProfile() returns ApiResponse<BusinessProfile> and BusinessProfile already defines allocated_messages_per_session, allocated_daily_sessions, and allocated_whitelisted_domains as optional numbers, you can access these properties directly on res.data without any type assertions.

        setLimits({
          allocated_messages_per_session: res.data.allocated_messages_per_session,
          allocated_daily_sessions: res.data.allocated_daily_sessions,
          allocated_whitelisted_domains: res.data.allocated_whitelisted_domains,
        });

}
} catch (e) { console.error(e); }
Expand Down
Loading