Skip to content

[$300] Update the challenge object after forum created in processor #51

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

Closed
jmgasper opened this issue Sep 29, 2020 · 19 comments
Closed

Comments

@jmgasper
Copy link
Collaborator

jmgasper commented Sep 29, 2020

After we've created the group / forum for a challenge, we need to update the challenge object to contain a reference back to the forum created:

So you should be able to POST/PUT/PATCH with the challenge object as laid out in this git issue:
topcoder-platform/challenge-api#290

More information on the format is here: topcoder-platform/challenge-api#290 (comment)

From Topcoder:

And you should assume that there can be multiple vanilla forums for whatever reason. So you should loop through all the challenge objects in the array, and if they’re type: challenge, and provider: vanilla, and the url is empty, create that forum.

@jmgasper
Copy link
Collaborator Author

Contest https://www.topcoder.com/challenges/30144037 has been created for this ticket.

This is an automated message for ghostar via Topcoder X

@jmgasper
Copy link
Collaborator Author

Contest https://www.topcoder.com/challenges/30144037 has been updated - it has been assigned to obog.

This is an automated message for ghostar via Topcoder X

@atelomycterus
Copy link
Collaborator

@jmgasper Not quite everything is clear. Example:

"discussions": [
     {
       "provider": "vanilla",
       "name": "Justin Forum Test 11 Discussion",
       "type": "challenge"
     },
     
      {
       "provider": "vanilla",
       "name": "Customer Discussion",
       "type": "customer"
     }
   ],
  1. For a discussion with type='challenge':
    We create all vanilla entities (a group and so on.). Need to implement

'update the challenge object to contain a reference back to the forum created'

It's clear, no questions.

  1. Challenge without 'discussions'. 'discussions' is not required in the challenge schema.
    Should we create a group only in Vanilla?
    image

  2. Now the main category of challenge's discussions is named as a challenge's name.
    Should we use 'name' from a discussion object?
    {
    "provider": "vanilla",
    "name": "Justin Forum Test 11 Discussion",
    "type": "challenge"
    }

image

And you should assume that there can be multiple vanilla forums for whatever reason. So you should loop through all the challenge objects in the array, and if they’re type: challenge, and provider: vanilla, and the url is empty, create that forum

Will there be only one object with type='challenge' and provider='vanilla'?

  1. Are other types out of scope in this task?

@atelomycterus
Copy link
Collaborator

@jmgasper Don't have permissions to patch a challenge. Could you please ask Topcoder team to grant permissions?

image

@jmgasper
Copy link
Collaborator Author

jmgasper commented Oct 3, 2020

1. Challenge without 'discussions'. 'discussions' is not required in the challenge schema.
   Should we create a group only in Vanilla?
   ![image](https://user-images.githubusercontent.com/10196632/94921513-20c65480-04c1-11eb-944c-c5b89beaaec5.png)

If we don't get a discussions object, we won't do anything. We don't need to create a group in that case.

2. Now the main category of challenge's discussions is named as a challenge's name.
   Should we use 'name' from a discussion object?
   {
   "provider": "vanilla",
   "name": "Justin Forum Test 11 Discussion",
   "type": "challenge"
   }

image

Yes, I think that makes sense

And you should assume that there can be multiple vanilla forums for whatever reason. So you should loop through all the challenge objects in the array, and if they’re type: challenge, and provider: vanilla, and the url is empty, create that forum

Will there be only one object with type='challenge' and provider='vanilla'?

I've asked Topcoder

  1. Are other types out of scope in this task?

Yep, but if you run into any issues, let me know and I'll log things so we track them, thanks!

@atelomycterus
Copy link
Collaborator

@jmgasper Please apply PRs: topcoder-platform/challenge-forum-processor#31

Assumption

Implemented for 'one object with type='challenge' and provider='vanilla'
We will wait for a response from Topcoder team if we need support for multiple objects.
if yes then new questions arise. Should we create one group for all discussion objects or not?

Testing

I pushed the code. Couldn't test updating a challenge due to Forbidden Error.

image

@jmgasper
Copy link
Collaborator Author

jmgasper commented Oct 3, 2020

@atelomycterus - The scopes have been updated to:

"scope": "all:challenges read:challenges write:challenges write:groups read:groups read:project read:user_profiles read:project-user read:resources read:terms read:project-members read:group",

@atelomycterus
Copy link
Collaborator

@jmgasper It isn't working. Got 'Not allowed to perfom this action!' for Put/Patch methods.

Vanilla config:
image

I tested with a generated token
image

Postman results with this token:
Get : https://api.topcoder-dev.com/v5/challenges/9d20c28a-2c06-432d-9b0c-ebdee23a9ded - OK
image

Put the same object - Not allowed

image

Patch with updated description - Not allowed
image

@jmgasper
Copy link
Collaborator Author

jmgasper commented Oct 4, 2020

@rootelement ☝️ Any thoughts?

@jmgasper
Copy link
Collaborator Author

jmgasper commented Oct 4, 2020

@atelomycterus - I'm discussing with TC admins. Sorry for the trouble.

@jmgasper jmgasper changed the title [$100] Update the challenge object after forum created in processor [$200] Update the challenge object after forum created in processor Oct 4, 2020
@jmgasper
Copy link
Collaborator Author

jmgasper commented Oct 4, 2020

@ThomasKranitsas - Any thoughts on why the PUT might fail?

@ThomasKranitsas
Copy link

@jmgasper The API works fine. Your token is probably invalid (missing scopes). Please check here:
Screenshot 2020-10-05 at 4 37 30 PM

@jmgasper
Copy link
Collaborator Author

jmgasper commented Oct 5, 2020

@atelomycterus - Can you provide a full copy / paste of the payload being sent in the PUT please?

@atelomycterus
Copy link
Collaborator

@jmgasper I can send 'Patch'/'Put' requests but I see some issues:

PUT

My changes:

 "discussions": [
        {
            "provider": "vanilla",
            "name": "Justin Forum Test 11 Discussion updated obog-put-discussions",
            "type": "challenge",
            "url": "https://xyz.xyz/test"
        }
    ],
    "description": "Public specification updated by obog-put-discussions",

The full payload:

{
    "id": "9d20c28a-2c06-432d-9b0c-ebdee23a9ded",
    "created": "2020-10-02T01:31:11Z",
    "createdBy": "tcwebservice",
    "updated": "2020-10-05T13:41:04Z",
    "updatedBy": "tcwebservice",
    "status": "Active",
    "projectId": 16604,
    "name": "Justin Forum Test 11",
    "typeId": "927abff4-7af9-4145-8ba1-577c16e64e2e",
    "trackId": "9b6fc876-f4d9-4ccb-9dfd-419247628825",
    "startDate": "2020-10-02T01:47:09Z",
    "legacy": {
        "reviewType": "COMMUNITY",
        "isTask": false,
        "subTrack": "CODE",
        "directProjectId": 23642,
        "track": "DEVELOP",
        "reviewScorecardId": 30001610,
        "forumId": 0
    },
    "descriptionFormat": "HTML",
    "timelineTemplateId": "7ebf1c69-f62f-4d3a-bdfb-fe9ddb56861c",
    "terms": [
        {
            "roleId": "3eedd4a4-3c68-4f68-8de4-a1ca5c2055e5",
            "id": "82a35602-57c2-4b48-a9b9-b4e133b22035"
        },
        {
            "roleId": "318b9c07-079a-42d9-a81f-b96be1dc1099",
            "id": "82a35602-57c2-4b48-a9b9-b4e133b22035"
        },
        {
            "roleId": "732339e7-8e30-49d7-9198-cccf9451e221",
            "id": "b11da5cd-713f-478d-90f4-f679ef53ee95"
        },
        {
            "roleId": "ff556573-5da6-4392-b38c-08c1d7599c4a",
            "id": "82a35602-57c2-4b48-a9b9-b4e133b22035"
        },
        {
            "roleId": "d663fc84-5c37-43d1-a537-793feffb7667",
            "id": "82a35602-57c2-4b48-a9b9-b4e133b22035"
        },
        {
            "roleId": "e0544b94-6420-4afc-8f63-238eddc751b9",
            "id": "82a35602-57c2-4b48-a9b9-b4e133b22035"
        },
        {
            "roleId": "0e9c6879-39e4-4eb6-b8df-92407890faf1",
            "id": "75d2f6bb-aadc-475e-9728-32c1dbd13655"
        },
        {
            "roleId": "cfe12b3f-2a24-4639-9d8b-ec86726f76bd",
            "id": "e0993b1a-abf7-45e6-8ed9-8cd0546be90b"
        }
    ],
    "phases": [
        {
            "duration": 561008,
            "scheduledEndDate": "2020-10-08T13:37:00Z",
            "actualEndDate": "2020-10-05T13:45:00Z",
            "isOpen": true,
            "name": "Registration",
            "phaseId": "a93544bc-c165-4af4-b55e-18f3593b457a",
            "actualStartDate": "2020-10-02T01:47:09Z",
            "id": "f01ffd5a-7a00-42ba-b45f-b1ad42ce5652",
            "scheduledStartDate": "2020-10-02T01:47:09Z"
        },
        {
            "duration": 560718,
            "scheduledEndDate": "2020-10-08T13:37:00Z",
            "actualEndDate": "2020-10-05T13:45:00Z",
            "isOpen": false,
            "name": "Submission",
            "phaseId": "6950164f-3c5e-4bdc-abc8-22aaf5a1bd49",
            "actualStartDate": "2020-10-05T13:45:00Z",
            "id": "3c0a7174-5742-48aa-a926-2beeb2e9608a",
            "scheduledStartDate": "2020-10-02T01:52:00Z"
        },
        {
            "duration": 172800,
            "scheduledEndDate": "2020-10-10T13:37:00Z",
            "actualEndDate": "2020-10-05T13:45:00Z",
            "isOpen": false,
            "name": "Review",
            "phaseId": "aa5a3f78-79e0-4bf7-93ff-b11e8f5b398b",
            "actualStartDate": "2020-10-05T13:45:00Z",
            "id": "e70e5d1a-956e-4e17-a462-6b5ade2e8f33",
            "scheduledStartDate": "2020-10-08T13:37:00Z"
        },
        {
            "duration": 86400,
            "scheduledEndDate": "2020-10-11T13:37:00Z",
            "actualEndDate": "2020-10-05T13:45:00Z",
            "isOpen": false,
            "name": "Appeals",
            "phaseId": "1c24cfb3-5b0a-4dbd-b6bd-4b0dff5349c6",
            "actualStartDate": "2020-10-05T13:45:00Z",
            "id": "e399e9f8-dece-4dde-b1f9-3f48f178fae9",
            "scheduledStartDate": "2020-10-10T13:37:00Z"
        },
        {
            "duration": 43200,
            "scheduledEndDate": "2020-10-12T01:37:00Z",
            "actualEndDate": "2020-10-05T13:45:00Z",
            "isOpen": false,
            "name": "Appeals Response",
            "phaseId": "797a6af7-cd3f-4436-9fca-9679f773bee9",
            "actualStartDate": "2020-10-05T13:45:00Z",
            "id": "b972dbdd-62d1-441b-af3e-2326f91bb90b",
            "scheduledStartDate": "2020-10-11T13:37:00Z"
        }
    ],
    "discussions": [
        {
            "provider": "vanilla",
            "name": "Justin Forum Test 11 Discussion updated obog-put-discussions",
            "type": "challenge",
            "url": "https://xyz.xyz/test"
        }
    ],
    "description": "Public specification updated by obog-put-discussions",
    "groups": [],
    "endDate": "2020-10-12T01:37:00Z",
    "numOfSubmissions": 0,
    "numOfRegistrants": 0,
    "currentPhaseNames": [
        "Registration"
    ],
    "registrationStartDate": "2020-10-02T01:47:09Z",
    "registrationEndDate": "2020-10-05T13:45:00Z",
    "submissionStartDate": "2020-10-05T13:45:00Z",
    "submissionEndDate": "2020-10-05T13:45:00Z",
    "track": "Development",
    "type": "Challenge",
    "attachments": [],
    "prizeSets": [
        {
            "prizes": [
                {
                    "type": "USD",
                    "value": 100
                }
            ],
            "description": "Challenge Prizes",
            "type": "placement"
        },
        {
            "prizes": [
                {
                    "type": "copilot",
                    "value": 50
                }
            ],
            "type": "copilot"
        }
    ],
    "tags": [
        "Heroku"
    ],
    "legacyId": 30057219,
    "metadata": [],
    "events": [],
    "task": {
        "isAssigned": false,
        "isTask": false,
        "memberId": null
    },
    "currentPhase": {
        "duration": 561600,
        "scheduledEndDate": "2020-10-08T13:47:00Z",
        "actualEndDate": "2020-10-02T01:51:00Z",
        "isOpen": true,
        "name": "Registration",
        "phaseId": "a93544bc-c165-4af4-b55e-18f3593b457a",
        "actualStartDate": "2020-10-02T01:47:09Z",
        "description": "Registration Phase",
        "id": "d5640883-8e07-41a6-953a-ce00dd50445c",
        "scheduledStartDate": "2020-10-02T01:47:09Z"
    }
}

The result:

  • Description was updated
  • Discussions were missing in the response.
  • 'Get' responds with 'discussions' but without my changes.

image

image

PATCH

My payload:

{
       "discussions": [
        {
            "provider": "vanilla",
            "name": "Justin Forum Test 11 Discussion",
            "type": "challenge",
            "url": "https://xyz.xyz/test"
        }
    ],
   "description": "Public specification updated by obog-patch-discussions1"
}
  1. Missing discussions in the response:
    image

  2. Description was updated, but no changes in the discussions
    image

@jmgasper
Copy link
Collaborator Author

jmgasper commented Oct 6, 2020

@rootelement ☝️

@ThomasKranitsas
Copy link

I see the PR for supporting forum/discussions is not yet merged topcoder-platform/challenge-api#309 which means you can't test it yet

@jmgasper jmgasper changed the title [$200] Update the challenge object after forum created in processor [$300] Update the challenge object after forum created in processor Oct 6, 2020
@jmgasper
Copy link
Collaborator Author

jmgasper commented Oct 6, 2020

@atelomycterus - We made some additional tweaks, and this should be working now (at least it did in my testing using the payload above). Can you validate please?

@atelomycterus
Copy link
Collaborator

@jmgasper Thanks! Please apply PR: topcoder-platform/challenge-forum-processor#32.

Testing

You should see output
image

image

Notes

It throws 403 Error if 'url' contains 'localhost' or '127.0.0.1'. It's confusing because the token is valid but the status meaning access to the requested resource is forbidden for some reason.

image

image

image

@jmgasper
Copy link
Collaborator Author

jmgasper commented Oct 7, 2020

Payment task has been updated: https://software.topcoder.com/review/actions/ViewProjectDetails?pid=30144037

This is an automated message for ghostar via Topcoder X

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants