Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/ilhasoft/weni-engine int…
Browse files Browse the repository at this point in the history
…o develop
  • Loading branch information
BarbosaJackson committed Nov 25, 2021
2 parents 1859fd0 + 981be17 commit 3fb8781
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions connect/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"schedule": schedules.crontab(hour="22", minute=0),
},
"generate_project_invoice": {
"task": "weni.common.tasks.generate_project_invoice",
"task": "connect.common.tasks.generate_project_invoice",
"schedule": schedules.crontab(minute="*/5"),
},
"capture_invoice": {
"task": "weni.common.tasks.capture_invoice",
"task": "connect.common.tasks.capture_invoice",
"schedule": schedules.crontab(hour="8,10,13,15,17", minute=0),
# "schedule": 30,
},
Expand Down
29 changes: 13 additions & 16 deletions connect/common/tasks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from datetime import timedelta, datetime

from django.utils import timezone
import requests
from django.conf import settings
from django.db import transaction
from django.utils import timezone
from google.protobuf.timestamp_pb2 import Timestamp
from grpc._channel import _InactiveRpcError

Expand Down Expand Up @@ -241,22 +240,20 @@ def sync_updates_projects():
classifiers=classifiers_project,
)

if project.organization.organization_billing.last_invoice_date is None:
after = project.organization.created_at.strftime("%Y-%m-%d %H:%M")
else:
after = project.organization.organization_billing.last_invoice_date.strftime("%Y-%m-%d %H:%M")

if project.organization.organization_billing.next_due_date is None:
before = timezone.now().strftime("%Y-%m-%d %H:%M")
else:
before = project.organization.organization_billing.next_due_date.strftime("%Y-%m-%d %H:%M")

contact_count = flow_instance.get_billing_total_statistics(
project_uuid=str(project.flow_organization),
before=Timestamp().FromDatetime(
project.organization.created_at
if project.organization.organization_billing.last_invoice_date is None
else datetime.strptime(
str(project.organization.organization_billing.last_invoice_date),
"%Y-%m-%d",
)
),
after=Timestamp().FromDatetime(
datetime.strptime(
str(project.organization.organization_billing.next_due_date),
"%Y-%m-%d",
)
),
before=before,
after=after
).get("active_contacts")

project.name = str(flow_result.get("name"))
Expand Down

0 comments on commit 3fb8781

Please sign in to comment.