Skip to content

Commit

Permalink
Don't look up in DynamoDB
Browse files Browse the repository at this point in the history
  • Loading branch information
vegarsti committed Aug 14, 2024
1 parent c469105 commit c64999c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions cmd/lambda/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,19 @@ func main() {

// getTable either cached from DynamoDB if it has been processed before, or perform OCR with Textract
func getTable(file *extract.File) ([][]string, error) {
startGet := time.Now()
tableBytes, err := dynamodb.GetTable(file.Checksum)
if err != nil {
return nil, fmt.Errorf("dynamodb.GetTable: %w", err)
}
log.Printf("dynamodb get: %s", time.Since(startGet).String())
if tableBytes != nil {
var table [][]string
if err := json.Unmarshal(tableBytes, &table); err != nil {
return nil, fmt.Errorf("failed to convert from json: %w", err)
}
return table, nil
}
// startGet := time.Now()
// tableBytes, err := dynamodb.GetTable(file.Checksum)
// if err != nil {
// return nil, fmt.Errorf("dynamodb.GetTable: %w", err)
// }
// log.Printf("dynamodb get: %s", time.Since(startGet).String())
// if tableBytes != nil {
// var table [][]string
// if err := json.Unmarshal(tableBytes, &table); err != nil {
// return nil, fmt.Errorf("failed to convert from json: %w", err)
// }
// return table, nil
// }
// Old: Textract's Analyze Document
// output, err := textract.AnalyzeDocument(file)
// if err != nil {
Expand Down Expand Up @@ -183,7 +183,7 @@ func getTable(file *extract.File) ([][]string, error) {
}
}()

tableBytes, err = json.MarshalIndent(tableStringsSorted, "", " ")
tableBytes, err := json.MarshalIndent(tableStringsSorted, "", " ")
if err != nil {
return nil, fmt.Errorf("failed to convert table to json: %w", err)
}
Expand Down

0 comments on commit c64999c

Please sign in to comment.