diff --git a/src/api/endpoints/contributions/routes.py b/src/api/endpoints/contributions/routes.py index b497ff6b..c6fdc739 100644 --- a/src/api/endpoints/contributions/routes.py +++ b/src/api/endpoints/contributions/routes.py @@ -19,6 +19,7 @@ async def get_leaderboard( core: AsyncCore = Depends(get_async_core), access_info: AccessInfo = Depends(get_access_info) ) -> ContributionsLeaderboardResponse: + """Returns the leaderboard of user contributions.""" return await core.adb_client.run_query_builder( GetContributionsLeaderboardQueryBuilder() ) @@ -28,6 +29,18 @@ async def get_user_contributions( core: AsyncCore = Depends(get_async_core), access_info: AccessInfo = Depends(get_access_info) ) -> ContributionsUserResponse: + """Get contributions for the user and how often their annotations agreed with the final validation of URLs. + + Agreement for each is based the number of the user's correct annotations for that URL attribute + divided by their total number of annotations for that URL attribute. + + "Correct" in this case means the user's annotation value for that URL attribute + aligned with the final validated value for that attribute. + + In the case of attributes with multiple validated values, such as agency ID, + agreement is determined if the user's suggested value aligns with any of the final validated values. + """ + return await core.adb_client.run_query_builder( GetUserContributionsQueryBuilder(access_info.user_id) ) \ No newline at end of file diff --git a/tests/manual/api/test_contributions.py b/tests/manual/api/test_contributions.py index 1d79fe33..f367f02d 100644 --- a/tests/manual/api/test_contributions.py +++ b/tests/manual/api/test_contributions.py @@ -1,8 +1,11 @@ import pytest -from src.api.endpoints.contributions.user.queries import GetUserContributionsQueryBuilder +from src.api.endpoints.contributions.leaderboard.query import GetContributionsLeaderboardQueryBuilder +from src.api.endpoints.contributions.user.queries.core import GetUserContributionsQueryBuilder from src.db.client.async_ import AsyncDatabaseClient +# 72 = Max +# 17 = Josh @pytest.mark.asyncio async def test_contributions( @@ -10,5 +13,9 @@ async def test_contributions( ): await adb_client_test.run_query_builder( - GetUserContributionsQueryBuilder(user_id=72) - ) \ No newline at end of file + GetUserContributionsQueryBuilder(user_id=17) + ) + # + # await adb_client_test.run_query_builder( + # GetContributionsLeaderboardQueryBuilder() + # ) \ No newline at end of file