Skip to content

Commit

Permalink
1023 rename community (#171)
Browse files Browse the repository at this point in the history
* fix(api): rename community_id to scorer_id

* feat(exampl,scoring): have updated example renamed comunity -> scorer
  • Loading branch information
nutrina authored Mar 21, 2023
1 parent d3fae85 commit 0d88f1a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
36 changes: 18 additions & 18 deletions api/registry/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,25 +250,25 @@ def submit_passport(request, payload: SubmitPassportPayload) -> DetailedScoreRes


@router.get(
"/score/{int:community_id}/{str:address}",
"/score/{int:scorer_id}/{str:address}",
auth=ApiKey(),
response={
200: DetailedScoreResponse,
401: ErrorMessageResponse,
400: ErrorMessageResponse,
404: ErrorMessageResponse,
},
summary="Get score for an address that is associated with a community",
description="""Use this endpoint to fetch the score for a specific address that is associated with a community\n
summary="Get score for an address that is associated with a scorer",
description="""Use this endpoint to fetch the score for a specific address that is associated with a scorer\n
This endpoint will return a `DetailedScoreResponse`. This endpoint will also return the status of the asynchronous operation that was initiated with a request to the `/submit-passport` API.\n
""",
)
def get_score(request, address: str, community_id: int) -> DetailedScoreResponse:
def get_score(request, address: str, scorer_id: int) -> DetailedScoreResponse:
check_rate_limit(request)

# Get community object
user_community = api_get_object_or_404(
Community, id=community_id, account=request.auth
Community, id=scorer_id, account=request.auth
)

try:
Expand All @@ -280,39 +280,39 @@ def get_score(request, address: str, community_id: int) -> DetailedScoreResponse
return score
except Exception as e:
log.error(
"Error getting passport scores. community_id=%s",
community_id,
"Error getting passport scores. scorer_id=%s",
scorer_id,
exc_info=True,
)
raise InvalidCommunityScoreRequestException() from e


@router.get(
"/score/{int:community_id}",
"/score/{int:scorer_id}",
auth=ApiKey(),
response={
200: List[DetailedScoreResponse],
401: ErrorMessageResponse,
400: ErrorMessageResponse,
404: ErrorMessageResponse,
},
summary="Get scores for all addresses that are associated with a community",
description="""Use this endpoint to fetch the scores for all addresses that are associated with a community\n
summary="Get scores for all addresses that are associated with a scorer",
description="""Use this endpoint to fetch the scores for all addresses that are associated with a scorer\n
This API will return a list of `DetailedScoreResponse` objects. The endpoint supports pagination and will return a maximum of 1000 scores per request.\n
Pass a limit and offset query parameter to paginate the results. For example: `/score/1?limit=100&offset=100` will return the second page of 100 scores.\n
""",
)
@paginate(pass_parameter="pagination_info")
def get_scores(
request, community_id: int, address: str = "", **kwargs
request, scorer_id: int, address: str = "", **kwargs
) -> List[DetailedScoreResponse]:
check_rate_limit(request)
if kwargs["pagination_info"].limit > 1000:
raise InvalidLimitException()

# Get community object
user_community = api_get_object_or_404(
Community, id=community_id, account=request.auth
Community, id=scorer_id, account=request.auth
)

try:
Expand All @@ -327,8 +327,8 @@ def get_scores(

except Exception as e:
log.error(
"Error getting passport scores. community_id=%s",
community_id,
"Error getting passport scores. scorer_id=%s",
scorer_id,
exc_info=True,
)
raise e
Expand Down Expand Up @@ -368,17 +368,17 @@ def get_scores_analytics(


@analytics_router.get(
"/score/{int:community_id}", auth=ApiKey(), response=CursorPaginatedScoreResponse
"/score/{int:scorer_id}", auth=ApiKey(), response=CursorPaginatedScoreResponse
)
@permissions_required([ResearcherPermission])
def get_scores_by_community_id_analytics(
request,
community_id: int,
scorer_id: int,
address: str = "",
last_id: int = None,
limit: int = 1000,
) -> CursorPaginatedScoreResponse:
user_community = api_get_object_or_404(Community, id=community_id)
user_community = api_get_object_or_404(Community, id=scorer_id)

query = Score.objects.order_by("id")

Expand Down Expand Up @@ -407,7 +407,7 @@ def get_scores_by_community_id_analytics(
next_url = (
reverse_lazy_with_query(
"analytics:get_scores_by_community_id_analytics",
args=[community_id],
args=[scorer_id],
query_kwargs={"last_id": last_score.id},
)
if last_score
Expand Down
22 changes: 11 additions & 11 deletions examples/example-score-a-passport/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ <h4>Connect your wallet</h4>
<div id="scoringWithoutSignature">
<p class="mt-3">
<h4>Score without required signature</h4>
Enter your community ID and API key, which you can get from your
Enter your scorer ID and API key, which you can get from your
<a href="https://scorer.gitcoin.co/">scoring dashboard</a>
</p>
<input type="text" id="communityId" placeholder="Community ID" />
<input type="text" id="scorerId" placeholder="Scorer ID" />
<input type="text" id="apiKey" placeholder="API Key" />
<button type="button" class="submitForScoringButton btn btn-primary">
Submit for scoring without signature
Expand All @@ -35,10 +35,10 @@ <h4>Score without required signature</h4>
<div id="scoringWithSignature">
<p class="mt-3">
<h4>Score with required signature</h4>
Enter your community ID and API key, which you can get from your
Enter your scorer ID and API key, which you can get from your
<a href="https://scorer.gitcoin.co/">scoring dashboard</a>
</p>
<input type="text" id="communityId" placeholder="Community ID" />
<input type="text" id="scorerId" placeholder="Scorer ID" />
<input type="text" id="apiKey" placeholder="API Key" />
<button type="button" class="submitForScoringButton btn btn-primary">
Submit for scoring
Expand All @@ -60,7 +60,7 @@ <h4>Score with required signature</h4>
type="application/javascript"
></script>
<script>
let communityId, apiKey;
let scorerId, apiKey;

const endpoint = "https://api.scorer.gitcoin.co";
// const endpoint = "https://api.scorer.dpopp.gitcoin.co";
Expand Down Expand Up @@ -95,7 +95,7 @@ <h4>Score with required signature</h4>
const passportScoreDisplay = document.querySelector("#scoringWithoutSignature .passportScore");

passportScoreDisplay.innerHTML = "Calculating your score ..."
const communityId = document.querySelector("#scoringWithoutSignature #communityId").value;
const scorerId = document.querySelector("#scoringWithoutSignature #scorerId").value;
const apiKey = document.querySelector("#scoringWithoutSignature #apiKey").value;

if(!account) {
Expand All @@ -108,7 +108,7 @@ <h4>Score with required signature</h4>
endpoint + "/registry/submit-passport",
{
address: account,
community: communityId,
community: scorerId,
},
{
headers: {
Expand All @@ -124,7 +124,7 @@ <h4>Score with required signature</h4>
if (score) {
async function updateScore() {
const response = await axios.get(
endpoint + `/registry/score/${communityId}/${account}`,
endpoint + `/registry/score/${scorerId}/${account}`,
{
headers: {
"Content-Type": "application/json",
Expand Down Expand Up @@ -161,7 +161,7 @@ <h4>Score with required signature</h4>
const passportScoreDisplay = document.querySelector("#scoringWithSignature .passportScore");

passportScoreDisplay.innerHTML = "Calculating your score ..."
const communityId = document.querySelector("#scoringWithSignature #communityId").value;
const scorerId = document.querySelector("#scoringWithSignature #scorerId").value;
const apiKey = document.querySelector("#scoringWithSignature #apiKey").value;

if(!account) {
Expand Down Expand Up @@ -193,7 +193,7 @@ <h4>Score with required signature</h4>
endpoint + "/registry/submit-passport",
{
address: account,
community: communityId,
community: scorerId,
signature: signedMessage,
nonce: nonce,
},
Expand All @@ -211,7 +211,7 @@ <h4>Score with required signature</h4>

async function updateScore() {
const response = await axios.get(
endpoint + `/registry/score/${communityId}/${account}`,
endpoint + `/registry/score/${scorerId}/${account}`,
{
headers: {
"Content-Type": "application/json",
Expand Down

0 comments on commit 0d88f1a

Please sign in to comment.