def generate_billing_table(user_table,company_dist,start_monetize_rate,end_monetize_rate,start_churn_rate,end_churn_rate,contract_length,
contract_range,start,end):
    
    companies = get_company_ids(user_table)
    companies = add_company_type(companies,company_dist)
    
    billing_table = []
    for c in companies:
        company_type = c[3]
        start_date = c[2]
        next_month = start_date + timedelta(days=32)
        first_billing_date = next_month.replace(day=1,hour=0,minute=0,second=0,microsecond=0)
        
        monetize_date = get_monetize_date(company_type,first_billing_date,start_monetize_rate,end_monetize_rate,start,end)
        
        if monetize_date != 0:
            contract_amount = get_contract_amount(0,contract_range)
            entry = [c[0],monetize_date,h.ts(monetize_date),contract_amount,contract_length]
            billing_table.append(entry)
            
            next_billing_period = get_next_billing_period(monetize_date,contract_length)
            
            renew = check_renewal(company_type,start_churn_rate,end_churn_rate,next_billing_period,start,end)
            
            while next_billing_period < end and renew == True:
                
                contract_amount = get_contract_amount(contract_amount,contract_range)
                
                entry = [c[0],next_billing_period,h.ts(next_billing_period),contract_amount,contract_length]
                billing_table.append(entry)
                next_billing_period = get_next_billing_period(next_billing_period,contract_length)
                print 'made it here'
    
    return billing_table
def generate_billing_table(user_table, company_dist, start_monetize_rate,
                           end_monetize_rate, start_churn_rate, end_churn_rate,
                           contract_length, contract_range, start, end):

    companies = get_company_ids(user_table)
    companies = add_company_type(companies, company_dist)

    billing_table = []
    for c in companies:
        company_type = c[3]
        start_date = c[2]
        next_month = start_date + timedelta(days=32)
        first_billing_date = next_month.replace(day=1,
                                                hour=0,
                                                minute=0,
                                                second=0,
                                                microsecond=0)

        monetize_date = get_monetize_date(company_type, first_billing_date,
                                          start_monetize_rate,
                                          end_monetize_rate, start, end)

        if monetize_date != 0:
            contract_amount = get_contract_amount(0, contract_range)
            entry = [
                c[0], monetize_date,
                h.ts(monetize_date), contract_amount, contract_length
            ]
            billing_table.append(entry)

            next_billing_period = get_next_billing_period(
                monetize_date, contract_length)

            renew = check_renewal(company_type, start_churn_rate,
                                  end_churn_rate, next_billing_period, start,
                                  end)

            while next_billing_period < end and renew == True:

                contract_amount = get_contract_amount(contract_amount,
                                                      contract_range)

                entry = [
                    c[0], next_billing_period,
                    h.ts(next_billing_period), contract_amount, contract_length
                ]
                billing_table.append(entry)
                next_billing_period = get_next_billing_period(
                    next_billing_period, contract_length)
                print 'made it here'

    return billing_table
Esempio n. 3
0
def create_login_event(user_id, occurred_at, user_type):
    formatted_occurred_at = h.ts(occurred_at)
    event = [
        user_id, occurred_at, formatted_occurred_at, 'engagement', 'login',
        user_type
    ]

    return event
def generate_user(date,user_id):
    
    hour = h.create_hour()
    minute = h.create_minute()
    second = h.create_minute()
    
    create_date = datetime.datetime(date.year,date.month,date.day,hour,minute,second,0)
    formatted_date = h.ts(create_date)
    
    row = [user_id,create_date,formatted_date]
    
    return row
def generate_event(e,event_list,event_dist,last_event,last_event_time):
    time_between = random.normalvariate(30,30/5)
    time_between = max(int(time_between),2)
    
    diff_s = timedelta(seconds=1)
    occurred_at = last_event_time + (time_between * diff_s)
    formatted_occurred_at = h.ts(occurred_at)
    
    user_id = e[0]
    user_type = e[5]
    
    event_name = pick_event(event_list,event_dist,last_event)
    
    event = (user_id,occurred_at,formatted_occurred_at,'engagement',event_name,user_type)
    
    return event
Esempio n. 6
0
def make_event(user,event_number,events,step_time,last_event_time):
    user_id = user[0]
    e = event_number + 1
    
    time_between = random.normalvariate(step_time,step_time/5)
    time_between = max(int(time_between),2)
    
    diff_s = timedelta(seconds=1)
    
    occurred_at = last_event_time + (time_between * diff_s)
    formatted_occurred_at = h.ts(occurred_at)
    
    event_name = events[e]
    
    event = [user_id,occurred_at,formatted_occurred_at,'signup_flow',event_name]
    
    return event
Esempio n. 7
0
def generate_funnel_event(e, i, event_list, last_event_time):
    user_id = e[0]
    user_type = e[5]

    time_between = random.normalvariate(30, 30 / 5)
    time_between = max(int(time_between), 2)

    diff_s = timedelta(seconds=1)
    occurred_at = last_event_time + (time_between * diff_s)
    formatted_occurred_at = h.ts(occurred_at)

    event_name = event_list[i]

    event = (user_id, occurred_at, formatted_occurred_at, 'engagement',
             event_name, user_type)

    return event
Esempio n. 8
0
def generate_signup_events(user_table,events,start_date,end_date,start_flow,end_flow,step_time,weekend_ratio):
    
    day_diff = h.get_day_diff(start_date,end_date)
    
    updated_user_table = []
    event_table = []
    
    for user in user_table:
        user_id = user[0]
        created_at = user[1]
        created_at_formatted = h.ts(created_at)
        
        dow = created_at.weekday()
        
        since_start = h.get_day_diff(start_date,created_at)
        
        step1 = [user_id,created_at,created_at_formatted,'signup_flow','create_user']
        event_table.append(step1)
        
        last_event_time = created_at
        
        for e in range(len(start_flow)):
            
            stepX = create_signup_event(e,user,events,start_flow,end_flow,step_time,since_start,day_diff,weekend_ratio,dow,last_event_time)
            
            if stepX[0] == False:
                activated_at = ''
                break
            
            else:
                activated_at = stepX[1][2]
                event_table.append(stepX[1])
                last_event_time = stepX[1][1]
            
        updated_user = update_user(user,activated_at)
        updated_user_table.append(updated_user)
    
    return [event_table,updated_user_table]
Esempio n. 9
0
                if meta['video_codec_tag_string'] == 'avc1':
                    action = {"action": "convert_delete",
                              "reason": "probably iphone6 video " + meta.__str__()}
                elif 'hvc' in meta['video_codec_tag_string']:
                    # iphone 8 is already in h265 -> do not touch this
                    pass
                else:
                    action = {"action": "convert_delete",
                              "reason": "source unknown but h264 might downsize it " + meta.__str__()}

        # compose action
        if action is not None:
            fullaction = {"folder": root,
                          "file": name,
                          "size": get_file_size_mb(fpfn, 2)}
            fullaction.update(action)
            actionlist.append(fullaction)

# write action output
df = pd.DataFrame(actionlist)

fn = s.output_filename
if s.prefix_with_timestamp:
    fn = ts() + " " + fn
fpfn = os.path.join(s.output_folder, fn)
df.to_excel(fpfn)

os.startfile(fpfn)

print("finished.")
def create_login_event(user_id,occurred_at,user_type):
    formatted_occurred_at = h.ts(occurred_at)
    event = [user_id,occurred_at,formatted_occurred_at,'engagement','login',user_type]
    
    return event