Skip to content

Commit

Permalink
[finishes #187584911] Seller statistics per timeframe
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgrammerDATCH committed Jun 5, 2024
1 parent 0f1814c commit c0f6287
Show file tree
Hide file tree
Showing 28 changed files with 339 additions and 263 deletions.
32 changes: 26 additions & 6 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 @@ -92,7 +92,8 @@
"swagger-ui-express": "^5.0.0",
"ts-node": "^10.9.2",
"ts-node-dev": "^2.0.0",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"uuid": "^9.0.1"
},
"devDependencies": {
"@types/bcrypt": "^5.0.2",
Expand All @@ -107,6 +108,7 @@
"@types/sequelize": "^4.28.20",
"@types/swagger-jsdoc": "^6.0.4",
"@types/swagger-ui-express": "^4.1.6",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"eslint": "^8.57.0",
Expand Down
4 changes: 2 additions & 2 deletions src/databases/migrations/20240520180022-create-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export default {

await queryInterface.createTable("users", {
id: {
type: DataTypes.INTEGER,
type: DataTypes.UUID,
allowNull: false,
autoIncrement: true,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
firstName: {
Expand Down
7 changes: 4 additions & 3 deletions src/databases/migrations/20240521161805-create-shops-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ export = {
up: async (queryInterface: QueryInterface) => {
await queryInterface.createTable("shops", {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
type: DataTypes.UUID,
allowNull: false,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
userId: {
type: DataTypes.INTEGER,
type: DataTypes.UUID,
allowNull: false,
references: {
model: "users",
Expand Down
7 changes: 4 additions & 3 deletions src/databases/migrations/20240523180022-create-sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ export default {
up: async (queryInterface: QueryInterface) => {
await queryInterface.createTable("sessions", {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
type: DataTypes.UUID,
allowNull: false,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
userId: {
type: new DataTypes.INTEGER,
type: new DataTypes.UUID,
allowNull: false
},
device: {
Expand Down
12 changes: 6 additions & 6 deletions src/databases/migrations/20240601223523-create-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ export default {
up:async(queryInterface: QueryInterface, Sequelize: Sequelize)=> {
await queryInterface.createTable("collection", {
id: {
type: DataTypes.UUID,
allowNull: false,
primaryKey: true,
type: DataTypes.INTEGER,
autoIncrement: true
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
name: {
allowNull: false,
type: DataTypes.STRING(128)
},
sellerId: {
shopId: {
allowNull: false,
type: DataTypes.INTEGER,
type: DataTypes.UUID,
references: {
model: "users",
model: "shops",
key: "id"
},
onDelete: "CASCADE"
Expand Down
14 changes: 7 additions & 7 deletions src/databases/migrations/20240601223524-create-products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { QueryInterface, DataTypes } from "sequelize";
export default{
up :async (queryInterface: QueryInterface, Sequelize: any)=> {
await queryInterface.createTable("Products", {
id: {
allowNull: false,
primaryKey: true,
type: DataTypes.INTEGER,
autoIncrement: true
id: {
type: DataTypes.UUID,
allowNull: false,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
name: {
allowNull: false,
Expand Down Expand Up @@ -42,7 +42,7 @@ export default{
},
collectionId: {
allowNull: false,
type: DataTypes.INTEGER,
type: DataTypes.UUID,
references: {
model: "collection",
key: "id"
Expand All @@ -51,7 +51,7 @@ export default{
},
shopId: {
allowNull: false,
type: DataTypes.INTEGER,
type: DataTypes.UUID,
references: {
model: "shops",
key: "id"
Expand Down
11 changes: 6 additions & 5 deletions src/databases/migrations/20240603150804-create-orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ export = {
up: async (queryInterface: QueryInterface) => {
await queryInterface.createTable("orders", {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
type: DataTypes.UUID,
allowNull: false,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
userId: {
type: DataTypes.INTEGER,
type: DataTypes.UUID,
allowNull: false,
references: {
model: "users",
Expand All @@ -19,10 +20,10 @@ export = {
onDelete: "CASCADE"
},
shopId: {
type: DataTypes.INTEGER,
type: DataTypes.UUID,
allowNull: false,
references: {
model: "users",
model: "shops",
key: "id"
},
onUpdate: "CASCADE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ export = {
up: async (queryInterface: QueryInterface) => {
await queryInterface.createTable("order_products", {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
type: DataTypes.UUID,
allowNull: false,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
productId: {
type: DataTypes.INTEGER,
type: DataTypes.UUID,
allowNull: false,
references: {
model: "Products",
Expand All @@ -19,7 +20,7 @@ export = {
onDelete: "CASCADE"
},
orderId: {
type: DataTypes.INTEGER,
type: DataTypes.UUID,
allowNull: false,
references: {
model: "orders",
Expand Down
14 changes: 7 additions & 7 deletions src/databases/models/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ import { ICollection } from "../../types";

class collection extends Model<ICollection> {
declare id: number;
declare sellerId: number;
declare shopId: number;
declare name: string;
declare description?: string;
}

collection.init(
{
id: {
type: DataTypes.INTEGER,
type: DataTypes.UUID,
allowNull: false,
autoIncrement: true,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
sellerId: {
},
shopId: {
allowNull: false,
type: DataTypes.INTEGER,
type: DataTypes.UUID,
references: {
model: "users",
model: "shops",
key: "id"
},
onDelete: "CASCADE"
Expand Down
11 changes: 6 additions & 5 deletions src/databases/models/orderProducts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ class OrderProduct extends Model<OrderProductAttributes> implements OrderProduct
OrderProduct.init(
{
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
type: DataTypes.UUID,
allowNull: false,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
},
productId: {
type: new DataTypes.INTEGER,
type: new DataTypes.UUID,
allowNull: false
},
orderId: {
type: new DataTypes.INTEGER,
type: new DataTypes.UUID,
allowNull: false
},
quantity: {
Expand Down
11 changes: 6 additions & 5 deletions src/databases/models/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@ class Order extends Model<OrderAttributes> implements OrderAttributes {
Order.init(
{
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
type: DataTypes.UUID,
allowNull: false,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
},
userId: {
type: new DataTypes.INTEGER,
type: new DataTypes.UUID,
allowNull: false
},
shopId: {
type: new DataTypes.INTEGER,
type: new DataTypes.UUID,
allowNull: false
},
paymentMethodId: {
Expand Down
12 changes: 6 additions & 6 deletions src/databases/models/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ class Products extends Model<IProduct> {
Products.init(
{
id: {
type: DataTypes.UUID,
allowNull: false,
primaryKey: true,
autoIncrement: true,
type: DataTypes.INTEGER
},
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
collectionId: {
allowNull: false,
type: DataTypes.INTEGER,
type: DataTypes.UUID,
references: {
model: "collection",
key: "id"
Expand All @@ -41,7 +41,7 @@ Products.init(
},
shopId: {
allowNull: false,
type: DataTypes.INTEGER,
type: DataTypes.UUID,
references: {
model: "shops",
key: "id"
Expand Down
9 changes: 5 additions & 4 deletions src/databases/models/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ export interface SessionAttributes {
Session.init(
{
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
type: DataTypes.UUID,
allowNull: false,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
},
userId: {
type: new DataTypes.INTEGER,
type: new DataTypes.UUID,
allowNull: false
},
device: {
Expand Down
9 changes: 5 additions & 4 deletions src/databases/models/shops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ export interface ShopAttributes {
Shop.init(
{
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
type: DataTypes.UUID,
allowNull: false,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
},
userId: {
type: new DataTypes.INTEGER,
type: new DataTypes.UUID,
allowNull: false
},
name: {
Expand Down
Loading

0 comments on commit c0f6287

Please sign in to comment.