Exemplo n.º 1
0
def reload_event():
    start = time.time()
    table = _get_database().Table(os.environ["DB_TABLE_NAME"])
    response = table.scan()
    #ここのタイプはおそらくリスト
    exist_item_list = response["Items"]
    #これもおそらくリスト
    new_item_list = botocal.Get_cal().assign_to_dics()
    amount_of_already_exist = 0
    amount_of_change = 0
    check_exist = 0
    add_list = []
    for put_part in new_item_list:
        #書き込みたいファイルのuidを定義
        put_uid = put_part["uid"]
        for exist_part in exist_item_list:
            exist_uid = exist_part['uid']

            #データが存在するか
            if put_uid == exist_uid:
                amount_of_already_exist += 1
                check_exist = 1
            #存在しないなら追加
                
        if check_exist == 0:
            table.put_item(Item=put_part)
            add_list.append(put_part)
            amount_of_change +=1
        check_exist = 0        
    end = time.time()
    return add_list,len(new_item_list),amount_of_change,amount_of_already_exist,end-start
Exemplo n.º 2
0
def load_all_events():
    #table = _get_database().Table(os.environ["DB_TABLE_NAME"])
    #response = table.scan()
    #return response['Items']

    #cwd = os.getcwd()
    #datapath = os.path.join(cwd,'data.json')
    #with open(datapath) as file:
    #    return json.load(file)
    return botocal.Get_cal().assign_to_dics()
Exemplo n.º 3
0
def update_event():
    start = time.time()
    table = _get_database().Table(os.environ["DB_TABLE_NAME"])
    response = table.scan()
    #ここのタイプはおそらくリスト
    exist_item_list = response["Items"]
    #これもおそらくリスト
    new_item_list = botocal.Get_cal().assign_to_dics()
    amount_of_already_exist = 0 
    amount_of_update = 0
    check_exist = 0
    add_list = []
    for exist_part in exist_item_list:
        #書き込みたいファイルのuidを定義
        exist_uid = exist_part['uid']
        for put_part in new_item_list:
            put_uid = put_part["uid"]

            #データが存在するか
            if put_uid == exist_uid:
                amount_of_already_exist += 1
                check_exist = 1
            elif exist_uid == "setting":
                check_exist = 1
                
            #存在しないなら追加
                
        if check_exist == 0:
            result = table.delete_item(
                    Key={
                        "uid":exist_uid,
                        },
                    ReturnValues="ALL_OLD"
                    )
            add_list.append(exist_part)
            amount_of_update +=1
        check_exist = 0 
    end = time.time()
    return add_list,len(new_item_list),amount_of_update,amount_of_already_exist,end-start