This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[x] Created custom jobs for red_flag, summarize_supplier and summarize_buyer [x] Added new ScheduleRunner class in schedule.py [x] Added Schedule Runner on tender create/edit/delete [x] Removed fill_contract_values from management command [x] Management command can now handle all case for country code
- Loading branch information
Suyoj Man Tamrakar
authored and
Kushal Raj Shrestha
committed
Jul 16, 2021
1 parent
6a04eed
commit facbf4b
Showing
11 changed files
with
272 additions
and
227 deletions.
There are no files selected for viewing
45 changes: 14 additions & 31 deletions
45
country/management/commands/evaluate_contract_red_flag.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,23 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from country.models import Country, Tender | ||
from country.tasks import clear_redflag, process_redflag, process_redflag6, process_redflag7 | ||
from country.models import Country | ||
from country.tasks import evaluate_contract_red_flag | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Compute red flag for specific country" | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument("country", nargs="+", type=str) | ||
|
||
def handle(self, *args, **options): | ||
country_code = options["country"][0] | ||
country_code = str(country_code).upper() | ||
country_list = Country.objects.exclude(country_code_alpha_2="gl").values_list( | ||
"country_code_alpha_2", flat=True | ||
parser.add_argument("country", type=str) | ||
|
||
def handle(self, *args, **kwargs): | ||
country_alpha_code = kwargs["country"].upper() | ||
try: | ||
Country.objects.get(country_code_alpha_2=country_alpha_code) | ||
except Exception: | ||
return self.stdout.write("Country alpha code doesnt exist") | ||
evaluate_contract_red_flag.apply_async( | ||
args=(country_alpha_code,), | ||
queue="covid19", | ||
) | ||
|
||
if country_code not in country_list: | ||
self.stderr.write("Country code is invalid.") | ||
return | ||
|
||
country = Country.objects.get(country_code_alpha_2=country_code) | ||
|
||
self.stdout.write(f"Processing Red flag for {country.name}") | ||
|
||
country_tenders = Tender.objects.filter( | ||
country_id=country.id, supplier__isnull=False, buyer__isnull=False | ||
).values("id", "buyer__buyer_name", "supplier__supplier_name", "supplier__supplier_address") | ||
|
||
for tender in country_tenders: | ||
tender_id = tender["id"] | ||
self.stdout.write("Created task for id :" + str(tender_id)) | ||
clear_redflag.apply_async(args=(tender_id,), queue="covid19") | ||
process_redflag6.apply_async(args=(tender_id,), queue="covid19") | ||
process_redflag7.apply_async(args=(tender_id,), queue="covid19") | ||
process_redflag.apply_async(args=(tender_id,), queue="covid19") | ||
|
||
self.stdout.write("Done") | ||
return "Done" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.