-
Notifications
You must be signed in to change notification settings - Fork 20
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
Conversation
76d8ebb
to
2ea61d0
Compare
Signed-off-by: Gyuho Lee <[email protected]>
Codecov ReportAttention: Patch coverage is
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. |
// e.g., "xid", "sxid". | ||
ColumnEventID1 = "event_id_1" | ||
|
||
// e.g., "gpu_id", "gpu_uuid". | ||
ColumnEventID2 = "event_id_2" |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in #332
Closing in favor of #332. |
c.f., #324 (comment)