Use new simplified uuid.NewString() syntax

This commit is contained in:
Deluan
2021-02-01 01:22:31 -05:00
parent b47ec02f02
commit 861b406575
10 changed files with 17 additions and 32 deletions
+1 -2
View File
@@ -92,8 +92,7 @@ var _ = Describe("MediaRepository", func() {
})
It("delete tracks by id", func() {
random, _ := uuid.NewRandom()
id := random.String()
id := uuid.NewString()
Expect(mr.Put(&model.MediaFile{ID: id})).To(BeNil())
Expect(mr.Delete(id)).To(BeNil())
+1 -2
View File
@@ -78,9 +78,8 @@ func AssertPlayQueue(expected, actual *model.PlayQueue) {
func aPlayQueue(userId, current string, position int64, items ...model.MediaFile) *model.PlayQueue {
createdAt := time.Now()
updatedAt := createdAt.Add(time.Minute)
id, _ := uuid.NewRandom()
return &model.PlayQueue{
ID: id.String(),
ID: uuid.NewString(),
UserID: userId,
Current: current,
Position: position,
+2 -4
View File
@@ -37,8 +37,7 @@ func (r sqlRepository) annUpsert(values map[string]interface{}, itemIDs ...strin
c, err := r.executeSQL(upd)
if c == 0 || err == orm.ErrNoRows {
for _, itemID := range itemIDs {
id, _ := uuid.NewRandom()
values["ann_id"] = id.String()
values["ann_id"] = uuid.NewString()
values["user_id"] = userId(r.ctx)
values["item_type"] = r.tableName
values["item_id"] = itemID
@@ -68,9 +67,8 @@ func (r sqlRepository) IncPlayCount(itemID string, ts time.Time) error {
c, err := r.executeSQL(upd)
if c == 0 || err == orm.ErrNoRows {
id, _ := uuid.NewRandom()
values := map[string]interface{}{}
values["ann_id"] = id.String()
values["ann_id"] = uuid.NewString()
values["user_id"] = userId(r.ctx)
values["item_type"] = r.tableName
values["item_id"] = itemID
+1 -2
View File
@@ -186,8 +186,7 @@ func (r sqlRepository) put(id string, m interface{}) (newId string, err error) {
}
// If does not have an id OR could not update (new record with predefined id)
if id == "" {
rand, _ := uuid.NewRandom()
id = rand.String()
id = uuid.NewString()
values["id"] = id
}
// It is a insert. if there was a created_at, add it back to args
+1 -2
View File
@@ -44,8 +44,7 @@ func (r *userRepository) GetAll(options ...model.QueryOptions) (model.Users, err
func (r *userRepository) Put(u *model.User) error {
if u.ID == "" {
id, _ := uuid.NewRandom()
u.ID = id.String()
u.ID = uuid.NewString()
}
u.UpdatedAt = time.Now()
values, _ := toSqlArgs(*u)