A social RSS reader built on the AT Protocol. glean.at
glean atproto atmosphere rss feed social app
14
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix division by zero in Jaccard similarity calculation

+13 -11
+13 -11
internal/cluster/jaccard.go
··· 73 73 74 74 _, err = tx.ExecContext(ctx, ` 75 75 INSERT INTO _feed_sim_staging (feed_a, feed_b, jaccard) 76 - SELECT 77 - s1.feed_url, 78 - s2.feed_url, 79 - SUM(EXP(-0.023 * CAST(julianday('now') - julianday(MIN(s1.added_at, s2.added_at)) AS REAL))) 80 - / (f1.subscriber_count + f2.subscriber_count - CAST(COUNT(*) AS REAL)) 81 - FROM articles.subscriptions s1 82 - JOIN articles.subscriptions s2 ON s1.user_did = s2.user_did AND s1.feed_url < s2.feed_url 83 - JOIN articles.feeds f1 ON f1.feed_url = s1.feed_url 84 - JOIN articles.feeds f2 ON f2.feed_url = s2.feed_url 85 - WHERE s1.added_at IS NOT NULL AND s2.added_at IS NOT NULL 86 - GROUP BY s1.feed_url, s2.feed_url 76 + SELECT feed_a, feed_b, jaccard FROM ( 77 + SELECT 78 + s1.feed_url AS feed_a, 79 + s2.feed_url AS feed_b, 80 + SUM(EXP(-0.023 * CAST(julianday('now') - julianday(MIN(s1.added_at, s2.added_at)) AS REAL))) 81 + / NULLIF(f1.subscriber_count + f2.subscriber_count - CAST(COUNT(*) AS REAL), 0) AS jaccard 82 + FROM articles.subscriptions s1 83 + JOIN articles.subscriptions s2 ON s1.user_did = s2.user_did AND s1.feed_url < s2.feed_url 84 + JOIN articles.feeds f1 ON f1.feed_url = s1.feed_url 85 + JOIN articles.feeds f2 ON f2.feed_url = s2.feed_url 86 + WHERE s1.added_at IS NOT NULL AND s2.added_at IS NOT NULL 87 + GROUP BY s1.feed_url, s2.feed_url 88 + ) WHERE jaccard IS NOT NULL 87 89 `) 88 90 if err != nil { 89 91 return err