The SUSI SKill CMS has various filters to explore the skills of interest. For example skill category and skill language. The skills are stored in the susi_skill_data Github repo in the following structure:
NOTE: group and category are same terms and can be used interchangeably
So when a category filter is applied the skills from the corresponding directory are returned.
But there’s no directory called “All”, so how to get skills of all groups? For this, we need to loop through all the directories present in the model.
Server side implementation
Create a helper function that returns a list of all the folders present in a directory. The function accepts the parent directory name and an empty list. First, fetch all the items (files and folders) present in that directory and store them in an array. Then apply a filter over the array to check if the element is a directory and doesn’t start with a dot(.) i.e., it’s not hidden. Add the filtered array to the list.
Fetch the group name form the request and add a check if the CMS is asking for all skill. Otherwise, return the skills of a particular group only.
To fetch the list of all skills, call the listFoldersForFolders() function with the model name and an empty list as arguments. The function adds all the directories, present in that model directory, to folderList.
Then loop over all the groups present in the list to get all the skills present in that group. This process is the same as the existing process of getting skills of a particular category. Just keep adding the skill list to a global array.
CMS side implementation
The list of categories is first fetched from the API and then added to the dropdown menu. Since the API doesn’t return “All” in it, so we need to push it to the list manually.