From fd75e45715017d7553ae3f5d83db6388a3fdceec Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Wed, 6 Apr 2016 13:23:31 +0100 Subject: [PATCH] Multitenant DynamoDB collector should use a string for the hash key. This is because the key is of the form "-", but as I was testing without a userid, I didn't notice that "-" was a valid number. --- app/multitenant/dynamo_collector.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/multitenant/dynamo_collector.go b/app/multitenant/dynamo_collector.go index 8c6e34b8f4..8236195168 100644 --- a/app/multitenant/dynamo_collector.go +++ b/app/multitenant/dynamo_collector.go @@ -65,7 +65,7 @@ func (c *dynamoDBCollector) CreateTables() error { AttributeDefinitions: []*dynamodb.AttributeDefinition{ { AttributeName: aws.String(hourField), - AttributeType: aws.String("N"), + AttributeType: aws.String("S"), }, { AttributeName: aws.String(tsField), @@ -104,7 +104,7 @@ func (c *dynamoDBCollector) getRows(userid string, row int64, start, end time.Ti KeyConditions: map[string]*dynamodb.Condition{ hourField: { AttributeValueList: []*dynamodb.AttributeValue{ - {N: aws.String(rowKey)}, + {S: aws.String(rowKey)}, }, ComparisonOperator: aws.String("EQ"), }, @@ -158,11 +158,11 @@ func (c *dynamoDBCollector) Report(ctx context.Context) (report.Report, error) { // Queries will only every span 2 rows max. if rowStart != rowEnd { if result, err = c.getRows(userid, rowStart, start, now, result); err != nil { - return report.MakeReport(), nil + return report.MakeReport(), err } } if result, err = c.getRows(userid, rowEnd, start, now, result); err != nil { - return report.MakeReport(), nil + return report.MakeReport(), err } return result, nil } @@ -186,7 +186,7 @@ func (c *dynamoDBCollector) Add(ctx context.Context, rep report.Report) error { TableName: aws.String(tableName), Item: map[string]*dynamodb.AttributeValue{ hourField: { - N: aws.String(rowKey), + S: aws.String(rowKey), }, tsField: { N: aws.String(strconv.FormatInt(now.UnixNano(), 10)),