Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix a number of bugs with ProvisionStore#getConsumer #223

Merged
merged 2 commits into from
Sep 5, 2023
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
48 changes: 24 additions & 24 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 upload-api/functions/ucan-invocation-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export async function ucanInvocationRouter(request) {
CONSUMER_TABLE_NAME: consumerTableName = '',
SUBSCRIPTION_TABLE_NAME: subscriptionTableName = '',
DELEGATION_TABLE_NAME: delegationTableName = '',
SPACE_METRICS_TABLE: spaceMetricsTableName = '',
SPACE_METRICS_TABLE_NAME: spaceMetricsTableName = '',
RATE_LIMIT_TABLE_NAME: rateLimitTableName = '',
R2_ENDPOINT: r2DelegationBucketEndpoint = '',
R2_ACCESS_KEY_ID: r2DelegationBucketAccessKeyId = '',
Expand Down
2 changes: 1 addition & 1 deletion upload-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@web-std/fetch": "^4.1.0",
"@web3-storage/access": "^14.0.0",
"@web3-storage/capabilities": "^9.0.0",
"@web3-storage/upload-api": "^5.2.0",
"@web3-storage/upload-api": "^5.3.0",
"@web3-storage/w3infra-ucan-invocation": "*",
"multiformats": "^11.0.1",
"nanoid": "^4.0.2",
Expand Down
19 changes: 8 additions & 11 deletions upload-api/tables/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,17 @@ export function useConsumerTable (dynamoDb, tableName) {
const response = await dynamoDb.send(new QueryCommand({
TableName: tableName,
IndexName: 'consumer',
KeyConditionExpression: "consumer = :consumer and provider = :provider",
KeyConditionExpression: "consumer = :consumer",
ExpressionAttributeValues: {
':consumer': { S: consumer },
':provider': { S: provider }
},
}))
if (response.Items && (response.Items.length > 0)) {
const record = unmarshall(response.Items[0])
return {
subscription: record.subscription
}
} else {
return null
}
}))
// we may need to worry about pagination in the future if we end up supporting many many subscriptions for a single
// provider/consumer pair, but I suspect we'll never get there
const record = response.Items?.map(i => unmarshall(i)).find(i => i.provider === provider)
return record ? {
subscription: record.subscription
} : null
},

/**
Expand Down
5 changes: 2 additions & 3 deletions upload-api/tables/space-metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ export function useSpaceMetricsTable(dynamoDb, tableName) {
const response = await dynamoDb.send(new GetItemCommand({
TableName: tableName,
Key: marshall({
consumer,
space: consumer,
name: METRICS_NAMES.STORE_ADD_SIZE_TOTAL
}),
AttributesToGet: ['value']
})
}))
return response.Item ? unmarshall(response.Item).value : 0
}
Expand Down