Spaces:
Running
Running
Delete wall_cleanup.py with huggingface_hub
Browse files- wall_cleanup.py +0 -42
wall_cleanup.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Wall posts - Filter to only 24h posts
|
| 3 |
-
Called before returning /api/wall
|
| 4 |
-
"""
|
| 5 |
-
import os, json, time
|
| 6 |
-
|
| 7 |
-
MAX_AGE = 86400 # 24h in seconds
|
| 8 |
-
|
| 9 |
-
def filter_wall_24h(posts):
|
| 10 |
-
"""Filter wall posts to only those within 24h"""
|
| 11 |
-
if not posts:
|
| 12 |
-
return []
|
| 13 |
-
now = time.time()
|
| 14 |
-
return [p for p in posts if (now - (p.get('created', 0) or 0)) <= MAX_AGE]
|
| 15 |
-
|
| 16 |
-
# Monkey-patch the /api/wall endpoint
|
| 17 |
-
import app_v2_entry as entry_mod
|
| 18 |
-
|
| 19 |
-
_original_api_wall = None
|
| 20 |
-
|
| 21 |
-
def apply_24h_filter():
|
| 22 |
-
global _original_api_wall
|
| 23 |
-
|
| 24 |
-
# Find existing /api/wall endpoint
|
| 25 |
-
for route in entry_mod.app.routes:
|
| 26 |
-
if hasattr(route, 'path') and route.path == '/api/wall':
|
| 27 |
-
_original_api_wall = route.endpoint
|
| 28 |
-
break
|
| 29 |
-
|
| 30 |
-
# Create filtered version
|
| 31 |
-
@entry_mod.app.get('/api/wall')
|
| 32 |
-
def api_wall_24h():
|
| 33 |
-
if _original_api_wall:
|
| 34 |
-
result = _original_api_wall()
|
| 35 |
-
# Get posts from result
|
| 36 |
-
posts = result.body if hasattr(result, 'body') and isinstance(result.body, dict) else {}
|
| 37 |
-
if 'posts' in posts:
|
| 38 |
-
posts['posts'] = filter_wall_24h(posts['posts'])
|
| 39 |
-
return result
|
| 40 |
-
return entry_mod.JSONResponse({"posts": []})
|
| 41 |
-
|
| 42 |
-
print("[Wall] 24h filter applied to /api/wall endpoint")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|