MCPcopy
hub / github.com/gitcoinco/web / handle

Method handle

app/external_bounties/management/commands/sync_bounty0x.py:29–75  ·  view source on GitHub ↗
(self, *args, **options)

Source from the content-addressed store, hash-verified

27 help = 'syncs from other bounty provider'
28
29 def handle(self, *args, **options):
30
31 url = 'https://api.bounty0x.io/v1/bounty/'
32
33 headers = {
34 'origin': 'https://alpha.bounty0x.io',
35 'clientidentifier': 'Kzn9ureLQmDrx7AT3Kcd',
36 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36',
37 'accept-language': 'en-US,en;q=0.9',
38 'accept': 'application/json, text/plain, */*',
39 'referer': 'https://alpha.bounty0x.io/bounties',
40 'authority': 'api.bounty0x.io',
41 'dnt': '1',
42 }
43
44 response = requests.get(url, headers=headers)
45 bounties = response.json()
46 for bounty in bounties:
47 if False:
48 continue
49 try:
50 url = 'https://alpha.bounty0x.io/bounties/{}'.format(bounty['bountyID'])
51 amount = None
52 denomination = ''
53 payout_str = ''
54 try:
55 amount, denomination = bounty['payout'].replace(',','').split(' ')
56 amount = int(amount)
57 except:
58 payout_str = bounty['payout']
59 if not payout_str:
60 payout_str=''
61 amount = None
62 ExternalBounty.objects.get_or_create(
63 action_url=url,
64 active=True,
65 description=bounty['description'],
66 source_project='Bounty0x',
67 amount=amount,
68 amount_denomination=denomination,
69 tags=['Bounty0x'],
70 title=bounty['title'],
71 payout_str=payout_str,
72 )
73 print("HERE")
74 except Exception as e:
75 print(e)

Callers

nothing calls this directly

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected