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

change column name type to record_type #10

Merged
merged 1 commit into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cassandra/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ package cassandra

import (
"errors"
"time"

"github.com/InVisionApp/go-health"
"github.com/go-kit/kit/metrics/provider"
"github.com/goph/emperror"
db "github.com/xmidt-org/codex-db"
"github.com/xmidt-org/codex-db/blacklist"
"github.com/yugabyte/gocql"
"time"
)

var (
Expand Down Expand Up @@ -157,7 +158,7 @@ func (c *Connection) GetRecords(deviceID string, limit int) ([]db.Record, error)

// GetRecords returns a list of records for a given device and event type.
func (c *Connection) GetRecordsOfType(deviceID string, limit int, eventType db.EventType) ([]db.Record, error) {
deviceInfo, err := c.finder.findRecords(limit, "WHERE device_id = ? AND type = ?", deviceID, eventType)
deviceInfo, err := c.finder.findRecords(limit, "WHERE device_id = ? AND record_type = ?", deviceID, eventType)
if err != nil {
c.measures.SQLQueryFailureCount.With(db.TypeLabel, db.ReadType).Add(1.0)
return []db.Record{}, emperror.WrapWith(err, "Getting records from database failed", "device id", deviceID)
Expand Down
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
// metadata to be used for the record. If the data is encrypted, the Nonce,
// Alg, and KID values will be needed to determine how to correctly decrypt it.
type Record struct {
Type EventType `json:"type" bson:"type" gorm:"type:int"`
Type EventType `json:"recordtype" bson:"recordtype" gorm:"recordtype:int"`
DeviceID string `json:"deviceid" bson:"deviceid"`
BirthDate int64 `json:"birthdate" bson:"birthdate"`
DeathDate int64 `json:"deathdate" bson:"deathdate"`
Expand Down
4 changes: 2 additions & 2 deletions postgresql/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"strconv"
"time"

"github.com/xmidt-org/codex-db"
db "github.com/xmidt-org/codex-db"
"github.com/xmidt-org/codex-db/blacklist"

"github.com/go-kit/kit/metrics/provider"
Expand Down Expand Up @@ -268,7 +268,7 @@ func (c *Connection) GetRecordsOfType(deviceID string, limit int, eventType db.E
var (
deviceInfo []db.Record
)
err := c.finder.findRecords(&deviceInfo, limit, "device_id = ? AND type = ?", deviceID, eventType)
err := c.finder.findRecords(&deviceInfo, limit, "device_id = ? AND record_type = ?", deviceID, eventType)
if err != nil {
c.measures.SQLQueryFailureCount.With(db.TypeLabel, db.ReadType).Add(1.0)
return []db.Record{}, emperror.WrapWith(err, "Getting records from database failed", "device id", deviceID)
Expand Down