Exemple #1
0
 def get_active_recent(domain, monthspan):
     months = (domain.internal.experienced_threshold
               or DEFAULT_EXPERIENCED_THRESHOLD) - 1
     threshold_month = add_months(monthspan.startdate.year,
                                  monthspan.startdate.month, -months)
     first_month = datetime.date(day=1,
                                 year=threshold_month[0],
                                 month=threshold_month[1])
     all_users, users_dict, sms = active_mobile_users(
         domain, first_month, monthspan.computed_enddate)
     return set(users_dict.keys()) | sms
Exemple #2
0
 def classify_users(domain, monthspan):
     performing_users = set()
     experienced_users = set()
     eligible_forms = 0
     all_users, user_forms, sms = active_mobile_users(domain, monthspan.startdate, monthspan.computed_enddate)
     user_query = MALTRow.objects.filter(domain_name=domain).filter(month__lte=monthspan.startdate)\
         .values('user_id', 'month').distinct()
     user_months = defaultdict(int)
     for entry in user_query:
         user_months[entry['user_id']] += 1
     for user in all_users:
         if user_forms.get(user, 0) >= \
                 (domain.internal.performance_threshold or DEFAULT_PERFORMANCE_THRESHOLD):
             performing_users.add(user)
         if user_months.get(user, 0) >= \
                 (domain.internal.experienced_threshold or DEFAULT_EXPERIENCED_THRESHOLD):
             experienced_users.add(user)
     for user in performing_users & experienced_users:
         eligible_forms += user_forms.get(user)
     return UserCategories(set(user_forms.keys()), performing_users,
                           experienced_users, all_users, sms, eligible_forms)
Exemple #3
0
 def get_active_recent(domain, monthspan):
     months = (domain.internal.experienced_threshold or DEFAULT_EXPERIENCED_THRESHOLD) - 1
     threshold_month = add_months(monthspan.startdate.year, monthspan.startdate.month, -months)
     first_month = datetime.date(day=1, year=threshold_month[0], month=threshold_month[1])
     all_users, users_dict, sms = active_mobile_users(domain, first_month, monthspan.computed_enddate)
     return set(users_dict.keys()) | sms