Exemple #1
0
def get_daily_tank_storage(conn, year=2013, month=1, min_qty=10000, max_qty=15000):
    i = get_next_pk(conn, 'test_daily_tank_storage', 'daily_tank_storage_key')
    tanks = query(conn, 'select storage_tank_key as id from storage_tanks')
    ids = [tank['ID'] for tank in tanks]
    for day in days_in_month(year=year, month=month):
        for tank_id in ids:   
            yield (i, tank_id, random.randint(min_qty, max_qty), str(day))
            i += 1
Exemple #2
0
def get_daily_sale(conn, year=2013, month=1, total_bias=30000, daily_bias=1000):
    row = unique(conn, '''
        select sum(cl.qty) as total
        from 
        (select * from test_contracts 
        where year(contract_date) = ? and month(contract_date) = ?) c
        left join test_contract_lines cl
        on c.contract_key = cl.contract_key    
    ''', year, month)
    total = row['TOTAL']
    actual = random.randint(total - total_bias, total + total_bias)
    expected_daily_qty = actual / count_days(year, month)
    i = get_next_pk(conn, 'test_daily_sale', 'daily_sale_key')
    for day in days_in_month(year, month):
        yield (i, 0, 0,
               0, 12, random.randint(expected_daily_qty - daily_bias, expected_daily_qty + daily_bias),
               "this is a reminder", str(day))
        i += 1
Exemple #3
0
def get_date_dimensions(year=2013):
    for month in range(1, 13):
        for day in days_in_month(year, month):
            c = day.isocalendar()
            yield (str(day), c[1], c[2])
Exemple #4
0
def get_daily_sales(min_qty=1000, max_qty=4000, year=2013, month=1):
    for day in days_in_month(year, month):
        yield (str(day), (random.randint(min_qty, max_qty)))