Skip to content

Commit

Permalink
refactor: default sort by most downloaded packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Jan 21, 2024
1 parent faea546 commit be92dda
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions app/services/packages_fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class PackagesFetcher {
const valueB = b[property]

if (typeof valueA === 'number' && typeof valueB === 'number') {
return valueA - valueB * order
return (valueA - valueB) * order
}

if (typeof valueA === 'string' && typeof valueB === 'string') {
Expand Down Expand Up @@ -146,11 +146,13 @@ export class PackagesFetcher {
/**
* Sort the results
*/
console.log(options)
const sortedPackages = this.#sortPackages(
options.order ?? 1,
options.orderBy ?? 'name',
options.order ?? -1,
options.orderBy ?? 'downloads',
packages,
)
console.log(sortedPackages)

/**
* Paginate the results
Expand Down
2 changes: 1 addition & 1 deletion content/packages/cavai-queue.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: '@cavai/adonis-queue'
name: 'cavai/adonis-queue'
description: Queue package for Adonis V5. Comes with built-in database driver and allows easy extension with custom drivers
repo: cavai-research/Adonis-Queue
npm: '@cavai/adonis-queue'
Expand Down
4 changes: 2 additions & 2 deletions resources/pages/home/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ const orderByOptions = [
description: 'Sort packages by their last update date',
},
]
const order = ref<SortOrder>(params.order ? (+params.order as SortOrder) : 1)
const orderBy = ref<string>(params.orderBy || orderByOptions[0].value)
const order = ref<SortOrder>(params.order ? (+params.order as SortOrder) : -1)
const orderBy = ref<string>(params.orderBy || orderByOptions[3].value)
/**
* Filters
Expand Down

0 comments on commit be92dda

Please sign in to comment.