def pioneer_rate_mashups_o(): sql_params = ( ) rows = db_execute(pioneer_rate, sql_params) db_loop_pioneer_rate_to_database(rows, "pioneer_rate_apis_mashups_o") sql_params = ( ) rows = db_execute(pioneer_rate_apis_mashups, sql_params) db_loop_pioneer_rate_apis_mashups(rows, "pioneer_rate_apis_mashups_o")
def api_popularity_rank_snapshot_o(): sql_params = ( ) rows = db_execute(api_popularity_rank, sql_params) #db_loop(rows, "api_popularity_rank_o") axx = analysis_plot.get_stacked_bar_axx(1, 1, 1) # get top apis list top_apis_id = list() top_apis_name = list() #print arrange_developer_sql_length_snapshot() developer_count = analysis_util.get_developer_length(arrange_developer_sql_length_snapshot(), 0) analysis_plot.set_stacked_bar_bottom(developer_count) index_count = 21 index = range(index_count) color_util.create_rgbs(index_count) for i in index: row = rows.fetchone() api_id = row[1] api_name = row[2] top_apis_id.append(api_id) top_apis_name.append(api_name) print top_apis_name # other apis plot other_developer_index = [] other_apis = [] api_count_other_sql = api_deploy_other % str(tuple(top_apis_id)) api_count_other_sql = arrange_developer_sql_snapshot("api_count", api_count_other_sql) print api_count_other_sql api_count_other_rows = db_execute(api_count_other_sql, ()) for api_count_other_row in api_count_other_rows: other_developer_index.append(api_count_other_row[0]) if api_count_other_row[1] == None: #print "*********" other_apis.append(0) else: other_apis.append(api_count_other_row[1]) print other_apis stack_color = 'w' print stack_color analysis_plot.developer_to_api_bar_plot(other_developer_index, other_apis, axx, stack_color, "Other APIs") # top api plot index = range(len(top_apis_id)) for i in index: api_id = top_apis_id[i] api_name = top_apis_name[i] api_color = color_util.get_rgb(i) developer_index = [] apis_is = [] api_count_sql = arrange_developer_sql_snapshot("api_count", api_deploy_i) api_count_rows = db_execute(api_count_sql, (api_id, )) for api_row in api_count_rows: #print api[0], api[1] developer_index.append(api_row[0]) if api_row[1] == None: apis_is.append(0) else: apis_is.append(api_row[1]) analysis_plot.developer_to_api_bar_plot(developer_index, apis_is, axx, api_color, api_name) analysis_plot.developer_to_api_bar_legend(axx, top_apis_name)
def db_loop_api_usage(c, developer_number, cut_number, file_name): global analysis_path txt = open(analysis_path+file_name+".txt", "w") head = "index" for colum_name in c.description: head = head + ", \t"+str(colum_name[0]) head = head + ", \tdeveloper_used" head = head + ", \tmashup_used" head = head + ", \tlow_end_mashup" head = head + ", \thigh_end_mashup" print head txt.write(head+"\n") i = 1 for row in c: out = str(i) for r in row: out = out+"\t"+str(r) #print out api_id = row[0] #print api_id sql_params = (api_id, ) rows = db_execute(api_developer_count, sql_params) developer_count = rows.fetchone()[0] sql_params = (api_id, ) rows = db_execute(api_mashup_count, sql_params) mashup_count = rows.fetchone()[0] #print developer_count, mashup_count out = out+"\t"+str(developer_count)+"\t"+str(mashup_count) sql_params = (api_id, cut_number, ) rows = db_execute(api_developer_count_condition_small, sql_params) api_developer_small = rows.fetchone()[0] sql_params = (api_id, cut_number, ) rows = db_execute(api_developer_count_condition_large, sql_params) api_developer_large = rows.fetchone()[0] #print api_developer_small, api_developer_large out = out+"\t"+str(api_developer_small)+"\t"+str(api_developer_large) #print developer_condition_count print out txt.write(out+"\n") i = i+1
def get_developer_relationship( sql_params, temp_sql, temp_content_name, file_name, plot_function = analysis_plot.developer_to_mashup_line_plot ): rows = db_execute(temp_sql, sql_params) db_loop(rows, file_name) sql = arrange_developer_sql(temp_content_name, temp_sql) rows = db_execute(sql, sql_params) developers = [] contents = [] for row in rows: #print row[0] developers.append(row[0]) contents.append(row[1]) #developers = range(len(mashups)) #mashups = db_loop_for_array(rows, "developer_mashup_count_o", 2) #print developers #print #print mashups plot_function(developers, contents)
def api_db_loop(c, file_name): global analysis_path txt = open(analysis_path+file_name+".txt", "w") head = "index" for colum_name in c.description: head = head + ", \t"+str(colum_name[0]) head = head + ", \tprotocols" head = head + ", \tdataformats" head = head + ", \t" head = head + ", \tmashup_full_url" head = head + ", \tmashup_if_free" head = head + ", \tmashup_other_comments" print head txt.write(head+"\n") i = 1 for row in c: out = str(i) for r in row: out = out+"\t"+str(r) api_id = row[5] sql_params = (api_id, ) rows_p = db_execute(api_protocol, sql_params) protocols = element_loop(rows_p) out = out+"\t"+protocols rows_d = db_execute(api_dataformats, sql_params) dataformats = element_loop(rows_d) out = out+"\t"+dataformats print out out = out+"\t" mashup_part_url = row[3] mashup_full_url = "http://www.programmableweb.com"+row[3] out = out+"\t"+mashup_full_url out = out+"\t" out = out+"\t" print out txt.write(out+"\n") i = i+1
def developer_index_tmp_table_prepare(): global conn analysis_util.developer_index_tmp_table_init() sql_params = ( ) #print developer_index_mashups i = 1 rows = db_execute(developer_index_tmp, sql_params) author_id_rank = [] for row in rows: author_id_rank.append(row[0]) rows.close() for author_id in author_id_rank: #print author_id developer_index = i developer_id = author_id analysis_util.developer_index_tmp_table_update(developer_index, developer_id) i += 1 analysis_util.developer_index_tmp_table_check()
def developer_api_mashup_count_o(developer_number): sql_params = (developer_number, ) rows = db_execute(developer_api_mashup_count, sql_params) analysis_util.db_loop(rows, "CACM_developer_api__mashup_count_"+str(developer_number)+"_o")
def api_usage_o(developer_number, cut_number): sql_params = (developer_number, ) rows = db_execute(used_api, sql_params) db_loop_api_usage(rows, developer_number, cut_number, "CACM_api_usage_"+str(cut_number)+"_"+str(developer_number)+"_o")
def developer_mashup_o(developer_number): sql_params = (developer_number, ) rows = db_execute(developer_mashup, sql_params) db_loop(rows, "CACM_developer_mashup_"+str(developer_number)+"_o")
def developer_mashup_api_category_dataformat_o(developer_number): sql_params = (developer_number, ) rows = db_execute(developer_mashup_api_category_dataformat, sql_params) api_db_loop(rows, "CACM_developer_mashup_api_category_dataformat_"+str(developer_number)+"_o")
def apis_has_developer_count_o(): sql_params = ( ) rows = db_execute(apis_has_developer_count, sql_params) db_loop(rows, "apis_has_developer_count_o")
def developer_to_api_o(): sql_params = ( ) rows = db_execute(developer_to_api, sql_params) db_loop(rows, "developer_to_api_o")
def developer_api_time_o(): sql_params = ( ) rows = db_execute(develop_mashup, sql_params) db_loop_time(rows, "developer_api_time_o")
def pioneer_rate_o(): sql_params = ( ) rows = db_execute(pioneer_rate, sql_params) db_loop_pioneer_rate(rows, "pioneer_rate_o")
def api_developer_index_o(): sql_params = ( ) rows = db_execute(api_developer_index, sql_params) db_loop_api_developer_index(rows, "api_developer_index_o")