topcoder-platform / work-manager

This is the frontend application for creating and managing challenges.
13 stars 48 forks source link

Save skill data when updating a challenge #1575

Closed jmgasper closed 8 months ago

jmgasper commented 8 months ago

There are three parts to this task:

Part 1

We want to change the skill auto-complete endpoint from /v5/tc-emsi-skills-api to /v5/emsi-skills/skills

Example:

https://api.topcoder-dev.com/v5/emsi-skills/skills/auto-complete?term=jav

Part 2

We can now save the skills back to the API when editing a challenge. This will require a second API call when saving a challenge, which we'll need to make sure happens in addition to the PUT to the challenge endpoint.

To save skills:

POST to https://api.topcoder-dev.com/v5/emsi-skills-work-skills

BODY:

{
    "workId": "fed687e1-4257-48bb-806c-38712f9bf14f",
    "workTypeId": "413340e8-f56f-4061-8796-c916dfa82770",
    "skillIds": [
        "002015b4-9bcb-4b85-9d46-e648d0375a54",
        "0087514d-5ebc-4720-a635-17f0b5399692"
    ]
}

The workId is the challenge ID

The workTypeId should be configurable, with the default being 413340e8-f56f-4061-8796-c916dfa82770

Part 3

When reading the skills to display on the challenge details page, we can continue to use the challenge API response, but we should be looking for the skills array, not emsi-skills.

suppermancool commented 8 months ago

@jmgasper

  1. I get this error when calling update skills in manager app(pls allow https://local.topcoder-dev.com in allow origin cors):

    Screenshot 2023-10-16 at 13 35 59
  2. I get this error when calling update skills in postman: example body:

    {
    "workId": "fe775295-1f41-49c8-a946-b9004ced24fe",
    "workTypeId": "413340e8-f56f-4061-8796-c916dfa82770",
    "skillIds": [
        "041573a9-3713-4dbd-ad6d-db5dd2857783"
    ]
    }
    Screenshot 2023-10-16 at 13 40 05
jmgasper commented 8 months ago

@suppermancool - Try /emsi-skills/work-skills, instead of /emsi-skills-work-skills, thanks. The CORS is in place for local.topcoder-dev.com, so it should be fixed with the updated URL.

suppermancool commented 8 months ago

@jmgasper I get this error with the new endpoint:

Screenshot 2023-10-16 at 23 20 32
vas3a commented 8 months ago

@jmgasper I saw emsi and I was thinking you're trying to reach the old api, but after the slack comment, I think you're trying to hit the standardized skills api.

You should use /v5/standardized-skills/work-skills. this is the correct url, the payload looks good. You can also use the postman/swagger files hosted in this repo: https://github.com/topcoder-platform/standardized-skills-api/tree/develop/docs.

cc @suppermancool

jmgasper commented 8 months ago

@vas3a - Ugh, my bad, thanks for that. Just wasn't paying attention.

suppermancool commented 8 months ago

@jmgasper @vas3a

  1. The API works now but I can not save the skills to challenge https://challenges.topcoder-dev.com/projects/22248/challenges/fe775295-1f41-49c8-a946-b9004ced24fe/edit
  1. Can you provide an example of skills in challenge details info(response of get {{API_V5}}/challenges/fe775295-1f41-49c8-a946-b9004ced24fe)? Because I can not save the skills now I do not know the template of skills in the backend response. I do not have permission to assess https://github.com/topcoder-platform/standardized-skills-api/tree/develop/docs
jmgasper commented 8 months ago

@suppermancool - A couple things here:

  1. The work type ID should be 4d2bdbc8-eb3b-4156-8d20-98a46589cc5d, sorry. That whole thing is a bit confusing and I had to dig it out of the database. I'm thinking we may want a lookup API for it. I've attached the full list below, for reference on later tickets.

  2. I still get an error with that:

{
    "message": "Challenge with id: fe775295-1f41-49c8-a946-b9004ced24fe does not exist!"
}

I'll have to ask the platform devs on why that's not finding the challenge.

List of work type IDs

jmgasper commented 8 months ago

@suppermancool - Ok, the platform team fixed the API. I was able to create a skill on a challenge with this POST:

{
    "workId": "fe775295-1f41-49c8-a946-b9004ced24fe",
    "workTypeId": "4d2bdbc8-eb3b-4156-8d20-98a46589cc5d",
    "skillIds": [
        "002015b4-9bcb-4b85-9d46-e648d0375a54"
    ]
}
suppermancool commented 8 months ago

@jmgasper there is one problem. I can not save skills with skill ID from https://api.topcoder-dev.com/v5/emsi-skills/skills/auto-complete?term=jav . However, that bug does not block me from finishing this task.

Screenshot 2023-10-17 at 16 31 52
jmgasper commented 8 months ago

@suppermancool - We should be using https://api.topcoder-dev.com/v5/standardized-skills/skills/autocomplete?term=jav instead. That will have the correct IDs returned.

NOTE - autocomplete in the new API instead of auto-complete

suppermancool commented 8 months ago

@jmgasper done in work-manager-issue-1575.patch (this patch against commit 073fa1fb984c547d486bdfa8f13e6ab71c4f7ddc in develop branch)

suppermancool commented 8 months ago

@jmgasper pls apply this patch after the above patch work-manager-issue-1575-2.patch (i forget to check the creating challenge flow)

jmgasper commented 8 months ago

@suppermancool - OK, I think we found one bug here. When saving a challenge, we need to:

  1. Save the challenge first to the challenge API
  2. Then save the skills to /work-skills, all in one go, instead of every time the user edits a skill in the selector.

What's happening is that the skills are being saved to '/work-skills', but then we save the challenge to the challenge API and because it doesn't contain any skills, they get cleared out.

suppermancool commented 8 months ago

@jmgasper i implement your suggestion in work-manager-issue-1575-3.patch (this patch against commit bd2768e7c50975684e9d9d0d0000bc3102da9421 in develop branch)

jmgasper commented 8 months ago

@suppermancool - Thanks, we're working on this.

jmgasper commented 8 months ago

@suppermancool - Ok, after a lot of back and forth, we need to tweak all requests to the challenge API to include a version header like:

challenge-api-version: 1.1.0

Then, the skills will be returned in the GET to the challenge API.

Example Postman setup:

SCR-20231023-shmu
suppermancool commented 8 months ago

@jmgasper done in work-manager-issue-1575-4.patch (this patch against commit 88b229efc540138b3b52ae2affad1c9bb0282611 in develop branch)