summaryrefslogtreecommitdiff
path: root/parse.go
diff options
context:
space:
mode:
authorDmitry Ilvokhin <d@ilvokhin.com>2025-03-18 22:08:34 +0000
committerDmitry Ilvokhin <d@ilvokhin.com>2025-03-18 22:08:34 +0000
commit3a5909f9779ff2978a7e12ff23bf934aa55c1dc6 (patch)
tree68c9a3558939d8f849ef2eacbc777a6075b2aaeb /parse.go
parentbbf5d9d99aa6131dccada8908b770ac10f52be59 (diff)
downloadflatbot-3a5909f9779ff2978a7e12ff23bf934aa55c1dc6.tar.gz
flatbot-3a5909f9779ff2978a7e12ff23bf934aa55c1dc6.tar.bz2
flatbot-3a5909f9779ff2978a7e12ff23bf934aa55c1dc6.zip
Sort and unique fetched flats
There are cases (premium listings is one example), when there are duplicates in the fetched flats, unique them to avoid multiple notifications for the same property.
Diffstat (limited to 'parse.go')
-rw-r--r--parse.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/parse.go b/parse.go
index 6be416e..a5ee3ce 100644
--- a/parse.go
+++ b/parse.go
@@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
+ "slices"
"strconv"
"strings"
@@ -23,6 +24,10 @@ func parse(body []byte) ([]flat, error) {
}
flats = append(flats, flat)
}
+ slices.SortFunc(flats, compareID)
+ flats = slices.CompactFunc(flats, func(a, b flat) bool {
+ return compareID(a, b) == 0
+ })
return flats, nil
}