Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
feat: user ranks
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonHowe committed Jul 5, 2020
1 parent e4d3166 commit 8f59a83
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export const up = async (knex: Knex) => {
table.string("name").notNullable();
table.string("email").notNullable();
table.string("password").notNullable();
table.string("role");
table.string("role").notNullable();
table.integer("rank").notNullable();
table.string("description");
});
};
Expand Down
16 changes: 16 additions & 0 deletions packages/api/db/migrations/20200705082902_create_games_table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Knex from "knex";

export const up = async (knex: Knex) => {
return knex.schema.createTable("games", table => {
table.integer("gameid").notNullable();
table.integer("userid").notNullable();
table.integer("date").notNullable();
table.integer("wpm").notNullable();
table.integer("uncorrectedwpm").notNullable();
table.integer("accuracy").notNullable();
});
};

export const down = async (knex: Knex) => {
return knex.schema.dropTable("games");
};
19 changes: 12 additions & 7 deletions packages/api/db/seeds/examples/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface Users {
password: string;
role?: string | null;
description?: string | null;
rank: number;
}

export default [
Expand All @@ -12,27 +13,31 @@ export default [
email: "[email protected]",
password: "UserPass",
role: "admin",
description: null
description: null,
rank: 8
},
{
name: "MKGUN3",
email: "[email protected]",
password: "MaoGay",
role: null,
description: null
role: "member",
description: null,
rank: 4
},
{
name: "NotAUser",
email: "[email protected]",
password: "nothing",
role: null,
description: null
role: "member",
description: null,
rank: 2
},
{
name: "Guy2",
email: "[email protected]",
password: "JustAGuy",
role: null,
description: "But hey, I have a description!"
role: "member",
description: "But hey, I have a description!",
rank: 0
}
] as readonly Users[];
4 changes: 3 additions & 1 deletion packages/api/src/modules/users/actions/createUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export const createUser = async (
await knex<User>("users").insert(
{
...user,
password: encryptedPassword
role: "member",
password: encryptedPassword,
rank: 0
},
"*"
)
Expand Down
6 changes: 0 additions & 6 deletions packages/api/src/modules/users/types/PreviousUserGame.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/api/src/modules/users/types/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export default interface User {
email: string;
name: string;
password: string;
rank: number;
role?: string | null;
description?: string | null;
}

0 comments on commit 8f59a83

Please sign in to comment.