Skip to content

Commit

Permalink
fix: changed sorting order of batch list
Browse files Browse the repository at this point in the history
  • Loading branch information
pateljannat committed Jan 15, 2025
1 parent 8401e86 commit 5c8378f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions frontend/src/pages/Batches.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</router-link>
</div>
<div
v-else
v-else-if="!batches.list.loading"
class="flex flex-col items-center justify-center text-sm text-gray-600 italic mt-48"
>
<BookOpen class="size-10 mx-auto stroke-1.5 text-gray-500" />
Expand Down Expand Up @@ -101,7 +101,8 @@ const categories = ref([])
const currentCategory = ref(null)
const title = ref('')
const filters = ref({})
const currentTab = ref('All')
const currentTab = ref(user.data?.is_student ? 'All' : 'Upcoming')
const orderBy = ref('start_date')
onMounted(() => {
setFiltersFromQuery()
Expand Down Expand Up @@ -141,6 +142,7 @@ const updateBatches = () => {
updateFilters()
batches.update({
filters: filters.value,
orderBy: orderBy.value,
})
batches.reload()
}
Expand Down Expand Up @@ -170,18 +172,22 @@ const updateTitleFilter = () => {
}
const updateTabFilter = () => {
orderBy.value = 'start_date'
if (!user.data) {
return
}
if (currentTab.value == 'Enrolled' && user.data?.is_student) {
filters.value['enrolled'] = 1
orderBy.value = 'start_date desc'
} else if (user.data?.is_student) {
delete filters.value['enrolled']
} else {
delete filters.value['start_date']
delete filters.value['published']
orderBy.value = 'start_date desc'
if (currentTab.value == 'Upcoming') {
filters.value['start_date'] = ['>=', dayjs().format('YYYY-MM-DD')]
orderBy.value = 'start_date'
} else if (currentTab.value == 'Archived') {
filters.value['start_date'] = ['<', dayjs().format('YYYY-MM-DD')]
} else if (currentTab.value == 'Unpublished') {
Expand Down
4 changes: 2 additions & 2 deletions lms/lms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,7 @@ def enroll_in_program_course(program, course):


@frappe.whitelist(allow_guest=True)
def get_batches(filters=None, start=0, page_length=20):
def get_batches(filters=None, start=0, page_length=20, order_by="start_date"):
if not filters:
filters = {}

Expand Down Expand Up @@ -1884,7 +1884,7 @@ def get_batches(filters=None, start=0, page_length=20):
"published",
"category",
],
order_by="start_date desc",
order_by=order_by,
start=start,
page_length=page_length,
)
Expand Down

0 comments on commit 5c8378f

Please sign in to comment.