Work in progress atmosphere stats viewer
1

Configure Feed

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

feat: try and group spam when in collapsed mode on distribution graph

+30 -7
+30 -7
src/routes/plc/PdsDistribution.svelte
··· 5 5 const stats = getStats(); 6 6 let collapse = $state(true); 7 7 8 + // Hosts without a real pds on them 9 + // todo check this at runtime 10 + // todo hide spam entries by default when collapsed 11 + const SPAM_HOSTS = [ 12 + 'pds.trump.com', 13 + 'example.test', 14 + 'bssky.social', 15 + 'example.com', 16 + 'social.kabcash.com', 17 + ]; 18 + 19 + function isSpam(url: URL | null): url is null { 20 + return ( 21 + !url || 22 + url.protocol !== 'https:' || 23 + !url.host.includes('.') || 24 + SPAM_HOSTS.includes(url.hostname) 25 + ); 26 + } 27 + 8 28 function format(raw: Record<string, number>, collapse: boolean) { 9 29 const distribution = new Map<string, number>(); 10 30 ··· 12 32 const url = URL.parse(pds); 13 33 const key = url?.hostname.endsWith('bsky.network') 14 34 ? 'Bluesky PBC' 15 - : url && url.protocol === 'https:' && count > 300 && !collapse 16 - ? url.hostname 17 - : 'Other'; 35 + : isSpam(url) 36 + ? 'Spam' 37 + : !collapse && count > 300 38 + ? url.hostname 39 + : 'Other'; 18 40 19 41 const total = distribution.getOrInsert(key, 0); 20 42 distribution.set(key, total + count); ··· 29 51 if (b.key === 'Bluesky PBC') return 1; 30 52 if (a.key === 'Other') return 1; 31 53 if (b.key === 'Other') return -1; 54 + if (a.key === 'Spam') return 1; 55 + if (b.key === 'Spam') return -1; 32 56 return b.value - a.value; 33 57 }); 34 58 } ··· 39 63 <h4>PDS Distribution <small>(approx)</small></h4> 40 64 41 65 <label> 42 - Collapse non-Bluesky 66 + Collapse 43 67 <input type="checkbox" role="switch" bind:checked={collapse} /> 44 68 </label> 45 69 </div> ··· 51 75 data={format(stats.current.pdsDistribution, collapse)} 52 76 cRange={[ 53 77 'var(--primary)', 78 + 'var(--red)', 54 79 '#ac21ed', 55 - 'var(--green)', 56 - 'var(--orange)', 57 - 'var(--secondary)', 80 + ...(collapse ? [] : ['var(--green)', 'var(--orange)']), 58 81 ]} 59 82 key="key" 60 83 value="value"