Skip to content

Commit a8dbb8d

Browse files
committed
update-sites/stats: present examples more cleanly
1 parent ce42936 commit a8dbb8d

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

_pages/update-sites/stats.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -641,26 +641,25 @@ for year in sorted(yearly_stats.keys()):
641641
# Find the most popular year
642642
best_year = max(yearly_stats.keys(), key=lambda y: yearly_stats[y])
643643
print(f"\nBest year: {best_year} with {yearly_stats[best_year]:,} unique IPs")
644+
```
644645

645-
# Example: List all sites sorted by total unique IPs
646-
def get_sites_ranking():
647-
"""Get all sites ranked by total unique IPs."""
648-
import json
649-
650-
with urllib.request.urlopen('https://sites.imagej.net/sites.json') as response:
651-
sites_data = json.load(response)
646+
And another example to list all sites sorted by total unique IPs:
647+
```python
648+
import json
649+
import urllib.request
652650
653-
# Sort sites by total unique IPs
654-
ranked_sites = sorted(
655-
sites_data.items(),
656-
key=lambda x: x[1]['total_unique_ips'],
657-
reverse=True
658-
)
651+
with urllib.request.urlopen('https://sites.imagej.net/sites.json') as response:
652+
sites_data = json.load(response)
659653
660-
print("Sites ranked by total unique IPs:")
661-
for site_name, metadata in ranked_sites:
662-
print(f" {site_name}: {metadata['total_unique_ips']:,} unique IPs "
663-
f"({metadata['days_with_data']} days of data)")
654+
# Sort sites by total unique IPs
655+
ranked_sites = sorted(
656+
sites_data.items(),
657+
key=lambda x: x[1]['total_unique_ips'],
658+
reverse=True
659+
)
664660
665-
get_sites_ranking()
661+
print("Sites ranked by total unique IPs:")
662+
for site_name, metadata in ranked_sites:
663+
print(f" {site_name}: {metadata['total_unique_ips']:,} unique IPs "
664+
f"({metadata['days_with_data']} days of data)")
666665
```

0 commit comments

Comments
 (0)