forked from MirrorHub/mautrix-whatsapp
backfill logging: fix logging of Backfill structs
This commit is contained in:
parent
a3d56704a7
commit
e74bb62fc1
2 changed files with 20 additions and 1 deletions
|
@ -19,6 +19,7 @@ package database
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
log "maunium.net/go/maulogger/v2"
|
log "maunium.net/go/maulogger/v2"
|
||||||
|
@ -33,6 +34,18 @@ const (
|
||||||
BackfillMedia = 2
|
BackfillMedia = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (bt BackfillType) String() string {
|
||||||
|
switch bt {
|
||||||
|
case BackfillImmediate:
|
||||||
|
return "IMMEDIATE"
|
||||||
|
case BackfillDeferred:
|
||||||
|
return "DEFERRED"
|
||||||
|
case BackfillMedia:
|
||||||
|
return "MEDIA"
|
||||||
|
}
|
||||||
|
return "UNKNOWN"
|
||||||
|
}
|
||||||
|
|
||||||
type BackfillQuery struct {
|
type BackfillQuery struct {
|
||||||
db *Database
|
db *Database
|
||||||
log log.Logger
|
log log.Logger
|
||||||
|
@ -111,6 +124,12 @@ type Backfill struct {
|
||||||
CompletedAt *time.Time
|
CompletedAt *time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Backfill) String() string {
|
||||||
|
return fmt.Sprintf("Backfill{QueueID: %d, UserID: %s, BackfillType: %s, Priority: %d, Portal: %s, TimeStart: %s, TimeEnd: %s, MaxBatchEvents: %d, MaxTotalEvents: %d, BatchDelay: %d, CompletedAt: %s}",
|
||||||
|
b.QueueID, b.UserID, b.BackfillType, b.Priority, b.Portal, b.TimeStart, b.TimeEnd, b.MaxBatchEvents, b.MaxTotalEvents, b.BatchDelay, b.CompletedAt,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Backfill) Scan(row Scannable) *Backfill {
|
func (b *Backfill) Scan(row Scannable) *Backfill {
|
||||||
err := row.Scan(&b.QueueID, &b.UserID, &b.BackfillType, &b.Priority, &b.Portal.JID, &b.Portal.Receiver, &b.TimeStart, &b.TimeEnd, &b.MaxBatchEvents, &b.MaxTotalEvents, &b.BatchDelay)
|
err := row.Scan(&b.QueueID, &b.UserID, &b.BackfillType, &b.Priority, &b.Portal.JID, &b.Portal.Receiver, &b.TimeStart, &b.TimeEnd, &b.MaxBatchEvents, &b.MaxTotalEvents, &b.BatchDelay)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -78,7 +78,7 @@ func (user *User) handleHistorySyncsLoop() {
|
||||||
|
|
||||||
func (user *User) handleBackfillRequestsLoop(backfillRequests chan *database.Backfill) {
|
func (user *User) handleBackfillRequestsLoop(backfillRequests chan *database.Backfill) {
|
||||||
for req := range backfillRequests {
|
for req := range backfillRequests {
|
||||||
user.log.Debugfln("Handling backfill request %#v", req)
|
user.log.Debugfln("Handling backfill request %s", req)
|
||||||
conv := user.bridge.DB.HistorySyncQuery.GetConversation(user.MXID, req.Portal)
|
conv := user.bridge.DB.HistorySyncQuery.GetConversation(user.MXID, req.Portal)
|
||||||
if conv == nil {
|
if conv == nil {
|
||||||
user.log.Debugfln("Could not find history sync conversation data for %s", req.Portal.String())
|
user.log.Debugfln("Could not find history sync conversation data for %s", req.Portal.String())
|
||||||
|
|
Loading…
Add table
Reference in a new issue