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

Add dropdown filter to show rooms, languages, session types. Ensure it works in mobile view #228

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

odkhang
Copy link
Collaborator

@odkhang odkhang commented Aug 20, 2024

This PR closes/references issue #194 . It does so by:

  • Add filters for track, session, room on schedule/session page

How has this been tested?

Checklist

  • I have added tests to cover my changes.

Summary by Sourcery

Add dropdown filters for tracks, rooms, and session types on the schedule and session pages, and ensure they are responsive for mobile view.

New Features:

  • Introduce dropdown filters for tracks, rooms, and session types on the schedule and session pages, enhancing the user interface for filtering sessions.

Enhancements:

  • Ensure the new dropdown filters are responsive and function correctly in mobile view, improving the mobile user experience.

@odkhang
Copy link
Collaborator Author

odkhang commented Aug 20, 2024

image

image

@odkhang odkhang marked this pull request as ready for review August 20, 2024 07:28
Copy link

sourcery-ai bot commented Aug 20, 2024

Reviewer's Guide by Sourcery

This pull request implements a new filtering system for the schedule and sessions pages. It replaces the previous single filter button with dropdown filters for tracks, rooms, and session types. The changes also include improvements to the mobile view and the addition of a "favorites only" filter.

File-Level Changes

Files Changes
webapp/src/views/schedule/index.vue
webapp/src/views/schedule/sessions/index.vue
Replaced single filter button with dropdown filters for tracks, rooms, and session types
webapp/src/components/AppDropdown.vue
webapp/src/components/AppDropdownContent.vue
webapp/src/components/AppDropdownItem.vue
Added new components for dropdown functionality (AppDropdown, AppDropdownContent, AppDropdownItem)
webapp/src/views/schedule/index.vue
webapp/src/views/schedule/sessions/index.vue
Implemented filtering logic in computed properties and methods
webapp/src/views/schedule/index.vue
webapp/src/views/schedule/sessions/index.vue
Added 'favorites only' filter functionality
webapp/src/views/schedule/index.vue
webapp/src/views/schedule/sessions/index.vue
Improved mobile view styling for filter actions
webapp/src/store/schedule.js Updated store to include session type information
webapp/src/views/schedule/schedule-components/GridSchedule.vue Modified GridSchedule component to handle potential undefined values

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 optimizing the filteredTracks computed property for performance, especially if it's called frequently.
  • The addition of lodash for a single function (_.uniqBy) might be unnecessary. Consider using native JavaScript methods instead to reduce dependencies.
Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 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.

</template>
<script>
import _ from 'lodash'
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): Consider removing lodash dependency

While lodash is powerful, it might be overkill for this use case. Consider using native JavaScript methods to achieve the same functionality, which could reduce bundle size and improve performance.

// Remove this line if lodash is not used elsewhere in the file
// import _ from 'lodash'

// If specific lodash functions are needed, import them individually:
// import { functionName } from 'lodash-es'

...mapGetters('schedule', ['days', 'rooms', 'sessions', 'favs']),
exportType () {
return exportTypeSet
}
},
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): Optimize filteredTracks computed property

This computed property seems to be doing a lot of work on each computation. Consider memoizing the results or using a more efficient filtering algorithm to improve performance, especially for large datasets.

filteredTracks() {
  return Object.keys(this.filter).reduce((results, key) => {
    const { refKey, data } = this.filter[key];
    const selectedIds = data.filter(t => t.selected).map(t => t.value);
    if (selectedIds.length) {
      const filteredTalks = this.schedule.talks.filter(t => selectedIds.includes(t[refKey]));
      return results ? filteredTalks.filter(t => results.includes(t.id)) : filteredTalks;
    }
    return results;
  }, null)?.map(t => t.id) || null;
},

...mapGetters('schedule', ['days', 'rooms', 'sessions', 'favs']),
exportType () {
return exportTypeSet
}
},
Copy link

Choose a reason for hiding this comment

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

suggestion: Move complex logic to Vuex store

The sessions computed property contains complex logic that might be better suited in the Vuex store. This would improve separation of concerns and potentially allow for better caching and reusability across components.

sessions() {
  return this.$store.getters['schedule/filteredSessions']({
    onlyFavs: this.onlyFavs,
    favs: this.favs,
    filteredTracks: this.filteredTracks,
    currentTimezone: this.currentTimezone
  })
},

Comment on lines +138 to +144
state.schedule.session_type = state.schedule.talks.reduce((acc, current) => {
const isDuplicate = acc.some(item => item.session_type === current.session_type);
if (!isDuplicate) {
acc.push(current);
}
return acc;
}, []);
Copy link

Choose a reason for hiding this comment

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

suggestion: Move session type processing to a separate action

The processing of session types could be moved to a separate action or mutation for better organization and potential reusability. This would also make the main action cleaner and easier to understand.

// In store/schedule.js
const processSessionTypes = (talks) => {
  return talks.reduce((acc, current) => {
    if (!acc.some(item => item.session_type === current.session_type)) {
      acc.push(current);
    }
    return acc;
  }, []);
};

// In the action
state.schedule.session_type = processSessionTypes(state.schedule.talks);

@@ -47,6 +47,10 @@
if (!state.schedule) return {}
return state.schedule.speakers.reduce((acc, s) => { acc[s.code] = s; return acc }, {})
},
sessionTypeLookup (state) {
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider consolidating logic to avoid redundancy.

The new code introduces some complexity that could be streamlined. The sessionTypeLookup function adds redundancy similar to tracksLookup and speakersLookup, which can complicate maintenance. Consider consolidating this logic to avoid duplication. The fetch action now includes data processing, which should ideally be separated from data fetching to maintain clear separation of concerns. Direct state mutation within actions can lead to side effects; using mutations to commit processed data to the state is more Vuex-compliant. Additionally, inconsistent naming, such as session_type used in different contexts, can be confusing. Consistent naming conventions would improve readability. Refactoring these aspects could enhance maintainability and clarity.

@mariobehling mariobehling merged commit 190ed8d into fossasia:development Aug 20, 2024
2 of 3 checks passed
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