Skip to content

Commit

Permalink
Remove unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Apr 14, 2022
1 parent 09d368a commit fe7ee45
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
9 changes: 0 additions & 9 deletions core/models/contacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,15 +1353,6 @@ func GetContactLocker(orgID OrgID, contactID ContactID) *redisx.Locker {
return redisx.NewLocker(key, time.Minute*5)
}

// UpdateContactModifiedBy updates modified by the passed user id on the passed in contacts
func UpdateContactModifiedBy(ctx context.Context, db Queryer, contactIDs []ContactID, userID UserID) error {
if userID == NilUserID || len(contactIDs) == 0 {
return nil
}
_, err := db.ExecContext(ctx, `UPDATE contacts_contact SET modified_on = NOW(), modified_by_id = $2 WHERE id = ANY($1)`, pq.Array(contactIDs), userID)
return err
}

// ContactStatusChange struct used for our contact status change
type ContactStatusChange struct {
ContactID ContactID
Expand Down
21 changes: 0 additions & 21 deletions core/models/contacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,27 +509,6 @@ func TestUpdateContactLastSeenAndModifiedOn(t *testing.T) {
assert.True(t, cathy.ModifiedOn().After(t2))
}

func TestUpdateContactModifiedBy(t *testing.T) {
ctx, _, db, _ := testsuite.Get()

defer testsuite.Reset(testsuite.ResetAll)

err := models.UpdateContactModifiedBy(ctx, db, []models.ContactID{}, models.UserID(0))
assert.NoError(t, err)

assertdb.Query(t, db, `SELECT count(*) FROM contacts_contact WHERE id = $1 AND modified_by_id = NULL`, testdata.Cathy.ID).Returns(0)

err = models.UpdateContactModifiedBy(ctx, db, []models.ContactID{testdata.Cathy.ID}, models.UserID(0))
assert.NoError(t, err)

assertdb.Query(t, db, `SELECT count(*) FROM contacts_contact WHERE id = $1 AND modified_by_id = NULL`, testdata.Cathy.ID).Returns(0)

err = models.UpdateContactModifiedBy(ctx, db, []models.ContactID{testdata.Cathy.ID}, models.UserID(1))
assert.NoError(t, err)

assertdb.Query(t, db, `SELECT count(*) FROM contacts_contact WHERE id = $1 AND modified_by_id = 1`, testdata.Cathy.ID).Returns(1)
}

func TestUpdateContactStatus(t *testing.T) {
ctx, _, db, _ := testsuite.Get()

Expand Down

0 comments on commit fe7ee45

Please sign in to comment.