Skip to content

Commit 50ffe53

Browse files
author
Vladimir Smirnov
committed
Fix yet another issue with multiple filters per repo
1 parent 0dfaea3 commit 50ffe53

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

feeds/process.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ func ForceProcessFeed(name string) {
3131
}
3232

3333
func UpdateFeeds(feeds []*Feed) {
34-
logger := zapwriter.Logger("updateFeeds")
34+
loggerRef := zapwriter.Logger("updateFeeds")
3535
configs.Config.Lock()
3636
defer configs.Config.Unlock()
3737

3838
for _, feed := range feeds {
39-
logger = logger.With(
39+
logger := loggerRef.With(
4040
zap.Int("id", feed.Id),
4141
zap.String("repo", feed.Repo),
4242
)
4343

44-
logger.Debug("will initialize feeds",
44+
logger.Debug("will initialize feed",
4545
zap.Any("feed", feed),
4646
)
4747
var cfg *configs.FeedsConfig
@@ -63,6 +63,7 @@ func UpdateFeeds(feeds []*Feed) {
6363

6464
// We were unable to find relevant configuration for this particular feed, we need to create it
6565
if cfg == nil {
66+
logger.Debug("creating first configuration for the repo")
6667
feed.cfg = configs.FeedsConfig{
6768
Repo: feed.Repo,
6869
PollingInterval: configs.Config.PollingInterval,
@@ -79,15 +80,18 @@ func UpdateFeeds(feeds []*Feed) {
7980
}
8081

8182
// Configuration was found, but this filter is new, we need to append it to existing repo
83+
logger.Debug("adding new configuration for existing repo")
8284
cfg.Filters = append(cfg.Filters, configs.FiltersConfig{
8385
Name: feed.Name,
8486
Filter: feed.Filter,
8587
MessagePattern: feed.MessagePattern,
8688
FilterRegex: re,
8789
})
90+
91+
feed.cfg.Filters = cfg.Filters
8892
}
8993

90-
logger.Debug("feeds initialized",
94+
loggerRef.Debug("feeds initialized",
9195
zap.Any("feeds", feeds),
9296
)
9397

@@ -247,7 +251,9 @@ func (f *Feed) ForceProcess() {
247251
cfg := f.cfg
248252

249253
if len(cfg.Filters) == 0 {
250-
f.logger.Warn("no filters to process, exiting")
254+
f.logger.Warn("no filters to process, exiting",
255+
zap.Any("cfg", cfg),
256+
)
251257
return
252258
}
253259

@@ -305,7 +311,9 @@ func (f *Feed) ProcessFeed() {
305311
cfg := f.cfg
306312

307313
if len(cfg.Filters) == 0 {
308-
f.logger.Warn("no filters to process, exiting")
314+
f.logger.Warn("no filters to process, exiting",
315+
zap.Any("cfg", cfg),
316+
)
309317
return
310318
}
311319

0 commit comments

Comments
 (0)