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.
CPA-295 Set Buyer / Supplier summary
- [x] Create buyer and supplier summary commands/tasks like `summarize_buyer` and `summarize_supplier` - [x] Command will take buyer id or supplier id as parameter - [x] Add a `summary` JSON column in `country_buyer` and `country_supplier` tables - [x] Calculate summary information of buyer and supplier like: - [x] number of contracts `tender_count` - [x] total `amount_usd` - [x] total `amount_local` - [x] number of unique suppliers `supplier_count` OR buyers `buyer_count` - [x] number of Product categories `product_count` - [x] total of contracts with red flag `red_flag_tender_count` - [x] percentage of contracts with red flag `red_flag_tender_percentage` - [x] Added required line to solve error in tender edit
- Loading branch information
Suyoj Man Tamrakar
committed
May 6, 2021
1 parent
c082d5c
commit 8666a4f
Showing
5 changed files
with
120 additions
and
43 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from country.models import Buyer, Country | ||
from country.tasks import summarize_buyer | ||
|
||
|
||
class Command(BaseCommand): | ||
def add_arguments(self, parser): | ||
parser.add_argument("country", type=str) | ||
|
||
def handle(self, *args, **kwargs): | ||
country_alpha_code = kwargs["country"] | ||
try: | ||
country = Country.objects.get(country_code_alpha_2=country_alpha_code) | ||
except Exception: | ||
return self.stdout.write("Country alpha code doesnt exist") | ||
buyers = Buyer.objects.filter(tenders__country=country) | ||
for buyer in buyers: | ||
self.stdout.write("Created tasks for buyer_id" + str(buyer.id)) | ||
summarize_buyer.apply_async(args=(buyer.id,), queue="covid19") |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from country.models import Country, Supplier | ||
from country.tasks import summarize_supplier | ||
|
||
|
||
class Command(BaseCommand): | ||
def add_arguments(self, parser): | ||
parser.add_argument("country", type=str) | ||
|
||
def handle(self, *args, **kwargs): | ||
country_alpha_code = kwargs["country"] | ||
try: | ||
country = Country.objects.get(country_code_alpha_2=country_alpha_code) | ||
except Exception: | ||
return self.stdout.write("Country alpha code doesnt exist") | ||
suppliers = Supplier.objects.filter(tenders__country=country) | ||
for supplier in suppliers: | ||
self.stdout.write("Created tasks for supplier_id" + str(supplier.id)) | ||
summarize_supplier.apply_async(args=(supplier.id,), queue="covid19") |
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