Skip to content

Commit

Permalink
cors, query param on get-scores
Browse files Browse the repository at this point in the history
  • Loading branch information
qpwedev committed Jul 23, 2023
1 parent 7642abb commit 77277bf
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 19 deletions.
28 changes: 16 additions & 12 deletions backend/polygon_id/credential_issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def generate_credential_link(scores: Scores):
'expiration': None,
'limitedClaims': 1,
'mtProof': False,
'schemaID': 'c895e94a-643f-4e47-8ece-b434a520ba08',
'schemaID': '428a54e7-16eb-42bf-b49b-9b45818637a9',
'signatureProof': True,
}

Expand All @@ -42,18 +42,22 @@ def generate_credential_link(scores: Scores):
json=json_data
)

print(
response.text
)

return {"url": "https://issuer-ui.polygonid.me/credentials/scan-link/" + response.json()['id'], "id": response.json()['id']}


# p = generate_credential_link(
# Scores(
# 0.5,
# 0.5,
# 0.5,
# 0.5,
# 0.5,
# 0.5
# )
# )
p = generate_credential_link(
Scores(
0.5,
0.5,
0.5,
0.5,
0.5,
0.5
)
)

# print(p)
print(p)
5 changes: 3 additions & 2 deletions backend/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ def attest():
def scores():

try:
data = request.get_json()
# get query param
recipient = request.args.get('recipient')

scores = get_scores(
data['recipient']
recipient
)
except Exception as e:

Expand Down
5 changes: 4 additions & 1 deletion backend/run.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from flask import Flask
from flask_cors import CORS
from routes import main

app = Flask(__name__)
app.register_blueprint(main)
CORS(app, resources={r"/get-scores/*": {"origins": "https://near.org"}})


if __name__ == '__main__':
app.run(host='127.0.0.1', port=5555)
app.run(host='127.0.0.1', port=3000)
20 changes: 16 additions & 4 deletions backend/spot_scoring/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,16 @@ def calculate_wallet_data_score(wallet_data):

def calculate_degen_score(address):
score = get_degen_score(address)
return score
return 1


def calculate_nomis_score_eth(address):
score = get_nomis_score_eth(address)
return score

if score:
return score['data']['score']

return 1


def calculate_gitcoin_score(address):
Expand All @@ -102,7 +106,7 @@ def calculate_gitcoin_score(address):
if score:
return round(float(score['score']) / 100, 5)

return score
return 1


def calculate_spot_score(followers, following, posts, comments, mirrors, publications, collects, gitcoin):
Expand Down Expand Up @@ -181,13 +185,21 @@ def get_scores(address):

gitcoin_score = calculate_gitcoin_score(address)

print(
social_score,
degen_score,
nomis_score,
gitcoin_score,
wallet_data_score
)

return {
"scores": {
"social_score": social_score,
"degen_score": degen_score,
"nomis_score_eth": nomis_score,
"gitcoin_score": gitcoin_score,
"spot_score": 777 * (float(social_score) + float(degen_score)+float(nomis_score)+float(gitcoin_score) + float(wallet_data_score)) / 5,
"spot_score": 100 * (float(social_score) + float(degen_score)+float(nomis_score)+float(gitcoin_score) + float(wallet_data_score)) / 5,
"wallet_data": wallet_data_score,
},

Expand Down

0 comments on commit 77277bf

Please sign in to comment.