Skip to content

Conversation

@melsawy
Copy link
Contributor

@melsawy melsawy commented Jan 23, 2026

Description

We are experiencing slow database queries because we queried the Claim table to find matching claims by quote; the quote was stored as a string, so I migrated it to a hash column and now search using the hash value.

References: CV2-6562

How to test?

Re-run automated tests.

Checklist

  • I have performed a self-review of my code and ensured that it is safe and runnable, that code coverage has not decreased, and that there are no new Code Climate issues. I have also followed Meedan's internal coding guidelines.

Copy link
Contributor

@caiosba caiosba left a comment

Choose a reason for hiding this comment

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

Thanks, Sawy! My only suggestion here is to abstract this logic as a class method of Claim, so you can avoid having this logic in two places:

def self.generate_hash(claim)
  Digest::MD5.hexdigest(claim.to_s.strip.downcase)
end

Copy link
Contributor

@vasconsaurus vasconsaurus left a comment

Choose a reason for hiding this comment

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

Looks good! Agree with @caiosba suggestion.

@melsawy melsawy merged commit 9e999be into develop Jan 25, 2026
10 checks passed
@melsawy melsawy deleted the CV2-6562-slow-db-query-hash-quote branch January 25, 2026 08:27
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.

4 participants