Add debugging for proof types not showing in dropdown
Backend logging: - Log channel, sub-channel, and proof type counts in get_all_hierarchical() - Log Meta proof types specifically - Log API response for Social.Meta Frontend logging: - Log raw API response in apiService - Log dropdown options in App.tsx when loaded - Log available proof types in UploadProofModal when channel/subchannel selected This will help diagnose why Meta proof types are not appearing on staging. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3b868f7415
commit
874c1fceee
5 changed files with 42 additions and 5 deletions
|
|
@ -519,8 +519,18 @@ async def get_dropdown_options(
|
|||
user: dict = Depends(get_current_user),
|
||||
):
|
||||
"""Get all dropdown options as hierarchical structure."""
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
repo = DropdownRepository(db)
|
||||
options = await repo.get_all_hierarchical()
|
||||
|
||||
# Debug logging
|
||||
channels = options.get("channels", {})
|
||||
social = channels.get("Social", {})
|
||||
meta_proof_types = social.get("Meta", [])
|
||||
logger.info(f"[DEBUG API] Returning dropdown options - Social.Meta has {len(meta_proof_types)} proof types: {meta_proof_types}")
|
||||
|
||||
return DropdownOptionsResponse(**options)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
"""Repository for dropdown options (channels, sub-channels, proof types)."""
|
||||
import logging
|
||||
import uuid
|
||||
from typing import Optional
|
||||
from sqlalchemy import select, delete
|
||||
|
|
@ -7,6 +8,8 @@ from sqlalchemy.orm import selectinload
|
|||
|
||||
from app.models.models import DropdownOption
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DropdownRepository:
|
||||
"""Repository for managing dropdown options."""
|
||||
|
|
@ -30,6 +33,7 @@ class DropdownRepository:
|
|||
).order_by(DropdownOption.display_order)
|
||||
channels_result = await self.session.execute(channels_stmt)
|
||||
channels = channels_result.scalars().all()
|
||||
logger.info(f"[DEBUG] Found {len(channels)} channels: {[c.value for c in channels]}")
|
||||
|
||||
# Query 2: Get all sub-channels
|
||||
sub_channels_stmt = select(DropdownOption).where(
|
||||
|
|
@ -37,6 +41,7 @@ class DropdownRepository:
|
|||
).order_by(DropdownOption.display_order)
|
||||
sub_channels_result = await self.session.execute(sub_channels_stmt)
|
||||
sub_channels = sub_channels_result.scalars().all()
|
||||
logger.info(f"[DEBUG] Found {len(sub_channels)} sub-channels: {[sc.value for sc in sub_channels]}")
|
||||
|
||||
# Query 3: Get all proof types
|
||||
proof_types_stmt = select(DropdownOption).where(
|
||||
|
|
@ -44,6 +49,7 @@ class DropdownRepository:
|
|||
).order_by(DropdownOption.display_order)
|
||||
proof_types_result = await self.session.execute(proof_types_stmt)
|
||||
proof_types = proof_types_result.scalars().all()
|
||||
logger.info(f"[DEBUG] Found {len(proof_types)} proof types")
|
||||
|
||||
# Build lookup dictionaries
|
||||
sub_channels_by_parent: dict[uuid.UUID, list] = {}
|
||||
|
|
@ -58,6 +64,8 @@ class DropdownRepository:
|
|||
proof_types_by_parent[pt.parent_id] = []
|
||||
proof_types_by_parent[pt.parent_id].append(pt)
|
||||
|
||||
logger.info(f"[DEBUG] proof_types_by_parent has {len(proof_types_by_parent)} entries")
|
||||
|
||||
# Assemble hierarchy
|
||||
hierarchy: dict[str, dict[str, list[str]]] = {}
|
||||
for channel in channels:
|
||||
|
|
@ -66,9 +74,10 @@ class DropdownRepository:
|
|||
|
||||
for sub_channel in sub_channels_by_parent.get(channel.id, []):
|
||||
sub_channel_name = sub_channel.value
|
||||
hierarchy[channel_name][sub_channel_name] = [
|
||||
pt.value for pt in proof_types_by_parent.get(sub_channel.id, [])
|
||||
]
|
||||
proof_type_list = [pt.value for pt in proof_types_by_parent.get(sub_channel.id, [])]
|
||||
hierarchy[channel_name][sub_channel_name] = proof_type_list
|
||||
if sub_channel_name == "Meta":
|
||||
logger.info(f"[DEBUG] Meta sub-channel (id={sub_channel.id}) has {len(proof_type_list)} proof types: {proof_type_list}")
|
||||
|
||||
# Get brand guidelines
|
||||
stmt = select(DropdownOption).where(
|
||||
|
|
|
|||
|
|
@ -61,13 +61,16 @@ const App: React.FC = () => {
|
|||
|
||||
try {
|
||||
const options = await apiService.getDropdownOptions();
|
||||
console.log('[DEBUG App.tsx] Loaded dropdown options from API');
|
||||
console.log('[DEBUG App.tsx] options.channels:', JSON.stringify(options.channels, null, 2));
|
||||
console.log('[DEBUG App.tsx] Social.Meta proof types:', options.channels?.Social?.Meta);
|
||||
setDropdownOptions({
|
||||
campaigns: options.campaigns || [],
|
||||
channels: options.channels || {},
|
||||
brandGuidelines: options.brand_guidelines || []
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Failed to load dropdown options:', error);
|
||||
console.error('[DEBUG App.tsx] Failed to load dropdown options:', error);
|
||||
// Fall back to default options if API fails
|
||||
setDropdownOptions({
|
||||
campaigns: [],
|
||||
|
|
|
|||
|
|
@ -379,6 +379,17 @@ const UploadProofModal: React.FC<{
|
|||
const availableProofTypes = (channel && subChannel) ? (dropdownOptions.channels[channel][subChannel] || []) : [];
|
||||
const showProofType = availableProofTypes.length > 0;
|
||||
|
||||
// Debug logging for proof types
|
||||
useEffect(() => {
|
||||
if (channel && subChannel) {
|
||||
console.log('[DEBUG Frontend] Channel:', channel);
|
||||
console.log('[DEBUG Frontend] SubChannel:', subChannel);
|
||||
console.log('[DEBUG Frontend] dropdownOptions.channels[channel]:', dropdownOptions.channels[channel]);
|
||||
console.log('[DEBUG Frontend] dropdownOptions.channels[channel][subChannel]:', dropdownOptions.channels[channel]?.[subChannel]);
|
||||
console.log('[DEBUG Frontend] availableProofTypes:', availableProofTypes);
|
||||
}
|
||||
}, [channel, subChannel, dropdownOptions, availableProofTypes]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
setFile(null);
|
||||
|
|
|
|||
|
|
@ -314,7 +314,11 @@ class ApiService {
|
|||
|
||||
// Dropdown options endpoints
|
||||
async getDropdownOptions(): Promise<DropdownOptionsResponse> {
|
||||
return this.fetch<DropdownOptionsResponse>('/dropdown-options');
|
||||
const response = await this.fetch<DropdownOptionsResponse>('/dropdown-options');
|
||||
// Debug logging
|
||||
console.log('[DEBUG API Response] Raw dropdown options:', JSON.stringify(response, null, 2));
|
||||
console.log('[DEBUG API Response] Social.Meta proof types:', response.channels?.Social?.Meta);
|
||||
return response;
|
||||
}
|
||||
|
||||
async addChannel(name: string): Promise<void> {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue