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

Update use Query instead of Scan #506

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dilip0515
Copy link
Contributor

@dilip0515 dilip0515 commented Nov 18, 2024

Proposed changes

  • Update use Query instead of Scan for Get Leases from Lease table

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (changes to code, which do not change application behavior)

Checklist

  • I have filled out this PR template
  • I have read the CONTRIBUTING doc
  • I have added automated tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (README.md, inline comments, etc.)
  • I have updated the CHANGELOG.md under a ## next release, with a short summary of my changes

Relevant Links

Further comments

@dilip0515 dilip0515 requested a review from bjfish25 November 18, 2024 20:01
pkg/db/db.go Outdated
}
}

output, err := db.Client.Scan(scanInput)
output, err := db.Client.Query(queryInput)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we only do the query if an index field is present, and a scan otherwise?

@@ -628,13 +628,16 @@ func (db *DB) GetLeases(input GetLeasesInput) (GetLeasesOutput, error) {
filters := make([]string, 0)
filterValues := make(map[string]*dynamodb.AttributeValue)

queryInput := &dynamodb.QueryInput{
TableName: aws.String(db.LeaseTableName),
ConsistentRead: aws.Bool(db.ConsistentRead),
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this work given that no index is given?

I think the easist way to accomplish this is

  1. Go back to largely how it was
  2. Make a variable called, queryable, and queryIndex (or something like that) and mark it false to start
  3. If one of the index filters are set, set the field (make sure not to overwrite, we probably want to prioritize principal_id)
  4. Make the query with filters if queryable, make the scan with filters otherwise
  5. Output the results to the same spot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants