-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathgenerate_featured.py
More file actions
44 lines (32 loc) · 1.06 KB
/
generate_featured.py
File metadata and controls
44 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
"""Standalone script to regenerate featured user from existing users.json."""
import json
import os
import sys
# Import from fetch module
sys.path.insert(0, os.path.dirname(__file__))
from fetch import (
calculate_engagement_score,
safe_path,
save_featured_user,
select_featured_user,
)
SITE_DIR = "./docs"
def main():
"""Load users and regenerate featured user."""
users_path = safe_path(os.path.join(SITE_DIR, "users.json"))
if not os.path.exists(users_path):
print("Error: users.json not found. Run fetch.py first.")
sys.exit(1)
with open(users_path, encoding="utf-8") as f:
users = json.load(f)
print(f"Loaded {len(users)} users from cache")
featured_user = select_featured_user(users)
if featured_user:
save_featured_user(featured_user)
score = calculate_engagement_score(featured_user)
print(f"✅ Featured user: {featured_user['login']} (score: {score:.2f})")
else:
print("❌ No featured user selected")
if __name__ == "__main__":
main()