def firstRequirement(catalog, bestCategory): bestCategoryId = model.findCategoryid(catalog,bestCategory) if bestCategoryId == -1: return -1 else: result = model.firstRequirement(catalog, bestCategoryId) mergeSortByViews(result) return result
def thirdRequirement(catalog, bestCategory): bestCategoryId = model.findCategoryid(catalog,bestCategory) if bestCategoryId == -1: return -1 else: results = model.thirdRequirement(catalog, bestCategoryId) #results = videoMayor,repsMayor return results
def bestVideosCategoryCountryViews(catalog,bestCountry,bestCategory,numberVideos): catalogCC = initCatalog() bestCategoryid = model.findCategoryid(catalog,bestCategory) if bestCategoryid == -1: return -1 else: catalogCC = model.addvideoFromCatalog(catalog,catalogCC,bestCountry,bestCategoryid) topVideos = lt.newList(datastructure='ARRAY_LIST') if lt.size(catalogCC["videos"]) < numberVideos: return -2 else: for i in range(1, numberVideos + 1): lt.addLast(topVideos, lt.getElement(catalogCC["videos"],i) ) if lt.size(topVideos)==0: return -3 else: return topVideos
def thirdRequirement(catalog, bestCategory): delta_time = -1.0 delta_memory = -1.0 tracemalloc.start() start_time = getTime() start_memory = getMemory() bestCategoryId = model.findCategoryid(catalog, bestCategory) if bestCategoryId == -1: tracemalloc.stop() return -1 else: results = model.thirdRequirement(catalog, bestCategoryId) stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return results[0], results[1], delta_time, delta_memory
def firstRequirement(catalog, bestCategory, bestCountry): delta_time = -1.0 delta_memory = -1.0 tracemalloc.start() start_time = getTime() start_memory = getMemory() bestCategoryId = model.findCategoryid(catalog, bestCategory) if bestCategoryId == -1: tracemalloc.stop() return -1 else: result = model.firstRequirement(catalog, bestCategoryId, bestCountry) mergeSortByViews(result) stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return result, delta_time, delta_memory
def topnVideosCCV(catalog, bestCountry, bestCategory, numberVideos): bestCategoryid = model.findCategoryid(catalog, bestCategory) sortedCatalog = model.catalogSortedByViewsCountyCategory( catalog, bestCountry, bestCategoryid) topnVideosCCV = model.topnVideosByViews(sortedCatalog, numberVideos) return topnVideosCCV