Fetch available tasks

This commit is contained in:
AbdBarho
2023-01-20 12:16:17 +01:00
parent c81967fca9
commit e80a69dd8a
8 changed files with 62 additions and 17 deletions
+8
View File
@@ -1,5 +1,6 @@
import type { Message } from "src/types/Conversation";
import { LeaderboardReply, LeaderboardTimeFrame } from "src/types/Leaderboard";
import type { AvailableTasks } from "src/types/Task";
import type { BackendUser, BackendUserCore } from "src/types/Users";
export class OasstError {
@@ -205,6 +206,13 @@ export class OasstApiClient {
async fetch_leaderboard(time_frame: LeaderboardTimeFrame): Promise<LeaderboardReply> {
return this.get(`/api/v1/leaderboards/${time_frame}`);
}
/**
* Returns the counts of all tasks (some might be zero)
*/
async fetch_available_tasks(user: BackendUserCore): Promise<AvailableTasks> {
return this.post(`/api/v1/tasks/availability`, user);
}
}
const oasstApiClient = new OasstApiClient(process.env.FASTAPI_URL, process.env.FASTAPI_KEY);