Cache info for 10 hours
This commit is contained in:
parent
219d76059d
commit
df320a2ad4
3 changed files with 81 additions and 29 deletions
|
@ -4,6 +4,7 @@ import header from "./header.json";
|
||||||
import homepage from "./views/homepage.json";
|
import homepage from "./views/homepage.json";
|
||||||
import download from "./views/download.json";
|
import download from "./views/download.json";
|
||||||
import contribute from "./views/contribute.json";
|
import contribute from "./views/contribute.json";
|
||||||
|
import compatibility from "./views/compatibility.json";
|
||||||
|
|
||||||
export const en = {
|
export const en = {
|
||||||
navigations: navigations,
|
navigations: navigations,
|
||||||
|
@ -12,6 +13,7 @@ export const en = {
|
||||||
views: {
|
views: {
|
||||||
homepage: homepage,
|
homepage: homepage,
|
||||||
download: download,
|
download: download,
|
||||||
contribute: contribute
|
contribute: contribute,
|
||||||
|
compatibility: compatibility
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
9
src/i18n/locales/en/views/compatibility.json
Normal file
9
src/i18n/locales/en/views/compatibility.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"title": "Compatibility",
|
||||||
|
"description": "Ryujinx sure can play a lot of games",
|
||||||
|
"playable": "Playable",
|
||||||
|
"ingame": "In-Game",
|
||||||
|
"menus": "Menus",
|
||||||
|
"boots": "Boots",
|
||||||
|
"nothing": "Nothing"
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import { onMounted, ref } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { Doughnut } from "vue-chartjs";
|
import { Doughnut } from "vue-chartjs";
|
||||||
import { Chart, ArcElement, Title, Legend, Tooltip, Colors, ChartData, ChartOptions, elements } from 'chart.js'
|
import { Chart, ArcElement, Title, Legend, Tooltip, Colors, ChartData, ChartOptions, elements } from 'chart.js'
|
||||||
|
import { stat } from "fs";
|
||||||
|
|
||||||
Chart.register(ArcElement, Title, Legend, Tooltip, Colors);
|
Chart.register(ArcElement, Title, Legend, Tooltip, Colors);
|
||||||
|
|
||||||
|
@ -12,35 +13,35 @@ const { t } = useI18n();
|
||||||
const tierData = ref<PlayableTier[]>([
|
const tierData = ref<PlayableTier[]>([
|
||||||
{
|
{
|
||||||
labelName: "status-playable",
|
labelName: "status-playable",
|
||||||
prettyPrintName: "Playable",
|
displayName: "playable",
|
||||||
// Tailwind Emerald-600
|
// Tailwind Emerald-600
|
||||||
color: "#059669",
|
color: "#059669",
|
||||||
count: 0
|
count: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
labelName: "status-ingame",
|
labelName: "status-ingame",
|
||||||
prettyPrintName: "In-Game",
|
displayName: "ingame",
|
||||||
// Tailwind Lime-600
|
// Tailwind Lime-600
|
||||||
color: "#65a30d",
|
color: "#65a30d",
|
||||||
count: 0
|
count: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
labelName: "status-menus",
|
labelName: "status-menus",
|
||||||
prettyPrintName: "Menus",
|
displayName: "menus",
|
||||||
// Tailwind Yellow-600
|
// Tailwind Yellow-600
|
||||||
color: "#ca8a04",
|
color: "#ca8a04",
|
||||||
count: 0
|
count: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
labelName: "status-boots",
|
labelName: "status-boots",
|
||||||
prettyPrintName: "Boots",
|
displayName: "boots",
|
||||||
// Tailwind Orange-600
|
// Tailwind Orange-600
|
||||||
color: "#ea580c",
|
color: "#ea580c",
|
||||||
count: 0
|
count: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
labelName: "status-nothing",
|
labelName: "status-nothing",
|
||||||
prettyPrintName: "Nothing",
|
displayName: "nothing",
|
||||||
// Tailwind Red-600
|
// Tailwind Red-600
|
||||||
color: "#dc2626",
|
color: "#dc2626",
|
||||||
count: 0
|
count: 0
|
||||||
|
@ -53,32 +54,72 @@ onMounted(() => {
|
||||||
|
|
||||||
interface PlayableTier {
|
interface PlayableTier {
|
||||||
labelName: string;
|
labelName: string;
|
||||||
prettyPrintName: string;
|
displayName: string;
|
||||||
color: string;
|
color: string;
|
||||||
count: number;
|
count: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setWithExpiry(key: string, value: PlayableTier[], ttl: number) {
|
||||||
|
const now = new Date()
|
||||||
|
|
||||||
|
const item = {
|
||||||
|
value: value,
|
||||||
|
expiry: now.getTime() + (ttl * 60 * 60 * 1000),
|
||||||
|
}
|
||||||
|
localStorage.setItem(key, JSON.stringify(item))
|
||||||
|
}
|
||||||
|
|
||||||
|
function getWithExpiry(key: string): PlayableTier[] {
|
||||||
|
const itemStr = localStorage.getItem(key)
|
||||||
|
if (!itemStr) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
const item = JSON.parse(itemStr)
|
||||||
|
const now = new Date()
|
||||||
|
if (now.getTime() > item.expiry) {
|
||||||
|
localStorage.removeItem(key)
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.value
|
||||||
|
}
|
||||||
|
|
||||||
|
function setData() {
|
||||||
|
chartData.value = ({
|
||||||
|
labels: tierData.value.flatMap((tier) => tier.displayName),
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
data: tierData.value.flatMap((tier) => tier.count),
|
||||||
|
backgroundColor: tierData.value.flatMap((tier) => tier.color),
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const fetchStats = async () => {
|
const fetchStats = async () => {
|
||||||
try {
|
var stats = getWithExpiry("git-stats");
|
||||||
await Promise.all(tierData.value.map(async tier => {
|
if (stats.length == 0) {
|
||||||
const result = await axios.get<IssueSearch>(
|
try {
|
||||||
`${import.meta.env.VITE_LABEL_SEARCH_URL}label:${tier.labelName}+state:open`
|
await Promise.all(tierData.value.map(async tier => {
|
||||||
);
|
const result = await axios.get<IssueSearch>(
|
||||||
|
`${import.meta.env.VITE_LABEL_SEARCH_URL}label:${tier.labelName}+state:open`
|
||||||
|
);
|
||||||
|
|
||||||
tier.count = result.data.total_count;
|
tier.displayName = t("view.compatibility." + tier.displayName);
|
||||||
}));
|
console.log(t("view.compatibility.playable"));
|
||||||
|
tier.count = result.data.total_count;
|
||||||
|
}));
|
||||||
|
|
||||||
chartData.value = ({
|
setWithExpiry("git-stats", tierData.value, 10);
|
||||||
labels: tierData.value.flatMap((tier) => tier.prettyPrintName),
|
setData();
|
||||||
datasets: [
|
} catch (err) {
|
||||||
{
|
console.error(err);
|
||||||
data: tierData.value.flatMap((tier) => tier.count),
|
}
|
||||||
backgroundColor: tierData.value.flatMap((tier) => tier.color),
|
} else {
|
||||||
}
|
tierData.value = stats;
|
||||||
]
|
|
||||||
})
|
setData();
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,10 +150,10 @@ const chartOptions = {
|
||||||
<div class="space-y-16 container xl:max-w-7xl mx-auto px-4 py-16 lg:px-8 lg:py-32">
|
<div class="space-y-16 container xl:max-w-7xl mx-auto px-4 py-16 lg:px-8 lg:py-32">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="text-3xl md:text-4xl font-extrabold mb-4">
|
<h2 class="text-3xl md:text-4xl font-extrabold mb-4">
|
||||||
Compatibility
|
{{ t("views.compatibility.title") }}
|
||||||
</h2>
|
</h2>
|
||||||
<h3 class="text-lg md:text-xl md:leading-relaxed font-medium text-gray-600 lg:w-2/3 mx-auto">
|
<h3 class="text-lg md:text-xl md:leading-relaxed font-medium text-gray-600 lg:w-2/3 mx-auto">
|
||||||
{{ t("views.homepage.ourTeamDescription") }}
|
{{ t("views.compatibility.description") }}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue