Adds eslint and linted & improved routing for interactions
This commit is contained in:
parent
83209f642c
commit
441715675c
35 changed files with 2091 additions and 463 deletions
|
|
@ -2,7 +2,7 @@ import {Repository} from "./Repository";
|
|||
import {GroupModel} from "../Models/GroupModel";
|
||||
import Groups, {DBGroup} from "../Database/tables/Groups";
|
||||
import {DatabaseConnection} from "../Database/DatabaseConnection";
|
||||
import {CacheType, CacheTypeReducer, Guild, GuildMember, GuildMemberRoleManager} from "discord.js";
|
||||
import {GuildMember} from "discord.js";
|
||||
import {Nullable} from "../types/Nullable";
|
||||
import {PlaydateRepository} from "./PlaydateRepository";
|
||||
import {Container} from "../Container/Container";
|
||||
|
|
@ -33,7 +33,7 @@ export class GroupRepository extends Repository<GroupModel, DBGroup> {
|
|||
}
|
||||
|
||||
public findGroupsByRoles(server: string, roleIds: string[]): GroupModel[] {
|
||||
const template = roleIds.map(roleId => '?').join(',');
|
||||
const template = roleIds.map(_roleId => '?').join(',');
|
||||
|
||||
const dbResult = this.database.fetchAll<number[], DBGroup>(`
|
||||
SELECT * FROM groups WHERE server = ? AND role IN (${template})
|
||||
|
|
@ -64,7 +64,6 @@ export class GroupRepository extends Repository<GroupModel, DBGroup> {
|
|||
public deleteGroup(group: GroupModel): void {
|
||||
this.delete(group.id);
|
||||
|
||||
debugger
|
||||
const repo = Container.get<PlaydateRepository>(PlaydateRepository.name);
|
||||
const playdates = repo.findFromGroup(group, true)
|
||||
playdates.forEach((playdate) => {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export class PlaydateRepository extends Repository<PlaydateModel, DBPlaydate> {
|
|||
}
|
||||
|
||||
getNextPlaydateForGroup(group: GroupModel): PlaydateModel | null {
|
||||
let sql = `SELECT * FROM ${this.schema.name} WHERE groupid = ? AND time_from > ? ORDER BY time_from ASC LIMIT 1`;
|
||||
const sql = `SELECT * FROM ${this.schema.name} WHERE groupid = ? AND time_from > ? ORDER BY time_from LIMIT 1`;
|
||||
|
||||
const find = this.database.fetch<number, DBPlaydate>(
|
||||
sql,
|
||||
|
|
@ -78,14 +78,12 @@ export class PlaydateRepository extends Repository<PlaydateModel, DBPlaydate> {
|
|||
if (!intermediateModel) {
|
||||
throw new Error("Unable to convert the playdate model");
|
||||
}
|
||||
const result: PlaydateModel = {
|
||||
return {
|
||||
id: intermediateModel.id,
|
||||
group: fixedGroup ?? this.groupRepository.getById(intermediateModel.groupid),
|
||||
from_time: new Date(intermediateModel.time_from),
|
||||
to_time: new Date(intermediateModel.time_to),
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
protected convertToCreateObject(instance: Partial<PlaydateModel>): object {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {DatabaseConnection} from "../Database/DatabaseConnection";
|
|||
import {Model} from "../Models/Model";
|
||||
import { Nullable } from "../types/Nullable";
|
||||
import {DatabaseDefinition} from "../Database/DatabaseDefinition";
|
||||
import {debug} from "node:util";
|
||||
import {Container} from "../Container/Container";
|
||||
import {EventHandler} from "../Events/EventHandler";
|
||||
import {ElementCreatedEvent} from "../Events/ElementCreatedEvent";
|
||||
|
|
@ -62,7 +61,7 @@ export class Repository<ModelType extends Model, IntermediateModelType = unknown
|
|||
SET ${Object.keys(createObject).map((key) => `${key} = ?`).join(',')}
|
||||
WHERE id = ?`;
|
||||
const result = this.database.execute(sql, ...Object.values(createObject), instance.id);
|
||||
return result.lastInsertRowid;
|
||||
return result.changes > 0;
|
||||
}
|
||||
|
||||
public getById(id: number): Nullable<ModelType> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue