filter removes duplicates

This commit is contained in:
Balakrishnan Balasubramanian 2022-05-27 23:05:59 -04:00
parent 30340200d3
commit 17001a1537
2 changed files with 2 additions and 1 deletions

View File

@ -110,11 +110,11 @@ func ParseConfig(configPath string) (*Config, error) {
} }
func (fu *FeedURL) UnmarshalYAML(node *yaml.Node) error { func (fu *FeedURL) UnmarshalYAML(node *yaml.Node) error {
*fu = []string{""}
switch node.Kind { switch node.Kind {
case yaml.SequenceNode: case yaml.SequenceNode:
return node.Decode((*[]string)(fu)) return node.Decode((*[]string)(fu))
case yaml.ScalarNode: case yaml.ScalarNode:
*fu = []string{""}
return node.Decode(&(*fu)[0]) return node.Decode(&(*fu)[0])
} }
return fmt.Errorf("unexpected node type: %s, at %d:%d", node.ShortTag(), node.Line, node.Column) return fmt.Errorf("unexpected node type: %s, at %d:%d", node.ShortTag(), node.Line, node.Column)

View File

@ -78,6 +78,7 @@ func (d *db) Filter(entries []parser.FeedEntry) ([]parser.FeedEntry, error) {
for _, entry := range entries { for _, entry := range entries {
if _, ok := d.seenLinks[entry.Link]; !ok { if _, ok := d.seenLinks[entry.Link]; !ok {
filteredEntries = append(filteredEntries, entry) filteredEntries = append(filteredEntries, entry)
d.seenLinks[entry.Link] = struct{}{}
} }
} }
return filteredEntries, nil return filteredEntries, nil