topcoder-platform / challenge-forum-processor

0 stars 3 forks source link

[$275] Cleanup dev category list #11

Closed jmgasper closed 4 years ago

jmgasper commented 4 years ago

In dev (http://vanilla.topcoder-dev.com), we have a lot of "junk" left over from previous challenges.

We need to:

  1. Remove all the categories that were added.
  2. Add categories to match the Topcoder layout now for forums: Screen Shot 2020-04-09 at 10 55 11
  3. Update the forum processor to add new challenge categories underneath the respective parent category, like "Challenges Forum --> Development Forums"
jmgasper commented 4 years ago

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

This is an automated message for ghostar via Topcoder X

jmgasper commented 4 years ago

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

This is an automated message for ghostar via Topcoder X

atelomycterus commented 4 years ago

@jmgasper I think it's better to write a Javascript script and use the vanilla API to remove all existing categories and create default categories. Add npm run removeAllCategories and npm run setupCategories to package.json. Perhaps this is useful for further testing of the forum. If you are ok with this solution to the problem, I will start working on it.

jmgasper commented 4 years ago

@atelomycterus - Yep, that makes sense, thanks.

atelomycterus commented 4 years ago

@jmgasper a couple of questions: 1) All challenge categories are created as categories with type='heading'. To implement the requrement 'add new challenge categories underneath the respective parent category, like "Challenges Forum --> Development Forums"', we need to find categoryId of 'Challenges Forum' but the endpoint '/categories/search' doesn't search by categories with type='heading'.

The source code '/vanilla-src/package/applications/vanilla/models/class.categorymodel.php'

   /**
     * Search for categories by name.
     *
     * @param string $name The whole or partial category name to search for.
     * @param bool $expandParent Expand the parent category record.
     * @param int|null $limit Limit the total number of results.
     * @param int|null $offset Offset the results.
     * @param array $expand List of data need to be expanded/joined.
     * @return array
     */
    public function searchByName($name, $expandParent = false, $limit = null, $offset = null, array $expand = []) {
        if ($limit !== null && filter_var($limit, FILTER_VALIDATE_INT) === false) {
            $limit = null;
        }
        if ($offset !== null && filter_var($offset, FILTER_VALIDATE_INT) === false) {
            $offset = null;
        }

        $query = $this->SQL
            ->from('Category c')
            ->where('CategoryID >', 0)
            ->where('DisplayAs <>', 'Heading')
            ->like('Name', $name)
            ->orderBy('Name'); 
            ....
    }   

So should we fix Vanilla source code or use another type (e.g. 'nested categories') for 'Challenges Forum'? What category type should be used for other default categories? Headings?

2) As you know, the challenge-forum-processor creates a new role for a new category automatically. In this task should we implement cleanup a role list? If yes, which approach to use: a.) remove all roles except default vanilla roles (Guest, Applicant, Memeber, Moderator, Administrator, Unconfirmed)? b.) use category-role relation(a role name is equals to challengeId) and remove the role created with the category.

3) Vanilla 3.3 has been deployed on http://vanilla.topcoder-dev.com/ . The version of Vanilla is displayed in the footer of a web page. The docker uses Vanilla 3.0 (released 10 June, 2019 ). The latest release is Vanilla 3.3 (released Oct 29, 2019 ). So I updated a docker file. Important notes: The root folder of Vanilla shouldn't be named '/app'. It throws "Fatal Error in Twig\Loader\FilesystemLoader.findTemplate(); Unable to find template "lications/vanilla/views/vanillasettings/editcategory.twig" (looked into: /app)." from the version 3.2+. The function "renderTwig(string $path, array $data)" ('vanilla-src/package/library/Vanilla/Web/TwigRenderTrait.php) build a wrong path. if ROOT_PATH='/app' then it tries to find a twig file in 'lications/vanilla/views//.twig'. Don't use '/vanilla' as well. Vanilla-3 0-to-3 3.

jmgasper commented 4 years ago
  1. Let's just use nested categories. I want to try to limit what we do to Vanilla so that we can upgrade it easily.

  2. Let's just remove all the roles except the default ones for now

  3. Ok, thanks.

atelomycterus commented 4 years ago

@jmgasper Fixed. Need to apply PR.

If you testing with a docker locally, you need to rebuild it. The docker uses Vanilla 3.3.

Steps:

Found a bug in Vanilla 3.3: The endpoint '/categories/{id}' deletes a category with discussions and comments but records are not deleted from the table 'GDN_UserDisscussion'. The wrong count of 'My Discussions' is displayed. If click on 'My discussions' then 'No discussions were found' because all discussion records were deleted. issues-11-count

So DB is in an inconsistent state: issue11-db

I have checked the tables 'GDN_UserComment' and 'GDN_Comment'. all records were deleted. The issues only with count of discussions.

Perhaps need to create separate tickets with the 'known issue' status that can be fixed if Vanill is used in the future.

jmgasper commented 4 years ago

@atelomycterus - This looks good, thanks. One tweak needed still:

I'm not seeing Design Forums and Development Forums as a sub category to Challenges Forum

atelomycterus commented 4 years ago

@jmgasper I see, I missed the second level categories. The forum processor added new challenge category underneath 'Challenges Forum'. I thought they would be created with payloads.

TODO: So 'Development Forums' and 'Design Forums' are default categories as well.

Should we analyze the track of a challenge to match the Topcoder layout (https://apps.topcoder.com/forums)? For example,
The forum processor should add a new challenge category underneath 'Development Forums' for a challenge with the track 'DEVELOP'. The forum processor should add a new challenge category underneath 'Design Forums' for a challenge with the track 'DESIGN'. What about DATA_SCIENCE and COPILOT?

jmgasper commented 4 years ago
  1. Correct, Development Forums and Design Forums are defaults. Let's add Data Science Forums for the DATA_SCIENCE category as well.

  2. Yes, we should add the challenges to the correct sub-category.

  3. We can ignore COPILOT challenges from creating forums - they won't need forums

I'll bump the payment here for the additional work.

atelomycterus commented 4 years ago

@jmgasper Thanks for the additional payment. Sorry for a delay with this task. I am stuck with #12, I have been trying to fix the link color for alerts and notifications. Please apply PR.

Verification: npm run cleanData npm run setupData

You should see subcategories: image

'npm run start' and send a message to the topic. The challenge should be created underneath the appropriate forum:

image

jmgasper commented 4 years ago

Payment failed: [500]: Failed to get billing detail for the project.

This is an automated message for ghostar via Topcoder X

jmgasper commented 4 years ago

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

This is an automated message for ghostar via Topcoder X