additional debugging added to api_post()
This commit is contained in:
54
app.py
54
app.py
@@ -387,46 +387,32 @@ def get_display_name_for_source(platform, source, platform_config):
|
|||||||
def api_posts():
|
def api_posts():
|
||||||
"""API endpoint to get posts data with pagination and filtering"""
|
"""API endpoint to get posts data with pagination and filtering"""
|
||||||
try:
|
try:
|
||||||
# Load platform configuration
|
# ... (code to get user_settings) ...
|
||||||
platform_config = load_platform_config()
|
|
||||||
|
|
||||||
# Get query parameters
|
|
||||||
page = int(request.args.get('page', 1))
|
|
||||||
per_page = int(request.args.get('per_page', DEFAULT_PAGE_SIZE))
|
|
||||||
community = request.args.get('community', '')
|
|
||||||
platform = request.args.get('platform', '')
|
|
||||||
search_query = request.args.get('q', '').lower().strip()
|
|
||||||
filter_override = request.args.get('filter', '')
|
|
||||||
|
|
||||||
# Get user's filterset preference, community selections, and time filter
|
|
||||||
filterset_name = 'no_filter'
|
|
||||||
user_communities = []
|
|
||||||
time_filter_enabled = False
|
|
||||||
time_filter_days = 7
|
|
||||||
if current_user.is_authenticated:
|
|
||||||
try:
|
|
||||||
user_settings = json.loads(current_user.settings) if current_user.settings else {}
|
|
||||||
filterset_name = user_settings.get('filter_set', 'no_filter')
|
|
||||||
user_communities = user_settings.get('communities', [])
|
|
||||||
|
|
||||||
experience_settings = user_settings.get('experience', {})
|
|
||||||
time_filter_enabled = experience_settings.get('time_filter_enabled', False)
|
|
||||||
time_filter_days = experience_settings.get('time_filter_days', 7)
|
|
||||||
except:
|
|
||||||
filterset_name = 'no_filter'
|
|
||||||
user_communities = []
|
|
||||||
time_filter_enabled = False
|
|
||||||
time_filter_days = 7
|
|
||||||
|
|
||||||
# Override filterset if specified in request (for sidebar filter switching)
|
|
||||||
if filter_override and _is_safe_filterset(filter_override):
|
|
||||||
filterset_name = filter_override
|
|
||||||
|
|
||||||
# Use cached data for better performance
|
# Use cached data for better performance
|
||||||
cached_posts, cached_comments = _load_posts_cache()
|
cached_posts, cached_comments = _load_posts_cache()
|
||||||
|
|
||||||
|
# ====================================================================
|
||||||
|
# ADD THIS NEW DEBUG BLOCK
|
||||||
|
# ====================================================================
|
||||||
|
logger.info(f"--- API POSTS DEBUG V2 ---")
|
||||||
|
logger.info(f"User communities: {user_communities}")
|
||||||
|
|
||||||
|
# Get the first available post to inspect its data
|
||||||
|
if cached_posts:
|
||||||
|
first_post_uuid = list(cached_posts.keys())[0]
|
||||||
|
first_post_data = cached_posts[first_post_uuid]
|
||||||
|
logger.info(f"Inspecting first post:")
|
||||||
|
logger.info(f" - Post Source: '{first_post_data.get('source', '')}'")
|
||||||
|
logger.info(f" - Post Platform: '{first_post_data.get('platform', '')}'")
|
||||||
|
else:
|
||||||
|
logger.info("No posts found in cache to inspect.")
|
||||||
|
logger.info(f"--- END DEBUG V2 ---")
|
||||||
|
# ====================================================================
|
||||||
|
|
||||||
# Calculate time filter cutoff if enabled
|
# Calculate time filter cutoff if enabled
|
||||||
time_cutoff = None
|
time_cutoff = None
|
||||||
|
# ... (rest of the function) ...
|
||||||
if time_filter_enabled:
|
if time_filter_enabled:
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
cutoff_date = datetime.utcnow() - timedelta(days=time_filter_days)
|
cutoff_date = datetime.utcnow() - timedelta(days=time_filter_days)
|
||||||
|
|||||||
Reference in New Issue
Block a user