Skip to content

Commit

Permalink
db/message: fix GetEarliestTimestampInChat
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <sumner@beeper.com>
  • Loading branch information
sumnerevans committed Aug 6, 2023
1 parent 209c48c commit 072ad45
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions database/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,14 @@ func (mq *MessageQuery) GetFirstInChat(chat string) *Message {

func (mq *MessageQuery) GetEarliestTimestampInChat(chat string) (int64, error) {
row := mq.db.QueryRow("SELECT MIN(timestamp) FROM message WHERE portal_guid=$1", chat)
var timestamp int64
var timestamp sql.NullInt64
if err := row.Scan(&timestamp); err != nil {
return -1, err
} else if !timestamp.Valid {
return -1, nil
} else {
return timestamp.Int64, nil
}
return timestamp, nil
}

func (mq *MessageQuery) MergePortalGUID(txn dbutil.Execable, to string, from ...string) int64 {
Expand Down

0 comments on commit 072ad45

Please sign in to comment.