예제 #1
0
def get_longest_name_id(table):
    longest = [["", None]]

    for i in range(len(table)):
        if len(table[i][1]) > len(longest[0][0]):
            longest = [[table[i][1], table[i][0]]]
        elif len(table[i][1]) == len(longest[0][0]):
            longest.append([table[i][1], table[i][0]])

    lst = common.list_order(longest)

    return lst[0][1]
def get_lowest_price_item_id(table):
    lowest_price_id = []
    lowest_price = int(table[0][2])

    for i in range(len(table)):
        if int(table[i][2]) < lowest_price:
            lowest_price = int(table[i][2])
    
    for i in range(len(table)):
        if int(table[i][2]) == lowest_price:
            lowest_price_id.append(table[i][0])

    lowest_price_id = list(reversed(common.list_order(lowest_price_id)))

    return lowest_price_id[0]
def get_item_title_sold_last_from_table(table):
    last_sold_id = ""
    dates = []

    for line in table:
        temp = []
        temp.append(int(line[5]))
        temp.append(int(line[3]))
        temp.append(int(line[4]))
        dates.append(temp)

    dates = list(reversed(common.list_order(dates)))
    
    for line in table:
        if dates[0][0] == int(line[5]) and dates[0][1] == int(line[3]) and dates[0][2] == int(line[4]):
            last_sold_id = str(line[1])
            return last_sold_id
def get_item_id_sold_last():
    last_sold_id = ""
    table = data_manager.get_table_from_file("sales/sales.csv")
    dates = []

    for line in table:
        temp = []
        temp.append(int(line[5]))
        temp.append(int(line[3]))
        temp.append(int(line[4]))
        dates.append(temp)

    dates = list(reversed(common.list_order(dates)))
    
    for line in table:
        if dates[0][0] == int(line[5]) and dates[0][1] == int(line[3]) and dates[0][2] == int(line[4]):
            last_sold_id = str(line[0])
            return last_sold_id