From bdee1b4092106e02ef8bdf2d541134bfb7560c06 Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Wed, 26 Jan 2022 07:43:09 +0100 Subject: [PATCH] fix math to avoid negative balances --- manager/setup.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manager/setup.go b/manager/setup.go index 8f5c20c..ebc4026 100644 --- a/manager/setup.go +++ b/manager/setup.go @@ -103,6 +103,9 @@ func (s *Sync) walletSetup() error { videosOnYoutube = s.Manager.CliFlags.VideosToSync(s.DbChannelData.TotalSubscribers) } unallocatedVideos := videosOnYoutube - (publishedCount + failedCount) + if unallocatedVideos < 0 { + unallocatedVideos = 0 + } channelFee := channelClaimAmount channelAlreadyClaimed := s.DbChannelData.ChannelClaimID != "" if channelAlreadyClaimed { @@ -131,7 +134,7 @@ func (s *Sync) walletSetup() error { extraLBC := balance - requiredBalance if extraLBC > 5 { sendBackAmount := extraLBC - 1 - logUtils.SendInfoToSlack("channel %s has %.1f credits which is %.1f more than it should. We should send at least %.1f that back.", s.DbChannelData.ChannelId, balance, extraLBC, sendBackAmount) + logUtils.SendInfoToSlack("channel %s has %.1f credits which is %.1f more than it requires (%.1f). We should send at least %.1f that back.", s.DbChannelData.ChannelId, balance, extraLBC, requiredBalance, sendBackAmount) } }