Fixed db set date & show only changed fields in history view #246

This commit is contained in:
Sven Heidemann 2023-03-12 04:55:04 +01:00
parent ad00dce5d9
commit b1a0115e8b
29 changed files with 35 additions and 117 deletions

View File

@ -1,11 +1,8 @@
ALTER TABLE `ApiKeys`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `ApiKeys` ALTER TABLE `ApiKeys`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `ApiKeys` ALTER TABLE `ApiKeys`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `ApiKeysHistory` CREATE TABLE IF NOT EXISTS `ApiKeysHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `AuthUserUsersRelations`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `AuthUserUsersRelations` ALTER TABLE `AuthUserUsersRelations`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `AuthUserUsersRelations` ALTER TABLE `AuthUserUsersRelations`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `AuthUserUsersRelationsHistory` CREATE TABLE IF NOT EXISTS `AuthUserUsersRelationsHistory`

View File

@ -1,11 +1,8 @@
ALTER TABLE `AuthUsers`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `AuthUsers` ALTER TABLE `AuthUsers`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `AuthUsers` ALTER TABLE `AuthUsers`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `AuthUsersHistory` CREATE TABLE IF NOT EXISTS `AuthUsersHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `AutoRoleRules`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `AutoRoleRules` ALTER TABLE `AutoRoleRules`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `AutoRoleRules` ALTER TABLE `AutoRoleRules`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `AutoRoleRulesHistory` CREATE TABLE IF NOT EXISTS `AutoRoleRulesHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `AutoRoles`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `AutoRoles` ALTER TABLE `AutoRoles`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `AutoRoles` ALTER TABLE `AutoRoles`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `AutoRolesHistory` CREATE TABLE IF NOT EXISTS `AutoRolesHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `Clients`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `Clients` ALTER TABLE `Clients`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `Clients` ALTER TABLE `Clients`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `ClientsHistory` CREATE TABLE IF NOT EXISTS `ClientsHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `GameServers`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `GameServers` ALTER TABLE `GameServers`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `GameServers` ALTER TABLE `GameServers`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `GameServersHistory` CREATE TABLE IF NOT EXISTS `GameServersHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `KnownUsers`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `KnownUsers` ALTER TABLE `KnownUsers`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `KnownUsers` ALTER TABLE `KnownUsers`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `KnownUsersHistory` CREATE TABLE IF NOT EXISTS `KnownUsersHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `Levels`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `Levels` ALTER TABLE `Levels`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `Levels` ALTER TABLE `Levels`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `LevelsHistory` CREATE TABLE IF NOT EXISTS `LevelsHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `Servers`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `Servers` ALTER TABLE `Servers`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `Servers` ALTER TABLE `Servers`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `ServersHistory` CREATE TABLE IF NOT EXISTS `ServersHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `UserGameIdents`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `UserGameIdents` ALTER TABLE `UserGameIdents`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `UserGameIdents` ALTER TABLE `UserGameIdents`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UserGameIdentsHistory` CREATE TABLE IF NOT EXISTS `UserGameIdentsHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `UserJoinedGameServer`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `UserJoinedGameServer` ALTER TABLE `UserJoinedGameServer`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `UserJoinedGameServer` ALTER TABLE `UserJoinedGameServer`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UserJoinedGameServerHistory` CREATE TABLE IF NOT EXISTS `UserJoinedGameServerHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `UserJoinedServers`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `UserJoinedServers` ALTER TABLE `UserJoinedServers`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `UserJoinedServers` ALTER TABLE `UserJoinedServers`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UserJoinedServersHistory` CREATE TABLE IF NOT EXISTS `UserJoinedServersHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `UserJoinedVoiceChannel`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `UserJoinedVoiceChannel` ALTER TABLE `UserJoinedVoiceChannel`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `UserJoinedVoiceChannel` ALTER TABLE `UserJoinedVoiceChannel`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UserJoinedVoiceChannelHistory` CREATE TABLE IF NOT EXISTS `UserJoinedVoiceChannelHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `UserMessageCountPerHour`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `UserMessageCountPerHour` ALTER TABLE `UserMessageCountPerHour`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `UserMessageCountPerHour` ALTER TABLE `UserMessageCountPerHour`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UserMessageCountPerHourHistory` CREATE TABLE IF NOT EXISTS `UserMessageCountPerHourHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `UserWarnings`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `UserWarnings` ALTER TABLE `UserWarnings`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `UserWarnings` ALTER TABLE `UserWarnings`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UserWarningsHistory` CREATE TABLE IF NOT EXISTS `UserWarningsHistory`
( (

View File

@ -1,11 +1,8 @@
ALTER TABLE `Users`
MODIFY `LastModifiedAt` DATETIME(6) NULL ON UPDATE CURRENT_TIMESTAMP(6);
ALTER TABLE `Users` ALTER TABLE `Users`
CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `CreatedAt` `CreatedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6);
ALTER TABLE `Users` ALTER TABLE `Users`
CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6); CHANGE `LastModifiedAt` `LastModifiedAt` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6);
CREATE TABLE IF NOT EXISTS `UsersHistory` CREATE TABLE IF NOT EXISTS `UsersHistory`
( (

View File

@ -30,7 +30,6 @@ type UserHistory implements HistoryTableQuery {
xp: Int xp: Int
server: ID server: ID
leftServer: Boolean
deleted: Boolean deleted: Boolean
dateFrom: String dateFrom: String

View File

@ -10,7 +10,6 @@ class UserHistoryQuery(HistoryQueryABC):
self.set_field("discordId", self.resolve_discord_id) self.set_field("discordId", self.resolve_discord_id)
self.set_field("xp", self.resolve_xp) self.set_field("xp", self.resolve_xp)
self.set_field("server", self.resolve_server) self.set_field("server", self.resolve_server)
self.set_field("leftServer", self.resolve_left_server)
@staticmethod @staticmethod
def resolve_id(user: User, *_): def resolve_id(user: User, *_):
@ -27,7 +26,3 @@ class UserHistoryQuery(HistoryQueryABC):
@staticmethod @staticmethod
def resolve_server(user: User, *_): def resolve_server(user: User, *_):
return user.server return user.server
@staticmethod
def resolve_left_server(user: User, *_):
return user.left_server

View File

@ -133,7 +133,6 @@ export class Queries {
discordId discordId
xp xp
server server
leftServer
deleted deleted
dateFrom dateFrom
dateTo dateTo

View File

@ -20,8 +20,20 @@ export class HistoryBtnComponent implements OnInit {
} }
openHistory(): void { openHistory(): void {
console.log("history", this.history);
this.showSidebar = true; this.showSidebar = true;
let oldHistory: Partial<History> = {};
for (const history of this.history) {
const attributes = Object.keys(history).map((key) => {
return key;
});
for (const attribute of attributes) {
if (history[attribute] === oldHistory[attribute]) {
delete oldHistory[attribute];
}
}
oldHistory = history;
}
} }
getAttributeTranslationKey(key: string) { getAttributeTranslationKey(key: string) {

View File

@ -1 +0,0 @@
<p>history works!</p>

View File

@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HistoryComponent } from './history.component';
describe('HistoryComponent', () => {
let component: HistoryComponent;
let fixture: ComponentFixture<HistoryComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ HistoryComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(HistoryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -1,10 +0,0 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-history',
templateUrl: './history.component.html',
styleUrls: ['./history.component.scss']
})
export class HistoryComponent {
}

View File

@ -23,7 +23,6 @@ import { PanelModule } from "primeng/panel";
import { InputNumberModule } from "primeng/inputnumber"; import { InputNumberModule } from "primeng/inputnumber";
import { ImageModule } from "primeng/image"; import { ImageModule } from "primeng/image";
import { SidebarModule } from "primeng/sidebar"; import { SidebarModule } from "primeng/sidebar";
import { HistoryComponent } from "./components/history/history.component";
import { HistoryBtnComponent } from './components/history-btn/history-btn.component'; import { HistoryBtnComponent } from './components/history-btn/history-btn.component';
@ -32,7 +31,6 @@ import { HistoryBtnComponent } from './components/history-btn/history-btn.compon
AuthRolePipe, AuthRolePipe,
IpAddressPipe, IpAddressPipe,
BoolPipe, BoolPipe,
HistoryComponent,
HistoryBtnComponent, HistoryBtnComponent,
], ],
imports: [ imports: [

View File

@ -9,7 +9,7 @@ function Main(): void {
setVersion(version); setVersion(version);
}) })
.catch(err => { .catch(err => {
throwError(() => err); throw err;
}); });
} }
@ -50,7 +50,7 @@ async function setVersion(version: SoftwareVersion) {
const fs = require("fs"); const fs = require("fs");
fs.readFile(jsonFilePath, "utf8", (err: Error, data: string) => { fs.readFile(jsonFilePath, "utf8", (err: Error, data: string) => {
if (err) { if (err) {
throwError(() => err); throw err;
} }
const settings: Appsettings = JSON.parse(data); const settings: Appsettings = JSON.parse(data);
settings.WebVersion = version; settings.WebVersion = version;
@ -59,7 +59,7 @@ async function setVersion(version: SoftwareVersion) {
}); });
fs.readFile('./package.json', "utf8", (err: Error, data: string) => { fs.readFile('./package.json', "utf8", (err: Error, data: string) => {
if (err) { if (err) {
throwError(() => err); throw err;
} }
const settings = JSON.parse(data); const settings = JSON.parse(data);
settings.version = version.getVersionString(); settings.version = version.getVersionString();