Overview
The News System enables administrators to publish location-targeted announcements and news articles to specific parishes (parroquias) and neighborhoods (barrios) in Manta. Citizens automatically receive news relevant to their registered location.Architecture
Data Model
Targeting Logic
The system implements a three-tier targeting hierarchy:Parish-Level News
When
parroquia_destino is set but barrio_destino is null, the news is visible to all users in that parish.News Store (noticias.store.ts)
State Management
Fetching News for Citizens
Citizens receive news based on their registered location:Fetching All News (Admin)
Administrators can view all news regardless of targeting:Creating News (Admin)
Only administrators can create news articles:Updating News
Geolocation Filtering
Query Builder Pattern
The system uses Supabaseβs query builder with OR conditions:Filtering Examples
- Global News
- Parish News
- Neighborhood News
- User Query
Usage Examples
In Vue Components
Performance Optimization
Concurrent Fetch Prevention
The store prevents concurrent API calls to improve performance:Query Optimization
The Supabase query uses indexed columns (
parroquia_destino, barrio_destino) for optimal performance. Make sure to add indexes in your database:Best Practices
Always Specify Order
Always Specify Order
Always order by
created_at DESC to show newest news first. This is critical for user experience.Image Optimization
Image Optimization
Store images in Supabase Storage and reference them via
imagen_url. Optimize images before upload (max 1200px width, compressed).Concurrent Request Handling
Concurrent Request Handling
Use the loading flag to prevent duplicate API calls when components mount simultaneously.
Error Handling
Error Handling
Always handle errors gracefully and provide user feedback. The storeβs error state can be used to display error messages.
Related Resources
Reports System
Similar geolocation-based targeting for citizen reports
Supabase Queries
Advanced query patterns and filtering
