def get_category(): print("Starting Category ThreadPoolExecutor") futures = [] start_date = request.args.get('start_date') end_date = request.args.get('end_date') start_date, end_date = send_dates(start_date, end_date) query = "*%3A*&wt=json&fl=type&fq=date%3A%5B" + start_date + "%20TO%20" + end_date + "%5D&indent=true&facet=true&stats=true&stats.field=status&facet.pivot=type" result = SolrURLConnection.execute_facet_query(query) print("Category complete") director = ExperienceDirector() builder = ConcreteExperienceBuilder() director.builder = builder director.build_category(result, ['type']) return jsonify({'category': builder.customerData.getCategoryData()})
def get_experience(): # task = [task for task in tasks if task['id'] == task_id] # if len(task) == 0: # abort(404) print("Starting Experience Builder ThreadPoolExecutor") print(fromdate) facet_query = [ "*%3A*&wt=json&fl=type&indent=true&facet=true&stats=true&stats.field=status&facet.pivot=status", "*%3A*&wt=json&fl=type&indent=true&facet=true&stats=true&stats.field=status&facet.pivot=type", "*%3A*&wt=json&wt=json&fl=type&indent=true&facet=true&stats=true&stats.field=status&facet.pivot" "=userID,status ", "*%3A*&wt=json&wt=json&fl=type&indent=true&facet=true&stats=true" "&stats.field=status&facet.pivot=response_time " ] experience_query = ["&wt=json&fl=type&indent=true&facet=true&stats=true&stats.field=status&facet.pivot=userID," \ "status ", "&wt=json&fl=type&indent=true&stats=true&stats.field=response_time&facet=true&facet.pivot=userID," \ "response_time," \ "status&facet.field=status&omitHeader=true&group=true&group.field=userID&group.field=status"] agents = 3 new_agent = 3 with Pool(processes=agents) as pool: results = pool.map(execute_solr_url_query_by_facet, facet_query) with Pool(processes=new_agent) as pool: result_experience = pool.map(execute_solr_query_by_response_time, experience_query) # Output the result # print('Result: ' + str(result[1])) # print('Result: ' + str(result[0])) # print('Experience Response Time Result: ' + str(result_experience[1])) # print("All tasks complete") # print('Success 2 Result: ' + str(results[2])) director = ExperienceDirector() builder = ConcreteExperienceBuilder() director.builder = builder director.build_success_rate( results[0]['facet_counts']['facet_pivot']['status'], ['value', 'count']) director.build_uptime(results[0]['facet_counts']['facet_pivot'], ['status']) director.build_category(results[1], ['type']) director.build_good_experience(result_experience[0]['userID,status'], ['OK', 'IF', 'UF']) director.build_average_experience(result_experience[0]['userID,status'], ['OK', 'IF', 'UF']) director.build_bad_experience(result_experience[0]['userID,status'], ['OK', 'IF', 'UF']) good_experience_result = user_experience( builder.customerData.getGoodExperience()) average_experience_result = user_experience( builder.customerData.getAverageExperience()) bad_experience_result = user_experience( builder.customerData.getBadExperience()) good_exp_sorted = sortedlist(good_experience_result) average_exp_sorted = sortedlist(average_experience_result) bad_exp_sorted = sortedlist(bad_experience_result) return jsonify({ 'successRate': builder.customerData.getSuccessData(), 'upTime': builder.customerData.getSuccessData(), 'category': builder.customerData.getCategoryData(), 'goodExperience': good_exp_sorted, 'averageExperience': average_exp_sorted, 'badExperience': bad_exp_sorted })