Skip to content

Commit

Permalink
Add "INSTANCE_CREATE_EVENT" and "INSTANCE_UPDATE_EVENT" common tags
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisRayM committed Aug 14, 2020
1 parent d355505 commit 5ebbffd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions onadata/libs/utils/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from django.utils import timezone

from onadata.apps.logger.models import Instance
from onadata.libs.utils.common_tags import (
INSTANCE_CREATE_EVENT, INSTANCE_UPDATE_EVENT)


_segment = False
Expand Down Expand Up @@ -95,9 +97,9 @@ def get_event_name(self) -> str:
if isinstance(self.tracked_obj, Instance) and not event_name:
last_edited = self.tracked_obj.last_edited
if last_edited and last_edited > self.event_start:
event_name = 'Submission updated'
event_name = INSTANCE_UPDATE_EVENT
else:
event_name = 'Submission created'
event_name = INSTANCE_CREATE_EVENT
return event_name

def get_event_label(self) -> str:
Expand Down
3 changes: 3 additions & 0 deletions onadata/libs/utils/common_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,6 @@
'_submission_time',
'_xform_id'
]

INSTANCE_CREATE_EVENT = 'Submission created'
INSTANCE_UPDATE_EVENT = 'Submission updated'
8 changes: 5 additions & 3 deletions onadata/libs/utils/csv_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
celery_state_to_status)
from onadata.libs.utils.common_tags import (MULTIPLE_SELECT_TYPE, EXCEL_TRUE,
XLS_DATE_FIELDS,
XLS_DATETIME_FIELDS, UUID, NA_REP)
XLS_DATETIME_FIELDS, UUID, NA_REP,
INSTANCE_CREATE_EVENT,
INSTANCE_UPDATE_EVENT)
from onadata.libs.utils.common_tools import report_exception
from onadata.libs.utils.dict_tools import csv_dict_to_nested_dict
from onadata.libs.utils.logger_tools import (OpenRosaResponse, dict2xml,
Expand Down Expand Up @@ -441,10 +443,10 @@ def submit_csv(username, xform, csv_file, overwrite=False):
}
if added_submissions > 0:
tracking_properties['value'] = added_submissions
event_name = 'Submission created'
event_name = INSTANCE_CREATE_EVENT
if inserts > 0:
tracking_properties['value'] = inserts
event_name = 'Submission updated'
event_name = INSTANCE_UPDATE_EVENT

if event_name:
analytics.track(
Expand Down

0 comments on commit 5ebbffd

Please sign in to comment.