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

feat: add categories to knowledge center #687

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

calisio
Copy link
Contributor

@calisio calisio commented Jan 23, 2025

Description of the change

Adds category dropdown to knowledge center for students and admins.

Screenshot(s)

Screenshot 2025-01-23 at 12 12 23 PM

Additional context

Leaving this as a draft PR for now, we will be working on implementing AI to sort these features.

Proposed enhancement

We are also playing around with the idea of selecting more than one option from the dropdown.

@calisio
Copy link
Contributor Author

calisio commented Jan 23, 2025

@jtucholski we are thinking about implementing multi select for this query. do you have any oppositions to that?

@jtucholski
Copy link
Contributor

@calisio That's fine. If the user selects all of the options can it switch to "All Libraries"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you want to test this locally, uncomment this code to seed random categories into your db. For the real version, we will have these categories seeded into our databases directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will drop this component when Rich's PR gets merged in (it is pulled from his code but we just needed it to finish our ui)

@calisio calisio marked this pull request as ready for review January 27, 2025 17:38
@calisio
Copy link
Contributor Author

calisio commented Jan 28, 2025

@PThorpe92 should be updated now, but will need to modify again once rich's search is merged

@@ -59,6 +59,9 @@ func (db *DB) GetAllLibraries(page, perPage, days int, userId, facilityId uint,
search = "%" + strings.ToLower(search) + "%"
tx = tx.Where("LOWER(libraries.title) LIKE ? OR LOWER(libraries.description) LIKE ?", search, search)
}
if len(categoryIds) > 0 {
tx = tx.Select("DISTINCT libraries.*").Joins("JOIN open_content_types t ON t.content_id = libraries.id").Where("t.category_id IN (?)", categoryIds)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should have the following criteria added

t.open_content_provider_id = libraries.open_content_provider_id

otherwise you will pull all other providers' open_content_types records if there are any.

@@ -59,6 +59,9 @@ func (db *DB) GetAllLibraries(page, perPage, days int, userId, facilityId uint,
search = "%" + strings.ToLower(search) + "%"
tx = tx.Where("LOWER(libraries.title) LIKE ? OR LOWER(libraries.description) LIKE ?", search, search)
}
if len(categoryIds) > 0 {
tx = tx.Select("DISTINCT libraries.*").Joins("JOIN open_content_types t ON t.content_id = libraries.id").Where("t.category_id IN (?)", categoryIds)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious why you used DISTINCT here? I think you can remove this keyword if you make join on open_content_provider_id.

func (db *DB) GetCategories() ([]models.OpenContentCategory, error) {
var categories []models.OpenContentCategory
if err := db.Model(&models.OpenContentCategory{}).Find(&categories).Error; err != nil {
return nil, newNotFoundDBError(err, "categories")
Copy link
Contributor

Choose a reason for hiding this comment

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

change "categories" to the table name "open_content_categories"

@@ -182,6 +184,7 @@ const LibrarySearchResultsModal = forwardRef<
onModalClose();
setSearchResults(BlankChannel);
};
console.log(libraryOptions);
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be removed?

@@ -234,7 +234,6 @@ const router = createBrowserRouter([
path: 'viewer/libraries/:id',
element: <LibraryViewer />,
errorElement: <Error />,
loader: getLibraryOptions,
Copy link
Contributor

Choose a reason for hiding this comment

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

loader is needed here for loading library options

@@ -43,7 +52,7 @@ export const getStudentLevel1Data: LoaderFunction = async () => {
helpfulLinks: helpfulLinks,
topUserContent: topUserOpenContent,
topFacilityContent: topFacilityOpenContent,
favorites: favoriteOpenContent,
favorites: favoriteOpenContent,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you may need to add the logic for building the list of options here like you did in getLibraryLayoutData, these options will be used on the trending content page.

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.

Enhanced Knowledge Center > Library filtering
5 participants