import os

import django
from celery import Celery
from kombu import Queue

from fwd import settings

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fwd.settings")
django.setup()

app: Celery = Celery(
    'postman',
    broker=settings.BROKER_URL,
    include=['fwd_api.celery_worker.process_result_tasks', 'fwd_api.celery_worker.internal_task'],
)

app.conf.update({
    'task_queues':
    [
        # Queue('id_card_rs'),
        # Queue('driver_license_rs'),
        # Queue('invoice_rs'),
        # Queue('ocr_with_box_rs'),
        # Queue('template_matching_rs'),
        Queue('invoice_sap_rs'),
        Queue('invoice_fi_rs'),
        Queue('invoice_manulife_rs'),
        Queue('invoice_sbt_rs'),
        Queue('do_pdf'),
        Queue('upload_file_to_s3'),
        Queue('upload_obj_to_s3'),

    ],
    'task_routes': {
        # 'process_id_result': {'queue': 'id_card_rs'},
        # 'process_driver_license_result': {'queue': "driver_license_rs"},
        # 'process_invoice_result': {'queue': "invoice_rs"},
        # 'process_ocr_with_box_result': {'queue': "ocr_with_box_rs"},
        # 'process_template_matching_result': {'queue': 'template_matching_rs'},
        'process_sap_invoice_result': {'queue': 'invoice_sap_rs'},
        'process_sap_invoice': {'queue': "invoice_sap"},
        'process_fi_invoice_result': {'queue': 'invoice_fi_rs'},
        'process_fi_invoice': {'queue': "invoice_fi"},    
        'process_manulife_invoice_result': {'queue': 'invoice_manulife_rs'},
        'process_manulife_invoice': {'queue': "invoice_manulife"},
        'process_sbt_invoice_result': {'queue': 'invoice_sbt_rs'},
        'process_sbt_invoice': {'queue': "invoice_sbt"},
        'do_pdf': {'queue': "do_pdf"},   
        'upload_file_to_s3': {'queue': "upload_file_to_s3"},   
        'upload_obj_to_s3': {'queue': "upload_obj_to_s3"},   
        }
})

if __name__ == "__main__":
    argv = [
        'worker',
        '--loglevel=INFO',
        '--pool=solo'  # Window opts
    ]
    app.worker_main(argv)
