feat(api): add sheets-inspect endpoint and filter params to sync-sheets
This commit is contained in:
@@ -475,13 +475,25 @@ def get_stats():
|
||||
@api_dashboard_bp.route('/sync-sheets', methods=['POST'])
|
||||
@jwt_required
|
||||
def sync_google_sheets():
|
||||
"""Ejecuta la sincronización real con las hojas de cálculo de Google Sheets."""
|
||||
"""Ejecuta la sincronización real con las hojas de cálculo de Google Sheets con soporte de filtros."""
|
||||
from app.services.sheets_importer import GoogleSheetsImporter
|
||||
try:
|
||||
data = request.get_json(silent=True) or {}
|
||||
custom_url = data.get('sheets_url') or data.get('base_url')
|
||||
filter_career = data.get('filter_career')
|
||||
filter_subject = data.get('filter_subject')
|
||||
filter_day = data.get('filter_day')
|
||||
manual_date = data.get('manual_date')
|
||||
single_date_only = bool(data.get('single_date_only', False))
|
||||
|
||||
importer = GoogleSheetsImporter(base_url=custom_url)
|
||||
stats = importer.sync()
|
||||
stats = importer.sync(
|
||||
filter_career=filter_career,
|
||||
filter_subject=filter_subject,
|
||||
filter_day=filter_day,
|
||||
manual_date=manual_date,
|
||||
single_date_only=single_date_only
|
||||
)
|
||||
return jsonify({
|
||||
'status': 'success',
|
||||
'stats': stats,
|
||||
@@ -493,3 +505,24 @@ def sync_google_sheets():
|
||||
'message': str(e)
|
||||
}), 500
|
||||
|
||||
@api_dashboard_bp.route('/sheets-inspect', methods=['GET', 'POST'])
|
||||
@jwt_required
|
||||
def inspect_google_sheets():
|
||||
"""Devuelve metadatos, carreras y materias del Google Sheet online para filtros interactivos."""
|
||||
from app.services.sheets_importer import GoogleSheetsImporter
|
||||
try:
|
||||
data = request.get_json(silent=True) or {}
|
||||
custom_url = data.get('sheets_url') or request.args.get('sheets_url')
|
||||
importer = GoogleSheetsImporter(base_url=custom_url)
|
||||
metadata = importer.inspect_sheet_content()
|
||||
return jsonify({
|
||||
'status': 'success',
|
||||
'metadata': metadata,
|
||||
'source_url': importer.base_url
|
||||
}), 200
|
||||
except Exception as e:
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'message': str(e)
|
||||
}), 500
|
||||
|
||||
|
||||
Reference in New Issue
Block a user