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 multiple language in track/session type/ room filter #236

Closed

Conversation

odkhang
Copy link
Collaborator

@odkhang odkhang commented Sep 23, 2024

this PR about support multiple languages when filter track/session/room

Summary by Sourcery

Implement multi-language support for filtering tracks, session types, and rooms in the schedule view by leveraging user language preferences. Update the Vue configuration to set a global public path and adjust related asset paths. Introduce a BASE_PATH setting in the server configuration to facilitate dynamic URL path handling.

New Features:

  • Add support for filtering tracks, session types, and rooms in multiple languages by utilizing user language preferences stored in local storage.

Enhancements:

  • Enhance the filtering logic to accommodate session types that are represented as objects with multiple language keys.
  • Refactor the filter setup to dynamically handle multiple languages for tracks, session types, and rooms.

Build:

  • Update the public path in the Vue configuration to '/video' and adjust icon paths accordingly.

Deployment:

  • Introduce a BASE_PATH setting in the server configuration to support dynamic URL path adjustments.

Copy link

sourcery-ai bot commented Sep 23, 2024

Reviewer's Guide by Sourcery

This pull request implements support for multiple languages in track, session type, and room filters. The changes primarily affect the filtering logic and data processing in the schedule views, introducing language-specific handling for session types, tracks, and rooms.

File-Level Changes

Change Details Files
Implemented multi-language support for session type filtering
  • Added logic to handle both string and object session types
  • Introduced language preference handling, with fallback to English
  • Created a new Set to store unique session types across languages
webapp/src/views/schedule/index.vue
webapp/src/views/schedule/sessions/index.vue
Added language-specific filtering for tracks and rooms
  • Created a new filterLanguage method to process multi-language data
  • Implemented language preference handling with fallback to English
  • Updated filter data generation to use the new filterLanguage method
webapp/src/views/schedule/index.vue
webapp/src/views/schedule/sessions/index.vue
Updated Vue configuration for global path setting
  • Added publicPath setting to '/video'
  • Updated manifest icon paths to include '/video' prefix
webapp/vue.config.js
Modified server-side code to support base path configuration
  • Added BASE_PATH setting in server configuration
  • Updated WorldAdminToken view to use BASE_PATH in redirect URL
server/venueless/control/views.py
server/venueless/settings.py

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 extracting the common filtering logic in index.vue and sessions/index.vue into a shared utility function or mixin to avoid code duplication.
  • The filtering logic, especially in the filter() computed property, has become quite complex. Consider refactoring this into smaller, more manageable functions to improve readability and maintainability.
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.

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: Refactor duplicate code in index.vue and sessions/index.vue

The filterLanguage function and related logic are duplicated in both index.vue and sessions/index.vue. Consider extracting this common functionality into a shared utility or mixin to improve maintainability and reduce code duplication.

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

// ...

methods: {
  filterLanguage,
  // ... other methods
},

Comment on lines +227 to +257
this.schedule.session_type.forEach(t => {
if (typeof t.session_type === 'string') {
setSessionType.add(t.session_type)
} else {
const sessionTypeKeyArray = Object.keys(t.session_type)
let isEnglish = false

for (let i = 0; i < sessionTypeKeyArray.length; i++) {
if (sessionTypeKeyArray[i] === this.getLanguage()) {
setSessionType.add(t.session_type[sessionTypeKeyArray[i]])
break
}
else if (sessionTypeKeyArray[i] === enLanguage) {
isEnglish = true
if (i === sessionTypeKeyArray.length - 1) {
setSessionType.add(t.session_type[enLanguage])
}
}
else {
if (i === sessionTypeKeyArray.length - 1) {
if (isEnglish) {
setSessionType.add(t.session_type[enLanguage])
}
else {
setSessionType.add(t.session_type[sessionTypeKeyArray[i]])
}
}
}
}
}
})
Copy link

Choose a reason for hiding this comment

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

suggestion: Simplify language selection logic for improved readability

The nested conditional statements in the language selection logic are complex and hard to follow. Consider refactoring this into a more declarative approach, possibly using a separate function or utilizing lodash methods for a more concise implementation.

this.schedule.session_type.forEach(t => {
  const sessionType = typeof t.session_type === 'string' ? t.session_type : this.getSessionTypeByLanguage(t.session_type);
  setSessionType.add(sessionType);
});

getSessionTypeByLanguage(sessionTypeObj) {
  const languages = Object.keys(sessionTypeObj);
  return sessionTypeObj[this.getLanguage()] || sessionTypeObj[enLanguage] || sessionTypeObj[languages[languages.length - 1]];
}

@odkhang odkhang closed this Sep 23, 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