{"action":"created","issue":{"url":"https://api.github.com/repos/Tribler/tribler/issues/2216","repository_url":"https://api.github.com/repos/Tribler/tribler","labels_url":"https://api.github.com/repos/Tribler/tribler/issues/2216/labels{/name}","comments_url":"https://api.github.com/repos/Tribler/tribler/issues/2216/comments","events_url":"https://api.github.com/repos/Tribler/tribler/issues/2216/events","html_url":"https://github.com/Tribler/tribler/issues/2216","id":155500710,"number":2216,"title":"IO numbers of functions using DB stuff","user":{"login":"lfdversluis","id":3618917,"avatar_url":"https://avatars.githubusercontent.com/u/3618917?v=3","gravatar_id":"","url":"https://api.github.com/users/lfdversluis","html_url":"https://github.com/lfdversluis","followers_url":"https://api.github.com/users/lfdversluis/followers","following_url":"https://api.github.com/users/lfdversluis/following{/other_user}","gists_url":"https://api.github.com/users/lfdversluis/gists{/gist_id}","starred_url":"https://api.github.com/users/lfdversluis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lfdversluis/subscriptions","organizations_url":"https://api.github.com/users/lfdversluis/orgs","repos_url":"https://api.github.com/users/lfdversluis/repos","events_url":"https://api.github.com/users/lfdversluis/events{/privacy}","received_events_url":"https://api.github.com/users/lfdversluis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"lfdversluis","id":3618917,"avatar_url":"https://avatars.githubusercontent.com/u/3618917?v=3","gravatar_id":"","url":"https://api.github.com/users/lfdversluis","html_url":"https://github.com/lfdversluis","followers_url":"https://api.github.com/users/lfdversluis/followers","following_url":"https://api.github.com/users/lfdversluis/following{/other_user}","gists_url":"https://api.github.com/users/lfdversluis/gists{/gist_id}","starred_url":"https://api.github.com/users/lfdversluis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lfdversluis/subscriptions","organizations_url":"https://api.github.com/users/lfdversluis/orgs","repos_url":"https://api.github.com/users/lfdversluis/repos","events_url":"https://api.github.com/users/lfdversluis/events{/privacy}","received_events_url":"https://api.github.com/users/lfdversluis/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2016-05-18T13:26:14Z","updated_at":"2016-05-22T13:46:08Z","closed_at":null,"body":"Check this for the three database managers and aggregate the numbers.\r\n\r\nIncluding:\r\n\r\n- How many functions use cursors\r\n- How many of these call e.g. dispersy or GUI items"},"comment":{"url":"https://api.github.com/repos/Tribler/tribler/issues/comments/220833318","html_url":"https://github.com/Tribler/tribler/issues/2216#issuecomment-220833318","issue_url":"https://api.github.com/repos/Tribler/tribler/issues/2216","id":220833318,"user":{"login":"lfdversluis","id":3618917,"avatar_url":"https://avatars.githubusercontent.com/u/3618917?v=3","gravatar_id":"","url":"https://api.github.com/users/lfdversluis","html_url":"https://github.com/lfdversluis","followers_url":"https://api.github.com/users/lfdversluis/followers","following_url":"https://api.github.com/users/lfdversluis/following{/other_user}","gists_url":"https://api.github.com/users/lfdversluis/gists{/gist_id}","starred_url":"https://api.github.com/users/lfdversluis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lfdversluis/subscriptions","organizations_url":"https://api.github.com/users/lfdversluis/orgs","repos_url":"https://api.github.com/users/lfdversluis/repos","events_url":"https://api.github.com/users/lfdversluis/events{/privacy}","received_events_url":"https://api.github.com/users/lfdversluis/received_events","type":"User","site_admin":false},"created_at":"2016-05-22T13:46:07Z","updated_at":"2016-05-22T13:46:07Z","body":"# Dispersy/database.py\r\n\r\n### execute function\r\n`community.py.Community._dispersy_claim_sync_bloom_filter_modulo` -> uses the execute function three times. One can be refactored by a fetchone probably, the other two by fetchall\r\n`idem._download_master_member_identity` -> can be refactored by a fetchone\r\n`idem._initialize_timeline` -> loops over cursor, can be replaced by fetchall\r\n`idem._select_and_fix` -> loops over cursor. Can be replaced by fetchall\r\n`idem.dispersy_auto_load` -> ignores cursor\r\n`idem.dispersy_auto_load` -> can be refactored by using fetchone\r\n`idem.get_master_members` -> **weird function** that applies a reference to the execute function to a return statement. Quite ugly/complex return statement too.\r\n`idem.get_member` -> can be replaced by a fetchone\r\n`idem.initialize` -> several usages of execute, can be refactored with fetchone fetchall and functions that return none (just execute the query) from the db manager.\r\n`idem.update_global_time` -> ignores the cursor\r\n\r\n`community.HardKilledCommunity.initialize` -> can be refactored by using a fetchone and return that value from the dbmanager\r\n\r\n`dispersy.Dispersy._check_full_sync_distribution_batch` -> also gets a reference to the execute function and applies it in a loop. Will require refactoring by using a DeferredList or something alike.\r\n`idem._is_duplicate_sync_message` -> two are fetching data from the cursor and 1 line ignores it\r\n`idem._store` -> 1 ignore case, 2 fetchone, 2 fetchall and a loop that calls execute which also does a fetchone.\r\n`idem.check_double_member_and_global_time` -> one fetchall and one that gets ignored\r\n`idem.get_community` -> fetches tuple from cursor, can be refactored with fetchone\r\n`idem.get_last_message` -> fetches number from tuple, can be refactored using fetchone\r\n`idem.get_member` -> 3 lines that fetch items 2 ignoring the cursor\r\n`idem.get_member_from_database_id` -> fetches number from tuple, can be refactored using fetchone\r\n`idem.get_message` ->  fetches data from tuple, can be refactored using fetchone\r\n`idem.load_message` ->  fetches data from tuple, can be refactored using fetchone\r\n`idem.load_message_by_packetid` -> fetches data from tuple, can be refactored using fetchone\r\n`idem.reclassify_community` -> 1 line that ignores the cursor and one that fetches data\r\n`idem.sanity_check` -> 2 loops that will need fetchall, 3 lines that fetch a tuple and 2 lines that ignore the cursor\r\n`idem.sanity_check.select` -> a line that can be refactored by using fetchall\r\n\r\n`dispersydatabase.DispersyDatabase.check_community_database` -> 2 fetchone cases, one line that ignores the cursor and 4 fetchall that loop over data\r\n`idem.check_database` -> 1 loop, 2 fetch data from tuple and 1 line that ignores the cursor.\r\n\r\n`allchannelcommunity.community._get_packet_from_dispersy_id`->fetches data from a cursor tuple, can be refactored by a fetchone\r\n`idem.check_votecast` -> performs the execute in a loop, ignores the cursor\r\n\r\n`Channelcommunity.community._get_latest_channel_message` -> fetch data from a tuple, can be refactored with a fetchone\r\n`idem._get_packet_id` -> fetches data from a tuple, can be refactored by a fetchone\r\n`channelcommunity.channelconversion._get_message` -> fetches data from a tuple, can be refactored by a fetchone\r\n\r\n`Searchcommunity.community.Searchcommunity._get_packet_from_dispersy_id` -> fetches data from a tuple, can be refactored by a fetchone\r\n\r\n`Community.community._claim_master_member_sequence_number` -> fetches data from a tuple, can be refactored by a fetchone\r\n`idem._get_packets_for_bloomfilters` -> **interesting case** as it returns a generator that gets items from a cursor.  Can probably refactored by using a fetchall and yield one item per time.\r\n`idem._update_timerange` -> loops over elements in a cursor.\r\n`idem.check_undo` -> 2 lines that fetch data from a tuple on that loops over a cursor\r\n`idem.create_undo` -> 1 line that fetches a tuple and one that loops over a cursor\r\n`idem.fetch_packets` -> loops over a cursor\r\n`idem.initialize` -> ignores the cursor from execue\r\n`idem.on_destroy_community` -> 2 lines that fetch a tuple, 2 lines that ignore the cursor\r\n`idem.on_missing_identity` -> 2 loops over a cursor\r\n`idem.on_missing_message` -> one line that fetches a tuple\r\n`idem.on_missing_proof` -> one line that fetches a tuple.\r\n\r\n`community.Trackercommunity.dispersy_cleanup_community` -> uses the execute in a loop where a tuple is being fetches with next().\r\n\r\n`test_torrent_upgrade_63_64` -> two lines that conver a cursor to a list.\r\n\r\n**note**\r\nThere are 63 probably usages indicated by my PyCharm IDE. I did not check these.\r\n\r\n### Executemany function \r\n\r\nAll 11 callers ignore the cursor being returned.\r\n\r\n(dispersy)\r\n`community.community.initialize` -> two lines that ignore the cursor\r\n\r\n(tribler)\r\n`idem._update_timerange` -> two lines that ignore the cursor\r\n`idem.on_undo` -> one line that ignores the cursor.\r\n\r\n`Dispersydatabase.check_community_database` -> 6 lines that ignore the cursor\r\n`\r\n\r\n### executescript function\r\n\r\n25 calls to this function, 25/25 ignore the cursor (100%).\r\n\r\n`Bartercast.StatisticsDatabase.check_database` ->ignores the cursor\r\n``idem.cleanup` -> ignores the cursor\r\n\r\n`Dispersydatabase. check_database` -> 23 cases, all ignore the cursor.\r\n`\r\n"}}
{"actor":{"display_login":"lfdversluis"}}