fix: offset
This commit is contained in:
@@ -23,7 +23,6 @@ type DBChannel struct {
|
||||
UUID int64
|
||||
Username string
|
||||
Title string
|
||||
Offset int
|
||||
MinID int
|
||||
}
|
||||
|
||||
@@ -86,28 +85,18 @@ func (c *DBChannel) Get(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
c.MinID = int(m.MinID)
|
||||
c.Offset = int(m.Offset)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *DBChannel) Update(ctx context.Context, offsetID int) error {
|
||||
if c.Offset == 0 {
|
||||
c.Offset = offsetID
|
||||
}
|
||||
|
||||
if c.Offset > offsetID {
|
||||
c.Offset = offsetID
|
||||
}
|
||||
|
||||
if c.MinID < offsetID {
|
||||
c.MinID = offsetID
|
||||
func (c *DBChannel) Update(ctx context.Context, msgID int) error {
|
||||
if c.MinID < msgID {
|
||||
c.MinID = msgID
|
||||
}
|
||||
|
||||
tbl := table.Channels
|
||||
_, err := tbl.UPDATE().
|
||||
SET(
|
||||
tbl.Offset.SET(Int64(int64(c.Offset))),
|
||||
tbl.MinID.SET(Int64(int64(c.MinID))),
|
||||
).
|
||||
WHERE(tbl.UUID.EQ(Int64(c.UUID))).
|
||||
|
||||
Reference in New Issue
Block a user