mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Enable custom list summary number
This commit is contained in:
parent
fa16340a86
commit
fd0dcb5f2f
4 changed files with 102 additions and 36 deletions
|
|
@ -34,13 +34,25 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import statuses from '~/helpers/statuses'
|
import getListSummaryNumbers from '~/helpers/get-list-summary-numbers.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
appList: {
|
appList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
default: null
|
||||||
|
},
|
||||||
|
customNumbers: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {
|
||||||
|
return {
|
||||||
|
total: null,
|
||||||
|
nativePercent: null,
|
||||||
|
rosettaPercent: null,
|
||||||
|
unreportedPercent: null,
|
||||||
|
unsupportedPercent: null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
|
|
@ -53,7 +65,7 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
total () {
|
total () {
|
||||||
return this.appList.length
|
return (this.customNumbers.total) ? this.customNumbers.total : this.appList.length
|
||||||
},
|
},
|
||||||
percentages () {
|
percentages () {
|
||||||
return [
|
return [
|
||||||
|
|
@ -104,34 +116,24 @@ export default {
|
||||||
created () {
|
created () {
|
||||||
// console.log('total apps ', this.total)
|
// console.log('total apps ', this.total)
|
||||||
|
|
||||||
// Create a totals object to collect amounts
|
const hasCustomNumbers = Object.entries(this.customNumbers).some(([key, number]) => number !== null)
|
||||||
const totals = {}
|
|
||||||
|
|
||||||
// Get status slugs from statuses
|
if (hasCustomNumbers) {
|
||||||
Object.entries(statuses).forEach( ([_, statusSlug]) => {
|
|
||||||
totals[statusSlug] = 0
|
|
||||||
})
|
|
||||||
|
|
||||||
// Count uses of each status
|
this.nativePercent = this.customNumbers.nativePercent
|
||||||
this.appList.forEach( app => {
|
this.rosettaPercent = this.customNumbers.rosettaPercent
|
||||||
// console.log('app.status', app.status)
|
this.unreportedPercent = this.customNumbers.unreportedPercent
|
||||||
|
this.unsupportedPercent = this.customNumbers.unsupportedPercent
|
||||||
|
|
||||||
for (const statusKey in statuses) {
|
return
|
||||||
if (app.status === statuses[statusKey]) {
|
|
||||||
totals[app.status]++
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
const summaryNumbers = getListSummaryNumbers(this.appList)
|
||||||
|
|
||||||
// console.log('totals', totals)
|
this.nativePercent = summaryNumbers.nativePercent
|
||||||
|
this.rosettaPercent = summaryNumbers.rosettaPercent
|
||||||
this.nativePercent = Number((( totals['native'] / this.total ) * 100).toFixed(1))
|
this.unreportedPercent = summaryNumbers.unreportedPercent
|
||||||
this.rosettaPercent = Number((( totals['rosetta'] / this.total ) * 100).toFixed(1))
|
this.unsupportedPercent = summaryNumbers.unsupportedPercent
|
||||||
this.unreportedPercent = Number((( totals['unreported'] / this.total ) * 100).toFixed(1))
|
|
||||||
|
|
||||||
this.unsupportedPercent = Number((100 - (this.nativePercent + this.rosettaPercent + this.unreportedPercent)).toFixed(1))
|
|
||||||
|
|
||||||
// console.log('this.nativePercent', this.nativePercent)
|
// console.log('this.nativePercent', this.nativePercent)
|
||||||
// console.log('this.unsupportedPercent', this.unsupportedPercent)
|
// console.log('this.unsupportedPercent', this.unsupportedPercent)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="search w-full">
|
<div class="search w-full">
|
||||||
|
|
||||||
|
<slot name="before-search">
|
||||||
<div class="list-summary-wrapper flex justify-center text-center text-sm my-4">
|
<div class="list-summary-wrapper flex justify-center text-center text-sm my-4">
|
||||||
|
|
||||||
<ListSummary
|
<ListSummary
|
||||||
|
|
@ -8,6 +10,7 @@
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</slot>
|
||||||
|
|
||||||
<div class="search-input relative">
|
<div class="search-input relative">
|
||||||
<input
|
<input
|
||||||
|
|
|
||||||
43
helpers/get-list-summary-numbers.js
Normal file
43
helpers/get-list-summary-numbers.js
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
import statuses from '~/helpers/statuses'
|
||||||
|
|
||||||
|
export default function ( appList ) {
|
||||||
|
|
||||||
|
const totalApps = appList.length
|
||||||
|
|
||||||
|
// Create a totals object to collect amounts
|
||||||
|
const totals = {}
|
||||||
|
|
||||||
|
// Get status slugs from statuses
|
||||||
|
Object.entries(statuses).forEach( ([_, statusSlug]) => {
|
||||||
|
totals[statusSlug] = 0
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count uses of each status
|
||||||
|
appList.forEach( app => {
|
||||||
|
// console.log('app.status', app.status)
|
||||||
|
|
||||||
|
for (const statusKey in statuses) {
|
||||||
|
if (app.status === statuses[statusKey]) {
|
||||||
|
totals[app.status]++
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
// console.log('totals', totals)
|
||||||
|
|
||||||
|
const nativePercent = Number((( totals['native'] / totalApps ) * 100).toFixed(1))
|
||||||
|
const rosettaPercent = Number((( totals['rosetta'] / totalApps ) * 100).toFixed(1))
|
||||||
|
const unreportedPercent = Number((( totals['unreported'] / totalApps ) * 100).toFixed(1))
|
||||||
|
|
||||||
|
const unsupportedPercent = Number((100 - (nativePercent + rosettaPercent + unreportedPercent)).toFixed(1))
|
||||||
|
|
||||||
|
return {
|
||||||
|
total: totalApps,
|
||||||
|
nativePercent,
|
||||||
|
rosettaPercent,
|
||||||
|
unreportedPercent,
|
||||||
|
unsupportedPercent,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,8 +13,19 @@
|
||||||
:quick-buttons="quickButtons"
|
:quick-buttons="quickButtons"
|
||||||
:initial-limit="200"
|
:initial-limit="200"
|
||||||
@update:query="onQueryUpdate"
|
@update:query="onQueryUpdate"
|
||||||
|
>
|
||||||
|
<template v-slot:before-search>
|
||||||
|
<div class="list-summary-wrapper flex justify-center text-center text-sm my-4">
|
||||||
|
|
||||||
|
<ListSummary
|
||||||
|
:custom-numbers="customSummaryNumbers"
|
||||||
|
class="max-w-4xl"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Search>
|
||||||
|
|
||||||
<div class="flex flex-col md:flex-row space-x-0 space-y-4 md:space-y-0 md:space-x-4">
|
<div class="flex flex-col md:flex-row space-x-0 space-y-4 md:space-y-0 md:space-x-4">
|
||||||
<LinkButton
|
<LinkButton
|
||||||
:href="`https://github.com/ThatGuySam/doesitarm/issues?q=is%3Aissue+${query}`"
|
:href="`https://github.com/ThatGuySam/doesitarm/issues?q=is%3Aissue+${query}`"
|
||||||
|
|
@ -48,16 +59,21 @@
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
|
import getListSummaryNumbers from '~/helpers/get-list-summary-numbers.js'
|
||||||
|
|
||||||
import Search from '~/components/search.vue'
|
import Search from '~/components/search.vue'
|
||||||
import LinkButton from '~/components/link-button.vue'
|
import LinkButton from '~/components/link-button.vue'
|
||||||
import AllUpdatesSubscribe from '~/components/all-updates-subscribe.vue'
|
import AllUpdatesSubscribe from '~/components/all-updates-subscribe.vue'
|
||||||
|
import ListSummary from '~/components/list-summary.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async asyncData () {
|
async asyncData () {
|
||||||
// const { default: appList } = await import('~/static/app-list.json')
|
// const { default: appList } = await import('~/static/app-list.json')
|
||||||
// const { default: gamelist } = await import('~/static/game-list.json')
|
// const { default: gamelist } = await import('~/static/game-list.json')
|
||||||
|
|
||||||
const { sortedAppList } = await import('~/helpers/get-list.js')
|
const { sortedAppList, allList } = await import('~/helpers/get-list.js')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// Filter app list to leave out data not needed for search
|
// Filter app list to leave out data not needed for search
|
||||||
|
|
@ -71,13 +87,15 @@ export default {
|
||||||
lastUpdated: app.lastUpdated,
|
lastUpdated: app.lastUpdated,
|
||||||
category: app.category,
|
category: app.category,
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
|
customSummaryNumbers: getListSummaryNumbers(allList)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
Search,
|
Search,
|
||||||
LinkButton,
|
LinkButton,
|
||||||
AllUpdatesSubscribe
|
AllUpdatesSubscribe,
|
||||||
|
ListSummary
|
||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue