Добавил в таблицу поле с никнеймом
This commit is contained in:
parent
5334968810
commit
fe77b55275
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"development": {
|
||||||
|
"username": "root",
|
||||||
|
"password": null,
|
||||||
|
"database": "hunt_blacklist",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"dialect": "mysql"
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"username": "root",
|
||||||
|
"password": null,
|
||||||
|
"database": "hunt_blacklist",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"dialect": "mysql"
|
||||||
|
},
|
||||||
|
"production": {
|
||||||
|
"username": "root",
|
||||||
|
"password": null,
|
||||||
|
"database": "hunt_blacklist",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"dialect": "mysql"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/** @type {import('sequelize-cli').Migration} */
|
||||||
|
module.exports = {
|
||||||
|
async up (queryInterface, Sequelize) {
|
||||||
|
await queryInterface.addColumn('BlacklistReports', 'steam_nickname', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
allowNull: true, // или false, если есть значение по умолчанию
|
||||||
|
after: 'steam_link'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async down (queryInterface, Sequelize) {
|
||||||
|
await queryInterface.removeColumn('BlacklistReports', 'steam_nickname');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const Sequelize = require('sequelize');
|
||||||
|
const process = require('process');
|
||||||
|
const basename = path.basename(__filename);
|
||||||
|
const env = process.env.NODE_ENV || 'development';
|
||||||
|
const config = require(__dirname + '/../config/config.json')[env];
|
||||||
|
const db = {};
|
||||||
|
|
||||||
|
let sequelize;
|
||||||
|
if (config.use_env_variable) {
|
||||||
|
sequelize = new Sequelize(process.env[config.use_env_variable], config);
|
||||||
|
} else {
|
||||||
|
sequelize = new Sequelize(config.database, config.username, config.password, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs
|
||||||
|
.readdirSync(__dirname)
|
||||||
|
.filter(file => {
|
||||||
|
return (
|
||||||
|
file.indexOf('.') !== 0 &&
|
||||||
|
file !== basename &&
|
||||||
|
file.slice(-3) === '.js' &&
|
||||||
|
file.indexOf('.test.js') === -1
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.forEach(file => {
|
||||||
|
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
|
||||||
|
db[model.name] = model;
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.keys(db).forEach(modelName => {
|
||||||
|
if (db[modelName].associate) {
|
||||||
|
db[modelName].associate(db);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
db.sequelize = sequelize;
|
||||||
|
db.Sequelize = Sequelize;
|
||||||
|
|
||||||
|
module.exports = db;
|
||||||
|
|
@ -2,10 +2,10 @@ import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
|
Delete,
|
||||||
Get,
|
Get,
|
||||||
Param,
|
Param,
|
||||||
Post,
|
Post,
|
||||||
Delete,
|
|
||||||
Put,
|
Put,
|
||||||
Query,
|
Query,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@ export class BlacklistService {
|
||||||
for (const record of records) {
|
for (const record of records) {
|
||||||
if (result[record.steam_link]) {
|
if (result[record.steam_link]) {
|
||||||
const item: BlacklistItem = result[record.steam_link];
|
const item: BlacklistItem = result[record.steam_link];
|
||||||
|
if (record.steam_nickname !== null) {
|
||||||
|
item.nicknames.push(record.steam_nickname);
|
||||||
|
}
|
||||||
item.comments.push(record.comment);
|
item.comments.push(record.comment);
|
||||||
item.toxic += Number(record.toxic);
|
item.toxic += Number(record.toxic);
|
||||||
item.cheater += Number(record.cheater);
|
item.cheater += Number(record.cheater);
|
||||||
|
|
@ -46,6 +49,7 @@ export class BlacklistService {
|
||||||
} else {
|
} else {
|
||||||
const item: BlacklistItem = {
|
const item: BlacklistItem = {
|
||||||
link: record.steam_link,
|
link: record.steam_link,
|
||||||
|
nicknames: [],
|
||||||
comments: [],
|
comments: [],
|
||||||
toxic: Number(record.toxic),
|
toxic: Number(record.toxic),
|
||||||
cheater: Number(record.cheater),
|
cheater: Number(record.cheater),
|
||||||
|
|
@ -53,6 +57,9 @@ export class BlacklistService {
|
||||||
useless: Number(record.useless),
|
useless: Number(record.useless),
|
||||||
griefer: Number(record.griefer),
|
griefer: Number(record.griefer),
|
||||||
};
|
};
|
||||||
|
if (record.steam_nickname !== null) {
|
||||||
|
item.nicknames.push(record.steam_nickname);
|
||||||
|
}
|
||||||
item.comments.push(record.comment);
|
item.comments.push(record.comment);
|
||||||
result[record.steam_link] = item;
|
result[record.steam_link] = item;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
export type BlacklistReportDto = {
|
export type BlacklistReportDto = {
|
||||||
id: number;
|
id: number;
|
||||||
steam_link: string;
|
steam_link: string;
|
||||||
|
steam_nickname: string;
|
||||||
comment: string;
|
comment: string;
|
||||||
toxic: boolean;
|
toxic: boolean;
|
||||||
cheater: boolean;
|
cheater: boolean;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ export class BlacklistReport extends Model {
|
||||||
@Column
|
@Column
|
||||||
declare steam_link: string;
|
declare steam_link: string;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
declare steam_nickname: string;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
declare comment: string;
|
declare comment: string;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
export type BlacklistItem = {
|
export type BlacklistItem = {
|
||||||
link: string;
|
link: string;
|
||||||
|
nicknames: Array<string>;
|
||||||
comments: Array<string>;
|
comments: Array<string>;
|
||||||
toxic: number;
|
toxic: number;
|
||||||
cheater: number;
|
cheater: number;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue