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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"dependencies": {
"@aws-sdk/client-sns": "^3.1000.0",
"@monaco-editor/react": "^4.7.0",
"@robosystems/client": "0.2.44",
"@robosystems/client": "0.2.45",
"date-fns": "^4.1.0",
"flowbite": "^3.1",
"flowbite-react": "^0.12.5",
Expand Down
40 changes: 4 additions & 36 deletions src/app/(app)/usage/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
getCreditSummary,
getGraphLimits,
getGraphs,
getStorageUsage,
listCreditTransactions,
} from '@robosystems/client'
import { Alert, Badge, Button, Card, Progress, Spinner } from 'flowbite-react'
Expand All @@ -32,12 +31,6 @@ interface CreditSummary {
graph_tier: string
}

interface StorageUsage {
current_usage_gb: number
max_storage_gb: number
storage_cost_per_day?: number
}

interface GraphLimits {
subscription_tier: string
graph_tier: string
Expand Down Expand Up @@ -77,7 +70,6 @@ interface CreditTransaction {
interface UsageData {
graphInfo: GraphInfo
creditSummary?: CreditSummary
storageUsage?: StorageUsage
graphLimits?: GraphLimits
recentTransactions?: CreditTransaction[]
}
Expand Down Expand Up @@ -119,35 +111,17 @@ export function UsageContent() {

const usageData: UsageData = { graphInfo }

// Determine if this is a repository
const isRepo = graphInfo.isRepository

// Fetch all usage data in parallel (skip storage for repositories)
const apiCalls = [
// Fetch all usage data in parallel
const [limitsRes, creditRes, transactionsRes] = await Promise.allSettled([
getGraphLimits({ path: { graph_id: graphId } }),
getCreditSummary({ path: { graph_id: graphId } }),
listCreditTransactions({
path: { graph_id: graphId },
query: { limit: 10 },
}),
]

// Only fetch storage for user graphs, not repositories
if (!isRepo) {
apiCalls.splice(
2,
0,
getStorageUsage({ path: { graph_id: graphId } }) as any
)
}
])

const results = await Promise.allSettled(apiCalls)

const [limitsRes, creditRes, storageRes, transactionsRes] = isRepo
? [results[0], results[1], { status: 'rejected' as const }, results[2]]
: [results[0], results[1], results[2], results[3]]

// Process limits
// Process limits (includes instance storage usage)
if (limitsRes.status === 'fulfilled' && limitsRes.value.data) {
usageData.graphLimits = limitsRes.value.data as unknown as GraphLimits
}
Expand All @@ -158,12 +132,6 @@ export function UsageContent() {
.data as unknown as CreditSummary
}

// Process storage
if (storageRes.status === 'fulfilled' && storageRes.value.data) {
usageData.storageUsage = storageRes.value
.data as unknown as StorageUsage
}

// Process transactions
if (
transactionsRes.status === 'fulfilled' &&
Expand Down
10 changes: 2 additions & 8 deletions src/lib/core/contexts/service-offerings-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export interface ServiceOfferings {
monthlyPrice: number
monthlyCredits: number
features: string[]
limits?: {
maxNodes?: number
maxRelationships?: number
}
instanceStorageLimitGb?: number
creditMultiplier: number
}
}
Expand Down Expand Up @@ -115,10 +112,7 @@ export function ServiceOfferingsProvider({
features: tier.features || [],
creditMultiplier:
apiData.graph_subscriptions?.tier_multipliers?.[tier.name] || 1,
limits: {
maxNodes: tier.max_nodes,
maxRelationships: tier.max_relationships,
},
instanceStorageLimitGb: tier.instance_storage_limit_gb,
}
})
}
Expand Down
12 changes: 0 additions & 12 deletions src/lib/core/lib/__tests__/graph-tiers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,18 @@ describe('graph-tiers', () => {
display_name: 'Free',
monthly_price: 0,
max_subgraphs: 0,
limits: {
max_nodes: 1000,
max_relationships: 1000,
},
},
{
tier: 'basic',
display_name: 'Basic',
monthly_price: 29,
max_subgraphs: 1,
limits: {
max_nodes: 10000,
max_relationships: 10000,
},
},
{
tier: 'premium',
display_name: 'Premium',
monthly_price: 99,
max_subgraphs: 5,
limits: {
max_nodes: 100000,
max_relationships: 100000,
},
},
] as GraphTier[],
}
Expand Down
Loading