Skip to content

Commit

Permalink
some edit + add kurami for setuppData command
Browse files Browse the repository at this point in the history
  • Loading branch information
nesmon committed Mar 23, 2023
1 parent 3e6fc72 commit a2f5b48
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 15 deletions.
57 changes: 57 additions & 0 deletions Commands/pushDefaultValue.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const { BaseCommand } = require('kurami');
const { getFirestore, collection, addDoc } = require('firebase/firestore');
const chartData = require('./../charts.json');
const scoreData = require('../scores.cjs');
const { initializeApp } = require("firebase/app");

class pushDefaultValue extends BaseCommand {
constructor() {
super({
name: 'load:default:data',
description: 'Push some default charts and scores',
});
}

async run() {
const app = initializeApp({
// firebase config here
});

console.log('Pushing default data...')
console.log('Pushing default charts...')
await this.pushDefaultCharts();
console.log('Pushing default scores...')
await this.pushDefaultScores();
console.log('Done!')
}

async pushDefaultCharts() {
// push chartData content to firestore
const db = getFirestore();
const chartsRef = collection(db, 'Chart');
for (let i = 0; i < chartData.length; i++) {
const chart = chartData[i];
await addDoc(chartsRef, chart).then((docRef) => {
console.log("Document written with ID: ", docRef.id);
}).catch((error) => {
console.error("Error adding document: ", error);
});
}
}

async pushDefaultScores() {
// push scoreData content to firestore
const db = getFirestore();
const scoresRef = collection(db, 'Score');
for (let i = 0; i < scoreData.length; i++) {
const score = scoreData[i];
await addDoc(scoresRef, score).then((docRef) => {
console.log("Document written with ID: ", docRef.id);
}).catch((error) => {
console.error("Error adding document: ", error);
});
}
}
}

module.exports = pushDefaultValue;
12 changes: 8 additions & 4 deletions src/charts.json → charts.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[
{
"id": "axe611acu8",
"name" : "Axeria",
"artist": "AcuticNotes",
"category": "Original",
"category": "original",
"difficulty" : [
{
"Easy": "4",
Expand All @@ -15,9 +16,10 @@
"imageCover": "https://silentblue.remywiki.com/images/d/d8/Axeria.png"
},
{
"id": "our1110t+p8",
"name" : "Our Wrenaly",
"artist": "t+pazolite",
"category": "Original",
"category": "original",
"difficulty" : [
{
"Easy": "4",
Expand All @@ -30,9 +32,10 @@
"imageCover": "https://silentblue.remywiki.com/images/0/05/Our_Wrenally.png"
},
{
"id": "mil57mil4",
"name" : "Milk",
"artist": "モリモリあつし",
"category": "GAME & VARIETY",
"category": "game",
"difficulty" : [
{
"Easy": "1",
Expand All @@ -45,9 +48,10 @@
"imageCover": "https://silentblue.remywiki.com/images/e/eb/MilK.png"
},
{
"id": "pandora_paradoxxx",
"name" : "Pandora Paradoxxx",
"artist": "Sakuzyo",
"category": "Original",
"category": "original",
"difficulty" : [
{
"Easy": "6",
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
<title>MaiScore</title>
</head>
<body>
<div id="root"></div>
Expand Down
3 changes: 3 additions & 0 deletions kurami.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"commandsPath": "./Commands"
}
99 changes: 99 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
"preview": "vite preview",
"kurami": "kurami"
},
"dependencies": {
"@headlessui/react": "^1.7.13",
"@heroicons/react": "^2.0.16",
"@tailwindcss/forms": "^0.5.3",
"firebase": "^9.18.0",
"kurami": "^1.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.9.0"
Expand Down
67 changes: 67 additions & 0 deletions scores.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const scores = [
{
"chartId": "axe611acu8",
"difficulty": "Master",
"rank": "A",
"pseudo": "Nenes",
"score": "21234",
"accuracy": "87.34",
"date": new Date(),
},
{
"chartId": "axe611acu8",
"difficulty": "Master",
"rank": "A",
"pseudo": "Megumi",
"score": "21224",
"accuracy": "84.34",
"date": new Date(),
},
{
"chartId": "our1110t+p8",
"difficulty": "Expert",
"rank": "A",
"pseudo": "MrDuck",
"score": "2123",
"accuracy": "80.34",
"date": new Date(),
},
{
"chartId": "mil57mil4",
"difficulty": "Expert",
"rank": "A",
"pseudo": "Nenes",
"score": "21234",
"accuracy": "87.34",
"date": new Date(),
},
{
"chartId": "axe611acu8",
"difficulty": "Advance",
"rank": "A",
"pseudo": "Megumi",
"score": "21224",
"accuracy": "84.34",
"date": new Date(),
},
{
"chartId": "mil57mil4",
"difficulty": "Expert",
"rank": "A",
"pseudo": "MrDuck",
"score": "2123",
"accuracy": "80.34",
"date": new Date(),
},
{
"chartId": "pandora_paradoxxx",
"difficulty": "Expert",
"rank": "S",
"pseudo": "Nenes",
"score": "21233",
"accuracy": "98,03",
"date": new Date(),
}
]

module.exports = scores;
Loading

0 comments on commit a2f5b48

Please sign in to comment.