Skip to content

Conversation

@AmanGIT07
Copy link
Contributor

@AmanGIT07 AmanGIT07 commented Oct 23, 2025

Added organization name (org_name) to audit records. Refactored billing transaction audit logging to avoid serialization conflicts in high-concurrency scenarios.

Why:

  • org_name field: Eliminates need to JOIN with organizations table for display/filtering, improving query performance and user experience
  • Refactoring: SERIALIZABLE transactions were hitting serialization conflicts when fetching org_name from organizations table under high concurrency. Moving audit creation to service layer (outside transaction) solves this.

@vercel
Copy link

vercel bot commented Oct 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
frontier Ready Ready Preview Comment Oct 23, 2025 0:21am

@AmanGIT07 AmanGIT07 changed the title feat: Add org_name field to audit records feat: add org_name to audit records Oct 23, 2025
@AmanGIT07 AmanGIT07 enabled auto-merge (squash) October 23, 2025 08:57
@AmanGIT07 AmanGIT07 requested a review from rohilsurana October 23, 2025 08:58
@coveralls
Copy link

coveralls commented Oct 23, 2025

Pull Request Test Coverage Report for Build 18748106950

Details

  • 39 of 80 (48.75%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.06%) to 37.074%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/store/postgres/audit_record_repository.go 11 13 84.62%
cmd/serve.go 0 7 0.0%
billing/credit/service.go 18 50 36.0%
Totals Coverage Status
Change from base Build 18739972992: 0.06%
Covered Lines: 14791
Relevant Lines: 39896

💛 - Coveralls

@AmanGIT07 AmanGIT07 removed the request for review from rohilsurana October 23, 2025 09:56
@AmanGIT07 AmanGIT07 marked this pull request as draft October 23, 2025 09:56
auto-merge was automatically disabled October 23, 2025 09:56

Pull request was converted to draft

@AmanGIT07 AmanGIT07 marked this pull request as ready for review October 23, 2025 12:21
@AmanGIT07 AmanGIT07 enabled auto-merge (squash) October 23, 2025 12:24
@AmanGIT07 AmanGIT07 requested a review from rohilsurana October 23, 2025 12:39
if auditRecord.OrgID != "" {
query, params, err := buildOrgNameQuery(auditRecord.OrgID)
if err == nil {
_ = r.dbc.QueryRowxContext(ctx, query, params...).Scan(&dbRecord.OrganizationName)
Copy link
Member

Choose a reason for hiding this comment

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

in case of any error, we would loose have empty org name, are we ok with that?

var orgName string
query, params, err := buildOrgNameQuery(record.OrganizationID)
if err == nil {
_ = tx.QueryRowContext(ctx, query, params...).Scan(&orgName)
Copy link
Member

Choose a reason for hiding this comment

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

in case of any error, we would loose have empty org name, are we ok with that?

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.

3 participants