diff --git a/RSI/__pycache__/__init__.cpython-39.pyc b/RSI/__pycache__/__init__.cpython-39.pyc index 34dd4b6..6739edd 100644 Binary files a/RSI/__pycache__/__init__.cpython-39.pyc and b/RSI/__pycache__/__init__.cpython-39.pyc differ diff --git a/RSI/__pycache__/settings.cpython-39.pyc b/RSI/__pycache__/settings.cpython-39.pyc index b9d9549..5ffe58d 100644 Binary files a/RSI/__pycache__/settings.cpython-39.pyc and b/RSI/__pycache__/settings.cpython-39.pyc differ diff --git a/RSI/__pycache__/urls.cpython-39.pyc b/RSI/__pycache__/urls.cpython-39.pyc index 57c8a7c..977dd48 100644 Binary files a/RSI/__pycache__/urls.cpython-39.pyc and b/RSI/__pycache__/urls.cpython-39.pyc differ diff --git a/RSI/__pycache__/wsgi.cpython-39.pyc b/RSI/__pycache__/wsgi.cpython-39.pyc index 5ea61a5..983bdc0 100644 Binary files a/RSI/__pycache__/wsgi.cpython-39.pyc and b/RSI/__pycache__/wsgi.cpython-39.pyc differ diff --git a/__pycache__/helpers.cpython-39.pyc b/__pycache__/helpers.cpython-39.pyc index 079d9bb..c3abf02 100644 Binary files a/__pycache__/helpers.cpython-39.pyc and b/__pycache__/helpers.cpython-39.pyc differ diff --git a/app/__pycache__/__init__.cpython-39.pyc b/app/__pycache__/__init__.cpython-39.pyc index 35cd699..d177bcd 100644 Binary files a/app/__pycache__/__init__.cpython-39.pyc and b/app/__pycache__/__init__.cpython-39.pyc differ diff --git a/app/__pycache__/admin.cpython-39.pyc b/app/__pycache__/admin.cpython-39.pyc index 9ad3a99..ffc08e0 100644 Binary files a/app/__pycache__/admin.cpython-39.pyc and b/app/__pycache__/admin.cpython-39.pyc differ diff --git a/app/__pycache__/apps.cpython-39.pyc b/app/__pycache__/apps.cpython-39.pyc index f372bdf..80a3b98 100644 Binary files a/app/__pycache__/apps.cpython-39.pyc and b/app/__pycache__/apps.cpython-39.pyc differ diff --git a/app/__pycache__/cityandprovince.cpython-39.pyc b/app/__pycache__/cityandprovince.cpython-39.pyc index 668f95d..2adbe7d 100644 Binary files a/app/__pycache__/cityandprovince.cpython-39.pyc and b/app/__pycache__/cityandprovince.cpython-39.pyc differ diff --git a/app/__pycache__/excel_processing.cpython-39.pyc b/app/__pycache__/excel_processing.cpython-39.pyc index 0d83709..bda6062 100644 Binary files a/app/__pycache__/excel_processing.cpython-39.pyc and b/app/__pycache__/excel_processing.cpython-39.pyc differ diff --git a/app/__pycache__/filtersets.cpython-39.pyc b/app/__pycache__/filtersets.cpython-39.pyc index a1dcfe7..f5da017 100644 Binary files a/app/__pycache__/filtersets.cpython-39.pyc and b/app/__pycache__/filtersets.cpython-39.pyc differ diff --git a/app/__pycache__/helper.cpython-39.pyc b/app/__pycache__/helper.cpython-39.pyc index 77f6159..3bc7b67 100644 Binary files a/app/__pycache__/helper.cpython-39.pyc and b/app/__pycache__/helper.cpython-39.pyc differ diff --git a/app/__pycache__/helper_excel.cpython-39.pyc b/app/__pycache__/helper_excel.cpython-39.pyc index ccd9942..7b69508 100644 Binary files a/app/__pycache__/helper_excel.cpython-39.pyc and b/app/__pycache__/helper_excel.cpython-39.pyc differ diff --git a/app/__pycache__/models.cpython-39.pyc b/app/__pycache__/models.cpython-39.pyc index 4664990..0a3f598 100644 Binary files a/app/__pycache__/models.cpython-39.pyc and b/app/__pycache__/models.cpython-39.pyc differ diff --git a/app/__pycache__/scripts.cpython-39.pyc b/app/__pycache__/scripts.cpython-39.pyc index 6c7920e..2de3648 100644 Binary files a/app/__pycache__/scripts.cpython-39.pyc and b/app/__pycache__/scripts.cpython-39.pyc differ diff --git a/app/__pycache__/serializers.cpython-39.pyc b/app/__pycache__/serializers.cpython-39.pyc index ae53dfc..6877fe9 100644 Binary files a/app/__pycache__/serializers.cpython-39.pyc and b/app/__pycache__/serializers.cpython-39.pyc differ diff --git a/app/__pycache__/urls.cpython-39.pyc b/app/__pycache__/urls.cpython-39.pyc index a07d22b..8daa7bd 100644 Binary files a/app/__pycache__/urls.cpython-39.pyc and b/app/__pycache__/urls.cpython-39.pyc differ diff --git a/app/__pycache__/views.cpython-39.pyc b/app/__pycache__/views.cpython-39.pyc index 96a1436..2896566 100644 Binary files a/app/__pycache__/views.cpython-39.pyc and b/app/__pycache__/views.cpython-39.pyc differ diff --git a/app/excel_processing.py b/app/excel_processing.py index bdee4ef..612ed1b 100644 --- a/app/excel_processing.py +++ b/app/excel_processing.py @@ -21,7 +21,8 @@ from app.serializers import TransportingDetailSerializer, HatchingDetailSerializ StewardForTransportCarcassSerializer, KillHouseForTransportCarcassSerializer, TransportCarcassDetailSerializer, \ GuildsForTransportCarcassSerializer, AllProductsTransportSerializer, AllProductsTransportCustomSerializer from helpers import build_query -from app.helper import get_hatching_permit_code +from app.helper import get_hatching_permit_code, normalize_persian_arabic_text + def transporting_detail_excel(request): filterset_class = TransportingDetailFilterSet @@ -2589,10 +2590,7 @@ def all_products_transport_excel(request): filters['product'] = product_type if destination_province and destination_province != 'undefined': - if destination_province == 'مرکزی': - filters['destination_province'] = 'مركزي' - else: - filters['destination_province'] = destination_province + filters['destination_province'] = normalize_persian_arabic_text(destination_province) if date1 and date2 and date1 != 'undefined' and date2 != 'undefined': try: diff --git a/app/helper.py b/app/helper.py index 66c3f5d..2e65b65 100644 --- a/app/helper.py +++ b/app/helper.py @@ -146,6 +146,26 @@ def api_get_hatching_permit_code(request): return Response({'detail': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) +def normalize_persian_arabic_text(text): + """ + نرمال‌سازی متن فارسی/عربی برای یکسان‌سازی کاراکترهای مشابه + تبدیل کاراکترهای فارسی به عربی برای سازگاری با دیتابیس + این تابع کاراکترهای 'ک' و 'ی' فارسی را به 'ك' و 'ي' عربی تبدیل می‌کند + تا با فرم استاندارد ذخیره شده در دیتابیس مطابقت داشته باشد + """ + if not text: + return text + + # تبدیل کاراکترهای فارسی به عربی + # 'ک' (U+06A9 - Persian Kaf) -> 'ك' (U+0643 - Arabic Kaf) + # 'ی' (U+06CC - Persian Yeh) -> 'ي' (U+064A - Arabic Yeh) + text = str(text) + text = text.replace('ک', 'ك') # Persian Kaf to Arabic Kaf + text = text.replace('ی', 'ي') # Persian Yeh to Arabic Yeh + + return text + + def create_guild(**info): Guilds( diff --git a/app/migrations/__pycache__/0001_initial.cpython-39.pyc b/app/migrations/__pycache__/0001_initial.cpython-39.pyc index 9c4f972..59257f6 100644 Binary files a/app/migrations/__pycache__/0001_initial.cpython-39.pyc and b/app/migrations/__pycache__/0001_initial.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0002_remove_poultry_allowinsert_and_more.cpython-39.pyc b/app/migrations/__pycache__/0002_remove_poultry_allowinsert_and_more.cpython-39.pyc index b648d65..8ceafba 100644 Binary files a/app/migrations/__pycache__/0002_remove_poultry_allowinsert_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0002_remove_poultry_allowinsert_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0003_poultry_allowinsert_poultry_allowupdate_and_more.cpython-39.pyc b/app/migrations/__pycache__/0003_poultry_allowinsert_poultry_allowupdate_and_more.cpython-39.pyc index 44072ef..465c096 100644 Binary files a/app/migrations/__pycache__/0003_poultry_allowinsert_poultry_allowupdate_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0003_poultry_allowinsert_poultry_allowupdate_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0004_poultryhatching_date_poultryhatching_hatchingage.cpython-39.pyc b/app/migrations/__pycache__/0004_poultryhatching_date_poultryhatching_hatchingage.cpython-39.pyc index 547f000..15b3f4f 100644 Binary files a/app/migrations/__pycache__/0004_poultryhatching_date_poultryhatching_hatchingage.cpython-39.pyc and b/app/migrations/__pycache__/0004_poultryhatching_date_poultryhatching_hatchingage.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0005_remove_poultryhatching_basehatchingcount_and_more.cpython-39.pyc b/app/migrations/__pycache__/0005_remove_poultryhatching_basehatchingcount_and_more.cpython-39.pyc index 2e5e7f3..b621f35 100644 Binary files a/app/migrations/__pycache__/0005_remove_poultryhatching_basehatchingcount_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0005_remove_poultryhatching_basehatchingcount_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0006_poultryhatching_basehatchingcount_and_more.cpython-39.pyc b/app/migrations/__pycache__/0006_poultryhatching_basehatchingcount_and_more.cpython-39.pyc index 3779d12..75b8bac 100644 Binary files a/app/migrations/__pycache__/0006_poultryhatching_basehatchingcount_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0006_poultryhatching_basehatchingcount_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0007_transportingchickendetail.cpython-39.pyc b/app/migrations/__pycache__/0007_transportingchickendetail.cpython-39.pyc index 43febf8..9967d97 100644 Binary files a/app/migrations/__pycache__/0007_transportingchickendetail.cpython-39.pyc and b/app/migrations/__pycache__/0007_transportingchickendetail.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0008_transportingchickendetail_certid_and_more.cpython-39.pyc b/app/migrations/__pycache__/0008_transportingchickendetail_certid_and_more.cpython-39.pyc index 566ab29..89112dc 100644 Binary files a/app/migrations/__pycache__/0008_transportingchickendetail_certid_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0008_transportingchickendetail_certid_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0009_transportingchickendetail_broilerflockrequestid_and_more.cpython-39.pyc b/app/migrations/__pycache__/0009_transportingchickendetail_broilerflockrequestid_and_more.cpython-39.pyc index 9593d5c..d1e448f 100644 Binary files a/app/migrations/__pycache__/0009_transportingchickendetail_broilerflockrequestid_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0009_transportingchickendetail_broilerflockrequestid_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0010_transportingchickendetail_province_and_more.cpython-39.pyc b/app/migrations/__pycache__/0010_transportingchickendetail_province_and_more.cpython-39.pyc index ea50bb7..e52f9e0 100644 Binary files a/app/migrations/__pycache__/0010_transportingchickendetail_province_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0010_transportingchickendetail_province_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0011_poultryhatching_pedigreename.cpython-39.pyc b/app/migrations/__pycache__/0011_poultryhatching_pedigreename.cpython-39.pyc index a2806f8..6b9993c 100644 Binary files a/app/migrations/__pycache__/0011_poultryhatching_pedigreename.cpython-39.pyc and b/app/migrations/__pycache__/0011_poultryhatching_pedigreename.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0012_transportingchickendetail_age.cpython-39.pyc b/app/migrations/__pycache__/0012_transportingchickendetail_age.cpython-39.pyc index 6b3eae6..9804eba 100644 Binary files a/app/migrations/__pycache__/0012_transportingchickendetail_age.cpython-39.pyc and b/app/migrations/__pycache__/0012_transportingchickendetail_age.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0013_poultryhatching_leftover.cpython-39.pyc b/app/migrations/__pycache__/0013_poultryhatching_leftover.cpython-39.pyc index c526004..f944a13 100644 Binary files a/app/migrations/__pycache__/0013_poultryhatching_leftover.cpython-39.pyc and b/app/migrations/__pycache__/0013_poultryhatching_leftover.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0014_poultry_locationnamecity_and_more.cpython-39.pyc b/app/migrations/__pycache__/0014_poultry_locationnamecity_and_more.cpython-39.pyc index 2542a5d..b42d282 100644 Binary files a/app/migrations/__pycache__/0014_poultry_locationnamecity_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0014_poultry_locationnamecity_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0015_hatching_transportingdetail.cpython-39.pyc b/app/migrations/__pycache__/0015_hatching_transportingdetail.cpython-39.pyc index 7d2aa5a..27b3a56 100644 Binary files a/app/migrations/__pycache__/0015_hatching_transportingdetail.cpython-39.pyc and b/app/migrations/__pycache__/0015_hatching_transportingdetail.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0016_remove_transportingdetail_certid_and_more.cpython-39.pyc b/app/migrations/__pycache__/0016_remove_transportingdetail_certid_and_more.cpython-39.pyc index 917e50b..8274759 100644 Binary files a/app/migrations/__pycache__/0016_remove_transportingdetail_certid_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0016_remove_transportingdetail_certid_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0017_hatching_archivedate.cpython-39.pyc b/app/migrations/__pycache__/0017_hatching_archivedate.cpython-39.pyc index 2826a4b..c129df3 100644 Binary files a/app/migrations/__pycache__/0017_hatching_archivedate.cpython-39.pyc and b/app/migrations/__pycache__/0017_hatching_archivedate.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0018_remove_hatching_capacityfemale.cpython-39.pyc b/app/migrations/__pycache__/0018_remove_hatching_capacityfemale.cpython-39.pyc index ff34316..767ddaa 100644 Binary files a/app/migrations/__pycache__/0018_remove_hatching_capacityfemale.cpython-39.pyc and b/app/migrations/__pycache__/0018_remove_hatching_capacityfemale.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0019_hatching_capacityfemale.cpython-39.pyc b/app/migrations/__pycache__/0019_hatching_capacityfemale.cpython-39.pyc index 9a667c4..e78fe77 100644 Binary files a/app/migrations/__pycache__/0019_hatching_capacityfemale.cpython-39.pyc and b/app/migrations/__pycache__/0019_hatching_capacityfemale.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0020_killhouse.cpython-39.pyc b/app/migrations/__pycache__/0020_killhouse.cpython-39.pyc index 682493b..cc75bbc 100644 Binary files a/app/migrations/__pycache__/0020_killhouse.cpython-39.pyc and b/app/migrations/__pycache__/0020_killhouse.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0021_hatching_killingave_transportingdetail_out_and_more.cpython-39.pyc b/app/migrations/__pycache__/0021_hatching_killingave_transportingdetail_out_and_more.cpython-39.pyc index ff7dcb6..6fe6e9c 100644 Binary files a/app/migrations/__pycache__/0021_hatching_killingave_transportingdetail_out_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0021_hatching_killingave_transportingdetail_out_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0022_alter_hatching_killingave.cpython-39.pyc b/app/migrations/__pycache__/0022_alter_hatching_killingave.cpython-39.pyc index 7691652..6d63858 100644 Binary files a/app/migrations/__pycache__/0022_alter_hatching_killingave.cpython-39.pyc and b/app/migrations/__pycache__/0022_alter_hatching_killingave.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0023_killhouse_cityid_killhouse_provinceid.cpython-39.pyc b/app/migrations/__pycache__/0023_killhouse_cityid_killhouse_provinceid.cpython-39.pyc index 9b67d95..2f93d9e 100644 Binary files a/app/migrations/__pycache__/0023_killhouse_cityid_killhouse_provinceid.cpython-39.pyc and b/app/migrations/__pycache__/0023_killhouse_cityid_killhouse_provinceid.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0024_poultry_city_poultry_province.cpython-39.pyc b/app/migrations/__pycache__/0024_poultry_city_poultry_province.cpython-39.pyc index 9c722eb..e0a61cd 100644 Binary files a/app/migrations/__pycache__/0024_poultry_city_poultry_province.cpython-39.pyc and b/app/migrations/__pycache__/0024_poultry_city_poultry_province.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0025_delete_transportingdetail.cpython-39.pyc b/app/migrations/__pycache__/0025_delete_transportingdetail.cpython-39.pyc index 08f48a2..1f5979c 100644 Binary files a/app/migrations/__pycache__/0025_delete_transportingdetail.cpython-39.pyc and b/app/migrations/__pycache__/0025_delete_transportingdetail.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0026_transportingdetail.cpython-39.pyc b/app/migrations/__pycache__/0026_transportingdetail.cpython-39.pyc index 7f78c94..0cd67ee 100644 Binary files a/app/migrations/__pycache__/0026_transportingdetail.cpython-39.pyc and b/app/migrations/__pycache__/0026_transportingdetail.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0027_hatching_samasat_discharge_percentage_and_more.cpython-39.pyc b/app/migrations/__pycache__/0027_hatching_samasat_discharge_percentage_and_more.cpython-39.pyc index 21ce775..4e301d9 100644 Binary files a/app/migrations/__pycache__/0027_hatching_samasat_discharge_percentage_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0027_hatching_samasat_discharge_percentage_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0028_hatching_goodsum.cpython-39.pyc b/app/migrations/__pycache__/0028_hatching_goodsum.cpython-39.pyc index 16e7714..19f755f 100644 Binary files a/app/migrations/__pycache__/0028_hatching_goodsum.cpython-39.pyc and b/app/migrations/__pycache__/0028_hatching_goodsum.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0029_apkinfo.cpython-39.pyc b/app/migrations/__pycache__/0029_apkinfo.cpython-39.pyc index be18a6f..b5340f6 100644 Binary files a/app/migrations/__pycache__/0029_apkinfo.cpython-39.pyc and b/app/migrations/__pycache__/0029_apkinfo.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0030_transportcarcassdetail.cpython-39.pyc b/app/migrations/__pycache__/0030_transportcarcassdetail.cpython-39.pyc index ebd53f9..e56f092 100644 Binary files a/app/migrations/__pycache__/0030_transportcarcassdetail.cpython-39.pyc and b/app/migrations/__pycache__/0030_transportcarcassdetail.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0031_auto_20250921_1447.cpython-39.pyc b/app/migrations/__pycache__/0031_auto_20250921_1447.cpython-39.pyc index 32b680d..34613e0 100644 Binary files a/app/migrations/__pycache__/0031_auto_20250921_1447.cpython-39.pyc and b/app/migrations/__pycache__/0031_auto_20250921_1447.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0032_delete_transportcarcassdetail.cpython-39.pyc b/app/migrations/__pycache__/0032_delete_transportcarcassdetail.cpython-39.pyc index de27cb5..18ffcfd 100644 Binary files a/app/migrations/__pycache__/0032_delete_transportcarcassdetail.cpython-39.pyc and b/app/migrations/__pycache__/0032_delete_transportcarcassdetail.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0033_transportcarcassdetail.cpython-39.pyc b/app/migrations/__pycache__/0033_transportcarcassdetail.cpython-39.pyc index 4ff96d3..711c845 100644 Binary files a/app/migrations/__pycache__/0033_transportcarcassdetail.cpython-39.pyc and b/app/migrations/__pycache__/0033_transportcarcassdetail.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0034_guilds.cpython-39.pyc b/app/migrations/__pycache__/0034_guilds.cpython-39.pyc index 043a7ef..0e566df 100644 Binary files a/app/migrations/__pycache__/0034_guilds.cpython-39.pyc and b/app/migrations/__pycache__/0034_guilds.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0035_guilds_is_steward.cpython-39.pyc b/app/migrations/__pycache__/0035_guilds_is_steward.cpython-39.pyc index 55d59fa..0248b53 100644 Binary files a/app/migrations/__pycache__/0035_guilds_is_steward.cpython-39.pyc and b/app/migrations/__pycache__/0035_guilds_is_steward.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0036_driver.cpython-39.pyc b/app/migrations/__pycache__/0036_driver.cpython-39.pyc index 2b74ea9..f5f70d0 100644 Binary files a/app/migrations/__pycache__/0036_driver.cpython-39.pyc and b/app/migrations/__pycache__/0036_driver.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0037_driver_product.cpython-39.pyc b/app/migrations/__pycache__/0037_driver_product.cpython-39.pyc index 73b2db2..f3ec73e 100644 Binary files a/app/migrations/__pycache__/0037_driver_product.cpython-39.pyc and b/app/migrations/__pycache__/0037_driver_product.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0038_auto_20250927_0848.cpython-39.pyc b/app/migrations/__pycache__/0038_auto_20250927_0848.cpython-39.pyc index 885b524..b72b528 100644 Binary files a/app/migrations/__pycache__/0038_auto_20250927_0848.cpython-39.pyc and b/app/migrations/__pycache__/0038_auto_20250927_0848.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0039_alter_transportcarcassdetail_tracking.cpython-39.pyc b/app/migrations/__pycache__/0039_alter_transportcarcassdetail_tracking.cpython-39.pyc index bf996d4..6ea6d0e 100644 Binary files a/app/migrations/__pycache__/0039_alter_transportcarcassdetail_tracking.cpython-39.pyc and b/app/migrations/__pycache__/0039_alter_transportcarcassdetail_tracking.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0040_transportcarcassdetail_product_date.cpython-39.pyc b/app/migrations/__pycache__/0040_transportcarcassdetail_product_date.cpython-39.pyc index a8d257c..88d1a27 100644 Binary files a/app/migrations/__pycache__/0040_transportcarcassdetail_product_date.cpython-39.pyc and b/app/migrations/__pycache__/0040_transportcarcassdetail_product_date.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0041_transportcarcassdetail_has_product_date.cpython-39.pyc b/app/migrations/__pycache__/0041_transportcarcassdetail_has_product_date.cpython-39.pyc index 1e409fd..3ad54d3 100644 Binary files a/app/migrations/__pycache__/0041_transportcarcassdetail_has_product_date.cpython-39.pyc and b/app/migrations/__pycache__/0041_transportcarcassdetail_has_product_date.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0042_alter_driver_created_by_alter_driver_modified_by_and_more.cpython-39.pyc b/app/migrations/__pycache__/0042_alter_driver_created_by_alter_driver_modified_by_and_more.cpython-39.pyc index 0c73810..92997bc 100644 Binary files a/app/migrations/__pycache__/0042_alter_driver_created_by_alter_driver_modified_by_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0042_alter_driver_created_by_alter_driver_modified_by_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0043_allproductstransport.cpython-39.pyc b/app/migrations/__pycache__/0043_allproductstransport.cpython-39.pyc index 4c4e584..56e91f8 100644 Binary files a/app/migrations/__pycache__/0043_allproductstransport.cpython-39.pyc and b/app/migrations/__pycache__/0043_allproductstransport.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0044_evacuationdetail.cpython-39.pyc b/app/migrations/__pycache__/0044_evacuationdetail.cpython-39.pyc index c069029..3ec9475 100644 Binary files a/app/migrations/__pycache__/0044_evacuationdetail.cpython-39.pyc and b/app/migrations/__pycache__/0044_evacuationdetail.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0045_remove_evacuationdetail_broilerflockrequestid_and_more.cpython-39.pyc b/app/migrations/__pycache__/0045_remove_evacuationdetail_broilerflockrequestid_and_more.cpython-39.pyc index d7f9428..94e82f5 100644 Binary files a/app/migrations/__pycache__/0045_remove_evacuationdetail_broilerflockrequestid_and_more.cpython-39.pyc and b/app/migrations/__pycache__/0045_remove_evacuationdetail_broilerflockrequestid_and_more.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/0046_rasadyarappinfo.cpython-39.pyc b/app/migrations/__pycache__/0046_rasadyarappinfo.cpython-39.pyc index 842d0fb..f877468 100644 Binary files a/app/migrations/__pycache__/0046_rasadyarappinfo.cpython-39.pyc and b/app/migrations/__pycache__/0046_rasadyarappinfo.cpython-39.pyc differ diff --git a/app/migrations/__pycache__/__init__.cpython-39.pyc b/app/migrations/__pycache__/__init__.cpython-39.pyc index f60a861..0f40f12 100644 Binary files a/app/migrations/__pycache__/__init__.cpython-39.pyc and b/app/migrations/__pycache__/__init__.cpython-39.pyc differ diff --git a/app/serializers.py b/app/serializers.py index 59d78e6..062e2f0 100644 --- a/app/serializers.py +++ b/app/serializers.py @@ -622,32 +622,66 @@ class AllProductsTransportCustomSerializer(serializers.ModelSerializer): def get_location_origin(self, obj): resul = {} - province_origin = Province.objects.filter(name=obj.origin_province).first() - city_origin = City.objects.filter(name=obj.origin_city).first() - if province_origin: - resul.update({ - "provinceLat": province_origin.Lat, - "provinceLng": province_origin.Lng - }) - if city_origin: - resul.update({ - "cityLat": city_origin.Lat, - "cityLng": city_origin.Lng - }) + # بهینه‌سازی: استفاده از context cache برای جلوگیری از N+1 queries + location_cache = self.context.get('location_cache', {}) + + if obj.origin_province: + cache_key = f"province_{obj.origin_province}" + if cache_key not in location_cache: + province_origin = Province.objects.filter(name=obj.origin_province).only('Lat', 'Lng').first() + if province_origin: + location_cache[cache_key] = { + "provinceLat": province_origin.Lat, + "provinceLng": province_origin.Lng + } + else: + location_cache[cache_key] = {} + resul.update(location_cache.get(cache_key, {})) + + if obj.origin_city: + cache_key = f"city_{obj.origin_city}" + if cache_key not in location_cache: + city_origin = City.objects.filter(name=obj.origin_city).only('Lat', 'Lng').first() + if city_origin: + location_cache[cache_key] = { + "cityLat": city_origin.Lat, + "cityLng": city_origin.Lng + } + else: + location_cache[cache_key] = {} + resul.update(location_cache.get(cache_key, {})) + return resul def get_location_destination(self, obj): resul = {} - province_destination = Province.objects.filter(name=obj.destination_province).first() - city_destination = City.objects.filter(name=obj.destination_city).first() - if province_destination: - resul.update({ - "provinceLat": province_destination.Lat, - "provinceLng": province_destination.Lng - }) - if city_destination: - resul.update({ - "cityLat": city_destination.Lat, - "cityLng": city_destination.Lng - }) + # بهینه‌سازی: استفاده از context cache برای جلوگیری از N+1 queries + location_cache = self.context.get('location_cache', {}) + + if obj.destination_province: + cache_key = f"province_{obj.destination_province}" + if cache_key not in location_cache: + province_destination = Province.objects.filter(name=obj.destination_province).only('Lat', 'Lng').first() + if province_destination: + location_cache[cache_key] = { + "provinceLat": province_destination.Lat, + "provinceLng": province_destination.Lng + } + else: + location_cache[cache_key] = {} + resul.update(location_cache.get(cache_key, {})) + + if obj.destination_city: + cache_key = f"city_{obj.destination_city}" + if cache_key not in location_cache: + city_destination = City.objects.filter(name=obj.destination_city).only('Lat', 'Lng').first() + if city_destination: + location_cache[cache_key] = { + "cityLat": city_destination.Lat, + "cityLng": city_destination.Lng + } + else: + location_cache[cache_key] = {} + resul.update(location_cache.get(cache_key, {})) + return resul diff --git a/app/views.py b/app/views.py index 0c5fdd2..a71e302 100644 --- a/app/views.py +++ b/app/views.py @@ -26,7 +26,7 @@ from app.filtersets import PoultryFilterSet, PoultryHatchingFilterSet, Transport PoultryInfoFilterSet, HatchingCalculationsFilterSet, HatchingsFilterSet, TransportingDetailFilterSet, \ KillHouseFilterSet, TransportingDetailCustomFilterSet, CustomHatchingsFilterSet, TransportCarcassDetailFilterSet, \ DriverFilterSet, GuildsFilterSet, AllProductsTransportFilterSet -from app.helper import SSLAdapter, get_hatching_permit_code +from app.helper import SSLAdapter, get_hatching_permit_code, normalize_persian_arabic_text from app.models import Poultry, PoultryHatching, TransportingChickenDetail, Hatching, TransportingDetail, KillHouse, \ ApkInfo, TransportCarcassDetail, Guilds, Driver, InquiryCredentials, AllProductsTransport, EvacuationDetail, \ RasadyarAppInfo @@ -4522,10 +4522,7 @@ class AllProductsTransportViewSet(viewsets.ModelViewSet): filters['product'] = product_type if destination_province and destination_province != 'undefined': - if destination_province == 'مرکزی': - filters['destination_province'] = 'مركزي' - else: - filters['destination_province'] = destination_province + filters['destination_province'] = normalize_persian_arabic_text(destination_province) if date1 and date2 and date1 != 'undefined' and date2 != 'undefined': try: @@ -4536,23 +4533,33 @@ class AllProductsTransportViewSet(viewsets.ModelViewSet): except ValueError: pass - transports = AllProductsTransport.objects.filter(**filters).order_by('-date', '-create_date') + # بهینه‌سازی: استفاده از select_related برای جلوگیری از N+1 queries + # و اعمال order_by فقط یک بار + transports = AllProductsTransport.objects.select_related('hatching').filter(**filters) if search and search != 'undefined' and search.strip(): - transports = transports.filter( - build_query(self.filterset_class.Meta.fields, search) - ) + transports = transports.filter( + build_query(self.filterset_class.Meta.fields, search) + ) + + # اعمال order_by فقط یک بار در آخر + transports = transports.order_by('-date', '-create_date') page_size = request.query_params.get('page_size', None) if page_size: self.pagination_class.page_size = int(page_size) - page = self.paginate_queryset(transports.order_by('-date', '-create_date')) + page = self.paginate_queryset(transports) + # بهینه‌سازی: ایجاد cache برای Province و City در context برای جلوگیری از N+1 queries + location_cache = {} + context = self.get_serializer_context() + context['location_cache'] = location_cache + if page is not None: - serializer = self.get_serializer(page, many=True) + serializer = self.get_serializer(page, many=True, context=context) return self.get_paginated_response(serializer.data) - serializer = self.serializer_class(transports.order_by('-date', '-create_date'), many=True) + serializer = self.serializer_class(transports, many=True, context=context) return Response(serializer.data, status=status.HTTP_200_OK) def create(self, request, *args, **kwargs): @@ -4755,10 +4762,7 @@ class AllProductsTransportDashboardView(APIView): destination_province = request.GET.get('destination_province') kill_house_filterset_class = AllProductsTransportFilterSet if destination_province and destination_province != 'undefined': - if destination_province == 'مرکزی': - filters['destination_province'] = 'مركزي' - else: - filters['destination_province'] = destination_province + filters['destination_province'] = normalize_persian_arabic_text(destination_province) queryset = AllProductsTransport.objects.filter(**filters) if search and search != 'undefined' and search.strip(): @@ -4785,10 +4789,7 @@ class AllProductsTransportDashboardView(APIView): # bars = queryset.filter(jihadi_origin__in=kill_house_codes) if destination_province and destination_province != 'undefined': - if destination_province == 'مرکزی': - filters_query['destination_province'] = 'مركزي' - else: - filters_query['destination_province'] = destination_province + filters_query['destination_province'] = normalize_persian_arabic_text(destination_province) bars = queryset.filter(**filters_query) aggregation = bars.aggregate( total=Sum('quantity'), @@ -4850,10 +4851,7 @@ class AllProductsTransportDashboardView(APIView): ).order_by('-modify_date') if destination_province and destination_province != 'undefined': - if destination_province == 'مرکزی': - filters_query['destination_province'] = 'مركزي' - else: - filters_query['destination_province'] = destination_province + filters_query['destination_province'] = normalize_persian_arabic_text(destination_province) bars = bars(**filters_query) aggregation = bars.aggregate( total=Sum('quantity'), diff --git a/authentication/__pycache__/__init__.cpython-39.pyc b/authentication/__pycache__/__init__.cpython-39.pyc index ba104ec..2eb3c6b 100644 Binary files a/authentication/__pycache__/__init__.cpython-39.pyc and b/authentication/__pycache__/__init__.cpython-39.pyc differ diff --git a/authentication/__pycache__/admin.cpython-39.pyc b/authentication/__pycache__/admin.cpython-39.pyc index 8970a7a..0434e32 100644 Binary files a/authentication/__pycache__/admin.cpython-39.pyc and b/authentication/__pycache__/admin.cpython-39.pyc differ diff --git a/authentication/__pycache__/apps.cpython-39.pyc b/authentication/__pycache__/apps.cpython-39.pyc index bf50178..b19ad11 100644 Binary files a/authentication/__pycache__/apps.cpython-39.pyc and b/authentication/__pycache__/apps.cpython-39.pyc differ diff --git a/authentication/__pycache__/models.cpython-39.pyc b/authentication/__pycache__/models.cpython-39.pyc index ed1dd29..b4dd9ab 100644 Binary files a/authentication/__pycache__/models.cpython-39.pyc and b/authentication/__pycache__/models.cpython-39.pyc differ diff --git a/authentication/__pycache__/serializers.cpython-39.pyc b/authentication/__pycache__/serializers.cpython-39.pyc index 8579ce2..7483bad 100644 Binary files a/authentication/__pycache__/serializers.cpython-39.pyc and b/authentication/__pycache__/serializers.cpython-39.pyc differ diff --git a/authentication/__pycache__/urls.cpython-39.pyc b/authentication/__pycache__/urls.cpython-39.pyc index 9924065..f08aa32 100644 Binary files a/authentication/__pycache__/urls.cpython-39.pyc and b/authentication/__pycache__/urls.cpython-39.pyc differ diff --git a/authentication/__pycache__/views.cpython-39.pyc b/authentication/__pycache__/views.cpython-39.pyc index 7e8ce58..6b2bfed 100644 Binary files a/authentication/__pycache__/views.cpython-39.pyc and b/authentication/__pycache__/views.cpython-39.pyc differ diff --git a/authentication/migrations/__pycache__/0001_initial.cpython-39.pyc b/authentication/migrations/__pycache__/0001_initial.cpython-39.pyc index 3822c8e..ab417b3 100644 Binary files a/authentication/migrations/__pycache__/0001_initial.cpython-39.pyc and b/authentication/migrations/__pycache__/0001_initial.cpython-39.pyc differ diff --git a/authentication/migrations/__pycache__/0002_city_lat_city_lng_province_lat_province_lng.cpython-39.pyc b/authentication/migrations/__pycache__/0002_city_lat_city_lng_province_lat_province_lng.cpython-39.pyc index 2c547e2..1ba5a03 100644 Binary files a/authentication/migrations/__pycache__/0002_city_lat_city_lng_province_lat_province_lng.cpython-39.pyc and b/authentication/migrations/__pycache__/0002_city_lat_city_lng_province_lat_province_lng.cpython-39.pyc differ diff --git a/authentication/migrations/__pycache__/0003_auto_20250809_1248.cpython-39.pyc b/authentication/migrations/__pycache__/0003_auto_20250809_1248.cpython-39.pyc index d52bd05..25bf33e 100644 Binary files a/authentication/migrations/__pycache__/0003_auto_20250809_1248.cpython-39.pyc and b/authentication/migrations/__pycache__/0003_auto_20250809_1248.cpython-39.pyc differ diff --git a/authentication/migrations/__pycache__/0004_province_tel_prefix.cpython-39.pyc b/authentication/migrations/__pycache__/0004_province_tel_prefix.cpython-39.pyc index 9f79d0e..5f4707d 100644 Binary files a/authentication/migrations/__pycache__/0004_province_tel_prefix.cpython-39.pyc and b/authentication/migrations/__pycache__/0004_province_tel_prefix.cpython-39.pyc differ diff --git a/authentication/migrations/__pycache__/__init__.cpython-39.pyc b/authentication/migrations/__pycache__/__init__.cpython-39.pyc index f413242..ee1aabe 100644 Binary files a/authentication/migrations/__pycache__/__init__.cpython-39.pyc and b/authentication/migrations/__pycache__/__init__.cpython-39.pyc differ