diff --git a/.gitignore b/.gitignore
index 68f19bd..ae3c1ec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ data
.nitro
.cache
dist
+storage
# Node dependencies
node_modules
diff --git a/app/pages/charts.vue b/app/pages/charts.vue
index 43943c5..f1b29d3 100644
--- a/app/pages/charts.vue
+++ b/app/pages/charts.vue
@@ -113,7 +113,7 @@ const sideBarOpen = ref(false);
@@ -134,7 +134,7 @@ const sideBarOpen = ref(false);
=> {
case "major": {
return gameVersions.major;
}
- default: {
+ case "minor": {
return gameVersions.minor;
}
+ case "unified": {
+ return gameVersions.unified;
+ }
+ default: {
+ setResponseStatus(event, 400);
+ return [];
+ }
}
});
diff --git a/server/plugins/storage.ts b/server/plugins/storage.ts
index fa0442e..605eab4 100644
--- a/server/plugins/storage.ts
+++ b/server/plugins/storage.ts
@@ -1,6 +1,15 @@
+import fsDriver from "unstorage/drivers/fs";
import upstashDriver from "unstorage/drivers/upstash";
export default defineNitroPlugin(() => {
+ if (import.meta.dev) {
+ defineDevelopmentStorage();
+ } else {
+ defnineProductionStorage();
+ }
+});
+
+function defnineProductionStorage() {
const storage = useStorage();
storage.mount(
@@ -27,4 +36,27 @@ export default defineNitroPlugin(() => {
base: "metadata",
}),
);
-});
+}
+
+function defineDevelopmentStorage() {
+ const storage = useStorage();
+
+ storage.mount(
+ "globalStatistics",
+ fsDriver({
+ base: "storage/globalStatistics",
+ }),
+ );
+ storage.mount(
+ "projectStatistics",
+ fsDriver({
+ base: "storage/projectStatistics",
+ }),
+ );
+ storage.mount(
+ "metadata",
+ fsDriver({
+ base: "storage/metadata",
+ }),
+ );
+}
diff --git a/server/utils/processing/gameVersions/processing.ts b/server/utils/processing/gameVersions/processing.ts
index c2eb63c..0c29e87 100644
--- a/server/utils/processing/gameVersions/processing.ts
+++ b/server/utils/processing/gameVersions/processing.ts
@@ -23,6 +23,7 @@ export function getSupportedGameVersions(
all: new Set(),
major: new Set(),
minor: new Set(),
+ unified: new Set(),
};
for (const gameVersion of version.game_versions) {
@@ -39,12 +40,19 @@ export function getSupportedGameVersions(
data.minor.add(minorVersion.name);
}
}
+
+ for (const unifiedVersion of gameVersions.unified) {
+ if (unifiedVersion.contains.includes(gameVersion)) {
+ data.unified.add(unifiedVersion.name);
+ }
+ }
}
return {
all: Array.from(data.all),
major: Array.from(data.major),
minor: Array.from(data.minor),
+ unified: Array.from(data.unified),
};
}
@@ -84,9 +92,16 @@ function groupGameVersions(versions: GameVersion[]): GameVersions {
major[major.length - 1]?.contains.push(...version.contains);
}
+ const unified: GameVersionData = [{ name: "unified", contains: [] }];
+
+ for (const version of major) {
+ unified[0].contains.push(...version.contains);
+ }
+
return {
all,
minor,
major,
+ unified,
};
}
diff --git a/server/utils/processing/gameVersions/types.ts b/server/utils/processing/gameVersions/types.ts
index 70a5c73..70214dc 100644
--- a/server/utils/processing/gameVersions/types.ts
+++ b/server/utils/processing/gameVersions/types.ts
@@ -5,7 +5,7 @@ export type GameVersion = {
export type GameVersionData = { name: string; contains: string[] }[];
-export type VersionCategories = "all" | "major" | "minor";
+export type VersionCategories = "all" | "major" | "minor" | "unified";
export type GameVersions = Record;
export type SupportedVersions = Record;
diff --git a/server/utils/processing/projects/processing.ts b/server/utils/processing/projects/processing.ts
index cec6710..53171b6 100644
--- a/server/utils/processing/projects/processing.ts
+++ b/server/utils/processing/projects/processing.ts
@@ -31,6 +31,7 @@ type StatsDataEntry = {
all: StatsDataType;
minor: StatsDataType;
major: StatsDataType;
+ unified: StatsDataType;
};
type StatsData = { all: StatsDataEntry; exclusive: StatsDataEntry };
@@ -39,6 +40,7 @@ type AllStatsEntry = {
all: ProjectStats;
minor: ProjectStats;
major: ProjectStats;
+ unified: ProjectStats;
};
type AllStats = { all: AllStatsEntry; exclusive: AllStatsEntry };
@@ -77,17 +79,29 @@ async function saveStats(stats: AllStats, type: ProjectTypes) {
await DB.ProjectStats.set(stats.all.all, type, "all", false);
await DB.ProjectStats.set(stats.all.minor, type, "minor", false);
await DB.ProjectStats.set(stats.all.major, type, "major", false);
+ await DB.ProjectStats.set(stats.all.unified, type, "unified", false);
await DB.ProjectStats.set(stats.exclusive.all, type, "all", true);
await DB.ProjectStats.set(stats.exclusive.minor, type, "minor", true);
await DB.ProjectStats.set(stats.exclusive.major, type, "major", true);
+ await DB.ProjectStats.set(stats.exclusive.unified, type, "unified", true);
}
async function getStatistics(type: ProjectTypes): Promise {
const BATCH_COUNT = import.meta.dev ? 1 : 10;
const data: StatsData = {
- all: { all: new Map(), major: new Map(), minor: new Map() },
- exclusive: { all: new Map(), major: new Map(), minor: new Map() },
+ all: {
+ all: new Map(),
+ major: new Map(),
+ minor: new Map(),
+ unified: new Map(),
+ },
+ exclusive: {
+ all: new Map(),
+ major: new Map(),
+ minor: new Map(),
+ unified: new Map(),
+ },
};
const gameVersions = await DB.GameVersions.get();
@@ -131,6 +145,9 @@ async function getStatistics(type: ProjectTypes): Promise {
all: groupStatsToStats(StatsFromType(gameVersions.all, data.all)),
minor: groupStatsToStats(StatsFromType(gameVersions.minor, data.minor)),
major: groupStatsToStats(StatsFromType(gameVersions.major, data.major)),
+ unified: groupStatsToStats(
+ StatsFromType(gameVersions.unified, data.unified),
+ ),
};
}
@@ -212,6 +229,13 @@ function analyzeVersions(
version.project_id,
version.downloads,
);
+ insertLauncherData(
+ data.all.unified,
+ supportedLaunchers,
+ supportedVersions.unified,
+ version.project_id,
+ version.downloads,
+ );
if (supportedLaunchers.length === 1) {
insertLauncherData(
@@ -235,6 +259,13 @@ function analyzeVersions(
version.project_id,
version.downloads,
);
+ insertLauncherData(
+ data.exclusive.unified,
+ supportedLaunchers,
+ supportedVersions.unified,
+ version.project_id,
+ version.downloads,
+ );
}
}
}