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

feat(components/db): add common events db helper #327

Closed
wants to merge 1 commit into from
Closed

Conversation

gyuho
Copy link
Collaborator

@gyuho gyuho commented Jan 23, 2025

@gyuho gyuho force-pushed the common-db-pkg branch 4 times, most recently from 76d8ebb to 2ea61d0 Compare January 23, 2025 06:05
@leptonai leptonai deleted a comment from codecov bot Jan 23, 2025
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 92.85714% with 12 lines in your changes missing coverage. Please review.

Project coverage is 21.63%. Comparing base (8ddf848) to head (38fc0d4).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
components/db/events.go 92.85% 8 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #327      +/-   ##
==========================================
+ Coverage   21.19%   21.63%   +0.44%     
==========================================
  Files         298      299       +1     
  Lines       26748    26916     +168     
==========================================
+ Hits         5668     5823     +155     
- Misses      20413    20422       +9     
- Partials      667      671       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +26 to +30
// e.g., "xid", "sxid".
ColumnEventID1 = "event_id_1"

// e.g., "gpu_id", "gpu_uuid".
ColumnEventID2 = "event_id_2"
Copy link

Choose a reason for hiding this comment

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

as discussed offline, let's rename these

}

func (db *DB) Insert(ctx context.Context, ev Event) error {
return insertEvent(ctx, db.dbRW, db.table, ev)
Copy link

Choose a reason for hiding this comment

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

do we allow one of dbRW and dbRO to be nil in the NewDB function? if yes, we should check nil before calling insertEvent

Comment on lines +201 to +220
var event Event
var eventID1 sql.NullString
var eventID2 sql.NullString
if err := rows.Scan(
&event.Timestamp,
&event.DataSource,
&event.EventType,
&eventID1,
&eventID2,
&event.EventDetails,
); err != nil {
return nil, err
}
if eventID1.Valid {
event.EventID1 = eventID1.String
}
if eventID2.Valid {
event.EventID2 = eventID2.String
}
events = append(events, event)
Copy link

Choose a reason for hiding this comment

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

wrap this to a function to avoid duplicate code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in #332

@gyuho
Copy link
Collaborator Author

gyuho commented Jan 24, 2025

Closing in favor of #332.

@gyuho gyuho closed this Jan 24, 2025
@gyuho gyuho deleted the common-db-pkg branch January 24, 2025 06:04
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