-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some edit + add kurami for setuppData command
- Loading branch information
Showing
9 changed files
with
269 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"commandsPath": "./Commands" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.