CoolFace
Apppublic

mydatascraper/competitor_compare

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes
bulk.cpython-313.pyc41 linesDownload Raw Back to __pycache__
1�

2h/2jo��\�SSKJrJrJrJr SSKJr SSKJr SSK	J3r4Jr SSKJ
r
 SSKJr SSKr\"SS	/S59r\R#S\S9\"\54S
\6S\S\4Sjj5r\R)S5\"\54S\S\4Sjj5r\R#S5S\"\54S\S\4Sjj5rg)�)�	APIRouter�Depends�BackgroundTasks�
HTTPException)�FileResponse)�verify_api_key)�BulkExportRequest�BulkExportResponse)�BulkExportService)�datetimeNz/bulkzBulk Export)�prefix�tagsz/export)�response_model�request�background_tasks�_api_keyc��# �[5nUR(a&URVs/sHoDRPM snOSnUR(a&URVs/sHofRPM snOSnUR	UUUR7URS9n[SSURS5=(d US	US8USS[RRUS	53[R "5[R "5S
9$s snfs snf![an	[SS[U	53S9eSn	A	ff=f7f)aC9Trigger a bulk data export.10 11- **retailers**: Filter to specific retailers (default: all MVP retailers)12- **categories**: Filter to specific categories (default: all)13- **format**: `parquet`, `csv`, or `json`14- **destination**: `local`, `s3`, or `gcs`15 16For S3/GCS delivery, configure credentials in environment variables.17N)�	retailers�18categories�file_format�destinationi�zExport failed: ��status_code�detail��	completed�19cloud_path�filepath�record_count�file_size_bytesz/bulk/download/)�	export_id�status�	file_pathrr �download_url�20started_at�completed_at)rr�valuer�export_full_dataset�formatr�	Exceptionr�strr21�get�os�path�basenamer�utcnow)22rrr�export_service�rr�cr�result�es23          �LC:\Users\sundrani.raza\PycharmProjects\grocery-price-api\app\routers\bulk.py�trigger_bulk_exportr7s3��� '�(�N�8?�8I�8I�'�"3�"3�4�"3�Q���"3�4�t�I�:A�:L�:L�7�#5�#5�6�#5�a�'�'�#5�6�RV�J�P��3�3��!�����+�+�	4�24������*�*�\�*�@�f�Z�.@��N�+��0�1�&�r�w�w�'7�'7��z�8J�'K�&L�M��?�?�$��_�_�&�	�	��5��6���P���o�c�!�f�X�4N�O�O��P�sA�*E�D �$E�%D%�:E�&D*�&BE�*25E�4E26�27E�Ez/download/{filename}�filenamec��@# �SSKJn [RR	UR28U5n[RR
U5(d29[SSS9eSnURS5(aSnOURS	5(aS30n[X0US9$7f)z,Download a previously generated export file.r)�settingsi�zExport file not foundrzapplication/octet-streamz.csvztext/csvz.jsonzapplication/json)r8�31media_type)32�33app.configr:r-r.�join�EXPORT_PATH�existsr�endswithr)r8rr:rr;s     r6�download_exportrA7s����$��w�w�|�|�H�0�0�(�;�H�
�7�7�>�>�(�#�#���4K�L�L�+�J����� � ��34�	�	�	�7�	#�	#�'�35���36�K�K�s�BBz/daily-snapshot�localrc��# �[5nURUS9nSU[R"5R	5S.$7f)zo37Trigger the daily snapshot export (both Parquet and CSV).38 39This is what would run on the daily cron schedule.40)rr)r"�exports�	timestamp)r�export_daily_snapshotrr0�	isoformat)rrr1�resultss    r6�trigger_daily_snapshotrILsE���'�(�N��2�2�{�2�K�G����_�_�&�0�0�2���s�AA)�fastapirrrr�fastapi.responsesr�app.authr�app.schemasr	r41� app.services.bulk_export_servicerrr-�router�post�dictr7r,r+rArI��r6�<module>rTs���F�F�*�#�=�>��	�	�'���	8�����Y�'9��:��^�,�'�
�'�%�'��'�;�'�T���"�#��^�,�L��L��L�$�L�(���
����^�,������ �rS