From 9b91b85a647074b75b79534485185ab5f671780d Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 20 May 2019 22:05:06 +0000 Subject: [PATCH] --- devdocs/specs/core-long-running-operations.txt | 3 +-- devdocs/todo.txt | 7 +++++-- server/AyaNova/biz/EventLogProcessor.cs | 4 ++-- server/AyaNova/biz/JobsBiz.cs | 1 + server/AyaNova/biz/PickListFetcher.cs | 2 +- server/AyaNova/biz/UserBiz.cs | 2 +- server/AyaNova/models/Event.cs | 10 +++++----- server/AyaNova/util/AySchema.cs | 4 ++-- 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/devdocs/specs/core-long-running-operations.txt b/devdocs/specs/core-long-running-operations.txt index 20334956..09e07834 100644 --- a/devdocs/specs/core-long-running-operations.txt +++ b/devdocs/specs/core-long-running-operations.txt @@ -58,8 +58,7 @@ SCHEMA =-=-=-= AOPSJOB - - jobid long NOT NULL INDEXED UNIQUE (initially I'll use linux epoch when job created, used to tag logs etc, but keeping this open for a change later) - - OwnerId NOT NULL + - jobid long NOT NULL INDEXED UNIQUE (initially I'll use linux epoch when job created, used to tag logs etc, but keeping this open for a change later) - Created NOT NULL - Exclusive NOT NULL bool (true=close api and don't run any other jobs, false=process async and keep api open) - StartAfter NOT NULL INDEXED (datetime to start the job, in cases of start now jobs the date will be minvalue) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 294566fb..2126c71e 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -16,13 +16,15 @@ Remove OwnerId - DONE ValidateJsonPatch - DONE FileAttachment - DONE FormCustom + - DONE OpsJob + - DONE UserOptions - Rename OwnerId to UserId for those objects that require it still - DONE DataFilter - EventLog - Event object uses it see eventlog above - - UserOptions (rename to userID) - - OpsJob (might be removable, rename it CreatorID? Or, if it's already logged in the event log then maybe no creator ID is required at all.) + + OwnerID is put on httpcontext in startup.cs, will it still be necessary? Clean up owner ID and rules now that it's deprecated @@ -47,6 +49,7 @@ TODO: Make it fucking easier to test deploy and erase db and fetch key and all t TODO: Licensing - make sure tech type use license works properly: a tech license is consumed if a user has **any one** of the four roles of TechFull, TechLimited, SubcontractorFull, SubcontractorLimited ### TODO FILTER ISSUE: SEE integration tests search for BUGBUG there are two tests failing in DataFilterFilteringLists tests that might be DST related +TODO: JobsBiz::Create -> should log an event in order to be able to see who created a job, but maybe not for automatic internal jobs =-=-=-=-=-=- Less urgent things... diff --git a/server/AyaNova/biz/EventLogProcessor.cs b/server/AyaNova/biz/EventLogProcessor.cs index 6c1a6b15..07193827 100644 --- a/server/AyaNova/biz/EventLogProcessor.cs +++ b/server/AyaNova/biz/EventLogProcessor.cs @@ -72,7 +72,7 @@ namespace AyaNova.Biz var ret = EventItems.Select(m => new AyaNova.Api.Controllers.EventLogController.ObjectEventLogItem() { Date = m.Created, - UserId = m.OwnerId, + UserId = m.UserId, Event = m.AyEvent, Textra = m.Textra }).ToArray(); @@ -91,7 +91,7 @@ namespace AyaNova.Biz //Set up the query var q = ct.Event.Select(m => m); - q = q.Where(m => m.OwnerId == opt.AyId); + q = q.Where(m => m.UserId == opt.AyId); if (opt.StartDate != null) q = q.Where(m => m.Created > opt.StartDate); diff --git a/server/AyaNova/biz/JobsBiz.cs b/server/AyaNova/biz/JobsBiz.cs index 3ef28a37..d0a8b3c2 100644 --- a/server/AyaNova/biz/JobsBiz.cs +++ b/server/AyaNova/biz/JobsBiz.cs @@ -142,6 +142,7 @@ namespace AyaNova.Biz /// internal static OpsJob AddJob(OpsJob newJob, AyContext ct) { + //TODO: Does this need to create an event so we know which user created the job? ct.OpsJob.Add(newJob); ct.SaveChanges(); return newJob; diff --git a/server/AyaNova/biz/PickListFetcher.cs b/server/AyaNova/biz/PickListFetcher.cs index ea31b0cb..c4fcbd07 100644 --- a/server/AyaNova/biz/PickListFetcher.cs +++ b/server/AyaNova/biz/PickListFetcher.cs @@ -113,7 +113,7 @@ namespace AyaNova.Biz /* 2018-12-12 16:29:12.7547|INFO|Microsoft.EntityFrameworkCore.Database.Command|Executed DbCommand (3ms) [Parameters=[@__p_2='999', @__p_1='0'], CommandType='Text', CommandTimeout='30'] - SELECT a.id, a.active, a.xmin, a.count, a.dollaramount, a.enddate, a.name, a.notes, a.ownerid, a.roles, a.serial, a.startdate, a.tags + SELECT a.id, a.active, a.xmin, a.count, a.dollaramount, a.enddate, a.name, a.notes, a.o wnerid, a.roles, a.serial, a.startdate, a.tags FROM ( SELECT *, xmin FROM AWIDGET where (name Like 'SortByFieldAscendingWorks 1544660950941%') ORDER BY startdate ASC ) AS a diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index b5510a04..79a4249e 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -551,7 +551,7 @@ namespace AyaNova.Biz //They can always make any user inactive to get rid of them and it will mean referential integrity issues are not there //There's only one rule - have they done anything eventlog worthy yet? - if (ct.Event.Select(m => m).Where(m => m.OwnerId == inObj.Id).Count() > 0) + if (ct.Event.Select(m => m).Where(m => m.UserId == inObj.Id).Count() > 0) { AddError(ApiErrorCode.INVALID_OPERATION, "user", "LT:ErrorDBForeignKeyViolation"); return; diff --git a/server/AyaNova/models/Event.cs b/server/AyaNova/models/Event.cs index 37f76e52..a6b94d52 100644 --- a/server/AyaNova/models/Event.cs +++ b/server/AyaNova/models/Event.cs @@ -14,7 +14,7 @@ namespace AyaNova.Models public uint ConcurrencyToken { get; set; } public DateTime Created { get; set; } [Required] - public long OwnerId { get; set; } + public long UserId { get; set; } //----------------------------------------- [Required] public long AyId { get; set; } @@ -32,10 +32,10 @@ namespace AyaNova.Models Created = System.DateTime.UtcNow; } - public Event(long ownerId, long ayId, AyaType ayType, AyaEvent ayEvent, string textra = null) + public Event(long userId, long ayId, AyaType ayType, AyaEvent ayEvent, string textra = null) { Created = System.DateTime.UtcNow; - OwnerId = ownerId; + UserId = userId; AyId = ayId; AyType = ayType; AyEvent = ayEvent; @@ -47,10 +47,10 @@ namespace AyaNova.Models } } - public Event(long ownerId, long ayId, AyaType ayType, AyaEvent ayEvent, DateTime created, string textra = null) + public Event(long userId, long ayId, AyaType ayType, AyaEvent ayEvent, DateTime created, string textra = null) { Created = created; - OwnerId = ownerId; + UserId = userId; AyId = ayId; AyType = ayType; AyEvent = ayEvent; diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 87723f5e..a88e6fd9 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -136,7 +136,7 @@ namespace AyaNova.Util LogUpdateMessage(log); //create aevent biz event log table - exec("CREATE TABLE aevent (id BIGSERIAL PRIMARY KEY, created timestamp not null, ownerid bigint not null," + + exec("CREATE TABLE aevent (id BIGSERIAL PRIMARY KEY, created timestamp not null, userid bigint not null," + "ayid bigint not null, aytype integer not null, ayevent integer not null, textra varchar(255))"); //SEARCH TABLES @@ -248,7 +248,7 @@ namespace AyaNova.Util { LogUpdateMessage(log); - exec("CREATE TABLE aopsjob (gid uuid PRIMARY KEY, ownerid bigint not null, name text not null, created timestamp not null, exclusive bool not null, " + + exec("CREATE TABLE aopsjob (gid uuid PRIMARY KEY, name text not null, created timestamp not null, exclusive bool not null, " + "startafter timestamp not null, jobtype integer not null, objectid bigint null, objecttype integer null, jobstatus integer not null, jobinfo text null)"); exec("CREATE TABLE aopsjoblog (gid uuid PRIMARY KEY, jobid uuid not null REFERENCES aopsjob (gid), created timestamp not null, statustext text not null)");