mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-04 04:51:16 +08:00
moved subschemas
This commit is contained in:
parent
c53138ce1c
commit
faf10edc2d
7 changed files with 144 additions and 112 deletions
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
//This is the mongo model for a user
|
||||
{
|
||||
"uid": 'uid',
|
||||
"presets": [
|
||||
//unknown whats inside here
|
||||
//can be added once one is added, and not created as blank
|
||||
],
|
||||
"name",
|
||||
"discordId",
|
||||
"pairingCode",
|
||||
"discordPairingCode",
|
||||
"config",
|
||||
"favouriteThemes",
|
||||
"refactored",
|
||||
"globalStats": {
|
||||
"timeTests",
|
||||
"startedTests",
|
||||
"completedTests"
|
||||
},
|
||||
"banned",
|
||||
"verified",
|
||||
"emailVerified",
|
||||
"lbMemory": {
|
||||
"time15",
|
||||
"time60"
|
||||
}
|
||||
snap.name = data.name;
|
||||
snap.discordId = data.discordId;
|
||||
snap.pairingCode =
|
||||
data.discordPairingCode == null ? undefined : data.discordPairingCode;
|
||||
snap.config = data.config;
|
||||
snap.favouriteThemes =
|
||||
data.favouriteThemes === undefined ? [] : data.favouriteThemes;
|
||||
snap.refactored = data.refactored === true ? true : false;
|
||||
snap.globalStats = {
|
||||
time: data.timeTyping,
|
||||
started: data.startedTests,
|
||||
completed: data.completedTests,
|
||||
};
|
||||
snap.banned = data.banned;
|
||||
snap.verified = data.verified;
|
||||
snap.emailVerified = user.emailVerified;
|
||||
try {
|
||||
if (data.lbMemory.time15 !== undefined) {
|
||||
snap.lbMemory.time15 = data.lbMemory.time15;
|
||||
}
|
||||
if (data.lbMemory.time60 !== undefined) {
|
||||
snap.lbMemory.time60 = data.lbMemory.time60;
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
//The user object returned by firebase.auth().currentUser
|
||||
// should this be retrieved from the server everytime or is it stored in the browser
|
||||
// probably browser
|
||||
{
|
||||
"uid",
|
||||
"name",
|
||||
"emailVerified",
|
||||
"displayName",
|
||||
"refreshToken",
|
||||
//guessing there is an access token in there somewhere, but I really don't know how this works
|
||||
}
|
||||
*/
|
78
backend/models/subschemas/config.js
Normal file
78
backend/models/subschemas/config.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
const mongoose = require("mongoose");
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const configSchema = new Schema({
|
||||
theme: { type: String },
|
||||
customTheme: Boolean,
|
||||
customThemeColors: [{ type: String }],
|
||||
favThemes: [{ type: String }],
|
||||
showKeyTips: Boolean,
|
||||
showLiveWpm: Boolean,
|
||||
showTimerProgress: Boolean,
|
||||
smoothCaret: Boolean,
|
||||
quickTab: Boolean,
|
||||
punctuation: Boolean,
|
||||
numbers: Boolean,
|
||||
words: Number,
|
||||
time: Number,
|
||||
mode: String,
|
||||
quoteLength: [{ type: Number }], //not sure why this is an array
|
||||
language: String,
|
||||
fontSize: Number,
|
||||
freedomMode: Boolean,
|
||||
difficulty: String,
|
||||
blindMode: Boolean,
|
||||
quickEnd: Boolean,
|
||||
caretStyle: String,
|
||||
paceCaretStyle: String,
|
||||
flipTestColors: Boolean,
|
||||
capsLockBackspace: Boolean,
|
||||
layout: String,
|
||||
confidenceMode: String,
|
||||
indicateTypos: Boolean,
|
||||
timerStyle: String,
|
||||
colorfulMode: Boolean,
|
||||
randomTheme: String, //feels like this should be a boolean
|
||||
timerColor: String,
|
||||
timerOpacity: String, //maybe should be a number
|
||||
stopOnError: String,
|
||||
showAllLines: Boolean,
|
||||
keymapMode: String,
|
||||
keymapStyle: String,
|
||||
keymapLegendStyle: String,
|
||||
keymapLayout: String,
|
||||
fontFamily: String,
|
||||
smoothLineScroll: Boolean,
|
||||
alwaysShowDecimalPlaces: Boolean,
|
||||
alwaysShowWordsHistory: Boolean,
|
||||
singleListCommandLine: String,
|
||||
playSoundOnError: Boolean,
|
||||
playSoundOnClick: String,
|
||||
startGraphsAtZero: Boolean,
|
||||
swapEscAndTab: Boolean,
|
||||
showOutOfFocusWarning: Boolean,
|
||||
paceCaret: String,
|
||||
paceCaretCustomSpeed: Number,
|
||||
pageWidth: String,
|
||||
chartAccuracy: Boolean,
|
||||
chartStyle: String,
|
||||
minWpm: String,
|
||||
minWpmCustomSpeed: Number,
|
||||
highlightMode: String,
|
||||
alwaysShowCPM: Boolean,
|
||||
enableAds: String,
|
||||
hideExtraLetters: Boolean,
|
||||
strictSpace: Boolean,
|
||||
minAcc: String,
|
||||
minAccCustom: Number,
|
||||
showLiveAcc: Boolean,
|
||||
monkey: Boolean,
|
||||
repeatQuotes: String,
|
||||
oppositeShiftMode: String,
|
||||
customBackground: String,
|
||||
customBackgroundSize: String,
|
||||
customBackgroundFilter: [{ type: Number }],
|
||||
customLayoutfluid: String,
|
||||
});
|
||||
|
||||
module.exports = { configSchema };
|
10
backend/models/subschemas/preset.js
Normal file
10
backend/models/subschemas/preset.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
const mongoose = require("mongoose");
|
||||
const Schema = mongoose.Schema;
|
||||
const { configSchema } = require("./config");
|
||||
|
||||
const presetSchema = new Schema({
|
||||
name: { type: String, required: true },
|
||||
config: { type: configSchema }, //not sure if preset config always follows config schema
|
||||
});
|
||||
|
||||
module.exports = { presetSchema };
|
38
backend/models/subschemas/result.js
Normal file
38
backend/models/subschemas/result.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
const mongoose = require("mongoose");
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const resultSchema = new Schema({
|
||||
wpm: { type: Number, required: true },
|
||||
rawWpm: { type: Number, required: true },
|
||||
correctChars: { type: Number, required: true },
|
||||
incorrectChars: { type: Number, required: true },
|
||||
allChars: { type: Number, required: true },
|
||||
acc: { type: Number, required: true },
|
||||
mode: { type: String, required: true }, //is this always string type?
|
||||
mode2: { type: Number, required: true }, //is this always number type?
|
||||
quoteLength: { type: Number, required: true },
|
||||
timestamp: { type: Number, required: true }, //can this be removed if timestamps are added to mongoose
|
||||
language: { type: String, required: true },
|
||||
restartCount: { type: Number, required: true },
|
||||
incompleteTestSeconds: { type: Number, required: true },
|
||||
testDuration: { type: Number, required: true },
|
||||
afkDuration: { type: Number, required: true },
|
||||
theme: { type: String, required: true },
|
||||
tags: [{ type: String }], //the id of each tag
|
||||
keySpacing: { type: String, required: true },
|
||||
keyDuration: { type: String, required: true },
|
||||
consistency: { type: Number, required: true },
|
||||
keyConsistency: { type: Number, required: true },
|
||||
chartData: {
|
||||
//should chartData have it's own schema?
|
||||
wpm: [{ type: Number }],
|
||||
raw: [{ type: Number }],
|
||||
err: [{ type: Number }],
|
||||
},
|
||||
customText: { type: Schema.Types.Mixed },
|
||||
keySpacingStats: { type: Schema.Types.Mixed }, //not sure that this needs to exist, it's set as null in all of mine
|
||||
name: { type: String, required: true }, //name of the user who took the test //should probably be typistName/username or something
|
||||
isPb: { type: Boolean, required: true },
|
||||
});
|
||||
|
||||
module.exports = { resultSchema };
|
9
backend/models/subschemas/tag.js
Normal file
9
backend/models/subschemas/tag.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
const mongoose = require("mongoose");
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tagSchema = new Schema({
|
||||
name: { type: String, required: true },
|
||||
personalBests: { type: Schema.Types.Mixed },
|
||||
});
|
||||
|
||||
module.exports = { tagSchema };
|
|
@ -1,51 +1,10 @@
|
|||
const mongoose = require("mongoose");
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tagSchema = new Schema({
|
||||
name: { type: String, required: true },
|
||||
personalBests: { type: Schema.Types.Mixed },
|
||||
});
|
||||
|
||||
const presetSchema = new Schema({
|
||||
name: { type: String, required: true },
|
||||
config: { type: Schema.Types.Mixed }, //will be config schema after it's created
|
||||
});
|
||||
|
||||
const resultSchema = new Schema({
|
||||
wpm: { type: Number, required: true },
|
||||
rawWpm: { type: Number, required: true },
|
||||
correctChars: { type: Number, required: true },
|
||||
incorrectChars: { type: Number, required: true },
|
||||
allChars: { type: Number, required: true },
|
||||
acc: { type: Number, required: true },
|
||||
mode: { type: String, required: true }, //is this always string type?
|
||||
mode2: { type: Number, required: true }, //is this always number type?
|
||||
quoteLength: { type: Number, required: true },
|
||||
timestamp: { type: Number, required: true }, //can this be removed if timestamps are added to mongoose
|
||||
language: { type: String, required: true },
|
||||
restartCount: { type: Number, required: true },
|
||||
incompleteTestSeconds: { type: Number, required: true },
|
||||
testDuration: { type: Number, required: true },
|
||||
afkDuration: { type: Number, required: true },
|
||||
theme: { type: String, required: true },
|
||||
tags: [{ type: String }], //the id of each tag
|
||||
keySpacing: { type: String, required: true },
|
||||
keyDuration: { type: String, required: true },
|
||||
consistency: { type: Number, required: true },
|
||||
keyConsistency: { type: Number, required: true },
|
||||
chartData: {
|
||||
//should chartData have it's own schema?
|
||||
wpm: [{ type: Number }],
|
||||
raw: [{ type: Number }],
|
||||
err: [{ type: Number }],
|
||||
},
|
||||
customText: { type: Schema.Types.Mixed },
|
||||
keySpacingStats: { type: Schema.Types.Mixed }, //not sure that this needs to exist, it's set as null in all of mine
|
||||
name: { type: String, required: true }, //name of the user who took the test //should probably be typistName/username or something
|
||||
isPb: { type: Boolean, required: true },
|
||||
});
|
||||
|
||||
const configSchema = new Schema({});
|
||||
const { configSchema } = require("./subschemas/config");
|
||||
const { resultSchema } = require("./subschemas/result");
|
||||
const { tagSchema } = require("./subschemas/tag");
|
||||
const { presetSchema } = require("./subschemas/preset");
|
||||
|
||||
const userSchema = new Schema(
|
||||
{
|
||||
|
@ -83,7 +42,7 @@ const userSchema = new Schema(
|
|||
email: { type: String, required: true },
|
||||
password: { type: String, required: true },
|
||||
refreshTokens: [{ type: String, required: true }],
|
||||
config: { type: Schema.Types.Mixed, default: {} },
|
||||
config: { type: configSchema, default: {} },
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
- Get google login working
|
||||
- Transfer leaderboard and other cloud functions
|
||||
- Reverse list of results on account page
|
||||
- spinning wheel on account page should dissapear after data is loaded
|
||||
- Account data should be updated when new result is added/test completed
|
||||
- Add email verification
|
||||
|
@ -22,6 +21,10 @@
|
|||
- Create configSchema
|
||||
- Figure out if filteredResults.reverse(); in account.js is going to cause efficiency issues
|
||||
- Could reverse processing of results, but that would add more complexity to code
|
||||
- In order to transfer users over, users should be able to be validated through firebase until they login again, when they will use their password to login. If firebase confirms that the password and email are valid, the new password will be hashed and saved to the new database
|
||||
- All data is moved and retrieved via the mongo server, just authentication uses firebase
|
||||
- Could force users to sign in again immediately in order to transfer users' passwords faster
|
||||
- Is it worth the inconvenience though.
|
||||
|
||||
## After beta is ready
|
||||
|
||||
|
|
Loading…
Reference in a new issue