Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Sales and Support call counter #287

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ Hint: Look at Extra Tips (at the bottom of README) for a more detailed guide on

```

[//]: # (has_booked_call )
[//]: # (has_signed_up )
support_call_count: Numerical
sales_call_count: Numerical
tc2_status: Large text
tc2_cligency_url: Large text
hermes_id: Numerical
Expand Down
3 changes: 2 additions & 1 deletion app/admin/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ class CompanyResource(Model):
'paid_invoice_count',
'estimated_income',
'currency',
'has_booked_call',
'sales_call_count',
'support_call_count',
'has_signed_up',
'utm_campaign',
'utm_source',
Expand Down
3 changes: 0 additions & 3 deletions app/callbooker/_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ async def get_or_create_contact_company(event: CBSalesCall) -> tuple[Company, Co
await company.save()
contact = contact or await get_or_create_contact(company, event)
app_logger.info(f'Got company {company} and contact {contact} from {event}')

company.has_booked_call = True
await company.save()
return company, contact


Expand Down
4 changes: 4 additions & 0 deletions app/callbooker/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ async def sales_call(event: CBSalesCall, tasks: BackgroundTasks):
else:
meeting.deal = deal
await meeting.save()
company.sales_call_count += 1
await company.save()
tasks.add_task(pd_post_process_sales_call, company=company, contact=contact, deal=deal, meeting=meeting)
return {'status': 'ok'}

Expand All @@ -59,6 +61,8 @@ async def support_call(event: CBSupportCall, tasks: BackgroundTasks):
return JSONResponse({'status': 'error', 'message': str(e)}, status_code=400)
else:
await meeting.save()
company.support_call_count += 1
await company.save()
tasks.add_task(pd_post_process_support_call, contact=contact, meeting=meeting)
return {'status': 'ok'}

Expand Down
3 changes: 2 additions & 1 deletion app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ class Company(HermesModel):
paid_invoice_count = fields.IntField(default=0)
estimated_income = fields.CharField(max_length=255, null=True)
currency = fields.CharField(max_length=255, null=True)
has_booked_call = fields.BooleanField(default=False)
sales_call_count = fields.IntField(default=0)
support_call_count = fields.IntField(default=0)
has_signed_up = fields.BooleanField(default=False)
utm_campaign = fields.CharField(max_length=255, null=True)
utm_source = fields.CharField(max_length=255, null=True)
Expand Down
15 changes: 15 additions & 0 deletions migrations/models/8_20240913013916_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from tortoise import BaseDBAsyncClient


async def upgrade(db: BaseDBAsyncClient) -> str:
return """
ALTER TABLE "company" ADD "support_call_count" INT NOT NULL DEFAULT 0;
ALTER TABLE "company" ADD "sales_call_count" INT NOT NULL DEFAULT 0;
ALTER TABLE "company" DROP COLUMN "has_booked_call";"""


async def downgrade(db: BaseDBAsyncClient) -> str:
return """
ALTER TABLE "company" ADD "has_booked_call" BOOL NOT NULL DEFAULT False;
ALTER TABLE "company" DROP COLUMN "support_call_count";
ALTER TABLE "company" DROP COLUMN "sales_call_count";"""
Loading
Loading