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

Support multi language filter track/session/room #237

Closed
wants to merge 14 commits into from

Conversation

odkhang
Copy link
Collaborator

@odkhang odkhang commented Sep 23, 2024

Summary by Sourcery

Introduce multi-language support for filtering tracks, sessions, and rooms in the schedule view by updating the filtering logic to handle session types with multiple language representations and adding utility functions to determine the user's language preference.

New Features:

  • Add support for multi-language filtering of session types, tracks, and rooms in the schedule view.

Enhancements:

  • Enhance the filtering logic to accommodate session types that are represented as objects with multiple language keys.

Copy link

sourcery-ai bot commented Sep 23, 2024

Reviewer's Guide by Sourcery

This pull request implements multi-language support for filtering tracks, sessions, and rooms in the schedule view. The changes primarily affect the filtering logic and data preparation for the filter components, allowing for both string and object representations of session types, tracks, and room names to accommodate multiple languages.

File-Level Changes

Change Details Files
Implement multi-language support for session type filtering
  • Add logic to handle both string and object representations of session types
  • Implement language preference handling, with fallback to English
  • Create a Set to store unique session types across languages
  • Update the filter data preparation to use the new multi-language session types
webapp/src/views/schedule/index.vue
webapp/src/views/schedule/sessions/index.vue
Add multi-language support for tracks and rooms filtering
  • Create a new filterLanguage method to handle multi-language names for tracks and rooms
  • Implement language preference handling, with fallback to English
  • Update the filter data preparation to use the new filterLanguage method
webapp/src/views/schedule/index.vue
webapp/src/views/schedule/sessions/index.vue
Modify the filtering logic to support multi-language data
  • Update the filtering function to handle both string and object representations of session types
  • Modify the filter to check all language keys when dealing with object representations
webapp/src/views/schedule/index.vue
webapp/src/views/schedule/sessions/index.vue
Add utility function for getting user language preference
  • Create a getLanguage method to retrieve the user's language preference from localStorage
  • Set 'en' as the default language if no preference is found
webapp/src/views/schedule/index.vue
webapp/src/views/schedule/sessions/index.vue

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @odkhang - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider refactoring the language handling logic into a separate utility function or service to improve code organization and maintainability.
  • The repeated code in both files suggests an opportunity for further abstraction. Consider creating shared functions for common operations.
  • Instead of accessing localStorage directly in the component, consider creating a user preferences or configuration service to handle language settings.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

const setSessionType = new Set()
const enLanguage = 'en'

this.schedule.session_type.forEach(t => {
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider extracting common language filtering logic into a separate function

The language filtering logic is repeated in multiple places. Creating a reusable function would improve maintainability and reduce code duplication.

function filterSessionTypes(schedule, language = 'en') {
  const setSessionType = new Set()
  schedule.session_type.forEach(t => {
    if (typeof t.session_type === 'string' && t.language === language) {
      setSessionType.add(t.session_type)
    }
  })
  return setSessionType
}

const setSessionType = filterSessionTypes(this.schedule, enLanguage)

getLanguage() {
return localStorage.getItem('userLanguage') || 'en'
},
filterLanguage(data) {
Copy link

Choose a reason for hiding this comment

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

suggestion: Extract duplicate code into a shared module or mixin

The changes in both 'index.vue' and 'sessions/index.vue' are nearly identical. Consider extracting this functionality into a shared module or mixin to improve maintainability and reduce duplication.

import { languageUtils } from '@/utils/languageUtils'

// ...

methods: {
  filterLanguage(data) {
    return languageUtils.filterLanguage(data, this.getLanguage())
  },

@odkhang odkhang closed this Sep 25, 2024
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.

2 participants