Handle visualization of the request response data based on type. Args: visual_type (str): The visualization type. TODO: * Reduce complexity of this method to pass McCabe complexity check. Returns: dict: The JSON representation of the requested visual type data.
(request, visual_type)
| 35 | |
| 36 | @staff_member_required |
| 37 | def data_viz_helper_get_data_responses(request, visual_type): |
| 38 | """Handle visualization of the request response data based on type. |
| 39 | |
| 40 | Args: |
| 41 | visual_type (str): The visualization type. |
| 42 | |
| 43 | TODO: |
| 44 | * Reduce complexity of this method to pass McCabe complexity check. |
| 45 | |
| 46 | Returns: |
| 47 | dict: The JSON representation of the requested visual type data. |
| 48 | |
| 49 | """ |
| 50 | data_dict = {} |
| 51 | network = 'mainnet' |
| 52 | for bounty in Bounty.objects.current().filter(network=network, web3_type='bounties_network'): |
| 53 | |
| 54 | if visual_type == 'status_progression': |
| 55 | max_size = 12 |
| 56 | value = 1 |
| 57 | if not value: |
| 58 | continue |
| 59 | response = [] |
| 60 | prev_bounties = Bounty.objects.filter( |
| 61 | standard_bounties_id=bounty.standard_bounties_id, network=network |
| 62 | ).exclude(pk=bounty.pk).order_by('created_on') |
| 63 | if prev_bounties.exists() and prev_bounties.first().status == 'started': |
| 64 | response.append('open') # mock for status changes not mutating status |
| 65 | last_bounty_status = None |
| 66 | for prev_bounty in prev_bounties: |
| 67 | if last_bounty_status != prev_bounty.status: |
| 68 | response.append(prev_bounty.status) |
| 69 | last_bounty_status = prev_bounty.status |
| 70 | if bounty.status != last_bounty_status: |
| 71 | response.append(bounty.status) |
| 72 | response = response[0:max_size] |
| 73 | while len(response) < max_size: |
| 74 | response.append('_') |
| 75 | |
| 76 | elif visual_type == 'repos': |
| 77 | value = bounty.value_in_usdt_then |
| 78 | bounty_org_name = getattr(bounty, 'org_name', '') |
| 79 | bounty_repo_name = getattr(bounty, 'github_repo_name', '') |
| 80 | |
| 81 | response = [ |
| 82 | bounty_org_name.replace('-', ''), |
| 83 | bounty_repo_name.replace('-', ''), |
| 84 | str(bounty.github_issue_number), |
| 85 | ] |
| 86 | |
| 87 | elif visual_type == 'fulfillers': |
| 88 | response = [] |
| 89 | if bounty.status == 'done': |
| 90 | for fulfillment in bounty.fulfillments.filter(accepted=1): |
| 91 | value = bounty.value_in_usdt_then |
| 92 | |
| 93 | response = [fulfillment.fulfiller_github_username.replace('-', '')] |
| 94 |
no test coverage detected