From fee357b65291a5110a859fe775edcaf6a1d2bafd Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 12 Mar 2024 20:58:16 +0200 Subject: [PATCH] Count messages that failed to save --- historysync.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/historysync.go b/historysync.go index 5189bde..a7946b6 100644 --- a/historysync.go +++ b/historysync.go @@ -526,6 +526,7 @@ func (user *User) storeHistorySync(evt *waProto.HistorySync) { Msg("Storing history sync") successfullySavedTotal := 0 + failedToSaveTotal := 0 totalMessageCount := 0 for _, conv := range evt.GetConversations() { jid, err := types.ParseJID(conv.GetId()) @@ -578,6 +579,7 @@ func (user *User) storeHistorySync(evt *waProto.HistorySync) { var minTimeIndex, maxTimeIndex int successfullySaved := 0 + failedToSave := 0 unsupportedTypes := 0 for i, rawMsg := range conv.GetMessages() { // Don't store messages that will just be skipped. @@ -614,6 +616,7 @@ func (user *User) storeHistorySync(evt *waProto.HistorySync) { Str("msg_id", msgEvt.Info.ID). Time("msg_time", msgEvt.Info.Timestamp). Msg("Failed to save historical message") + failedToSave++ continue } err = message.Insert(ctx) @@ -623,12 +626,16 @@ func (user *User) storeHistorySync(evt *waProto.HistorySync) { Str("msg_id", msgEvt.Info.ID). Time("msg_time", msgEvt.Info.Timestamp). Msg("Failed to save historical message") + failedToSave++ + } else { + successfullySaved++ } - successfullySaved++ } successfullySavedTotal += successfullySaved + failedToSaveTotal += failedToSave log.Debug(). Int("saved_count", successfullySaved). + Int("failed_count", failedToSave). Int("unsupported_msg_type_count", unsupportedTypes). Time("lowest_time", minTime). Int("lowest_time_index", minTimeIndex). @@ -646,6 +653,7 @@ func (user *User) storeHistorySync(evt *waProto.HistorySync) { } log.Info(). Int("total_saved_count", successfullySavedTotal). + Int("total_failed_count", failedToSaveTotal). Int("total_message_count", totalMessageCount). Msg("Finished storing history sync")