Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the webapp to fetch and upate tasks in sequence #19

Merged
merged 5 commits into from
Dec 18, 2022

Conversation

fozziethebeat
Copy link
Collaborator

This shows an end to end example of how to handle one task type (ratings) with a task queue in the client side and storing all the task & interaction state with an intermediate database. This is mostly to get a working example of a full flow.

In a future PR we will:

  • Support the various task types
  • Make it look good
  • Refactor the code to make it easier to work with.

@fozziethebeat fozziethebeat requested a review from yk as a code owner December 18, 2022 06:47
@fozziethebeat fozziethebeat linked an issue Dec 18, 2022 that may be closed by this pull request
Copy link
Collaborator

@andreaskoepf andreaskoepf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested changes could best be done after switching to Typescript. We can merge this now.

* Returns a new task created from the Task Backend. We do a few things here:
*
* 1) Get the task from the backend and register the requesting user.
* 2) Store the task in our local database.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably already clear: When the frontend posts user-information with the fetch-new-task-request the created work_package in the DB will be associated with the user and the backend will accept replies only from the same user (like DM conversation on discord). When no user information was included the task is considered to be 'public' (as in a public channel on discord) and multiple users can reply.
For interactions it is mandatory to send user information (replies and ratings/rankings are always associated with a user).

user: {
id: session.user.id,
display_name: session.user.name,
auth_method: "local",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently it would be possible to send the discord user_id as id + auth_method: "discord". We have to discuss the best way to support different auth-providers and still match users. For first v1 we should focus on discord (e.g. same identity used for bot and web).


// Send the interaction to the Task Backend. This automatically fetches the
// next task in the sequence (or the done task).
const interactionRes = await fetch(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend to move all the backend api fetch-impls to a class in a separate file.
somthing like:

export class BackendApi {
    public static async sendInteraction(interaction: TaskInteraction, session: Session): Promise<ResponseType> { .. }
}

(use suitable types & names as you like)

@andreaskoepf andreaskoepf merged commit 03879d2 into main Dec 18, 2022
@andreaskoepf andreaskoepf deleted the web-fetch-tasks branch December 18, 2022 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connect website to backend to fetch, ack, and interact with tasks
3 participants