Apr 2, 2021 11:10
Gave it a shot. Nobody has said anything yet. The big question is how to remove/refactor the MERGE statement
Mar 26, 2021 15:11
As bumbling as this is and without a full plan I guess it me flailing around trying this out. Why? 1) it's an interesting project, 2) there's a need for something to help out SQL post PASS, 3) demonstrate my data access project/app dev framework, and 4) I guess get referrals for consulting business (obliquely). To shake the tree and see what people will contribute. My big fear tho is nobody cares or it's not well received.
Mar 26, 2021 15:00
So it seems to makes we would want to build an engineering mule to develop the application logic and .NET Core API without consideration of actual identity infrastructure. If this is done the right way then the whole thing could be done "open source" in public I guess.
Mar 26, 2021 14:57
WE can't disclose the identity and access management code but it could be offered as a "free" service to Sql Server Saturday or other causes
Mar 26, 2021 14:55
The .NET Core environment we use for all current projects has a separate identity server which supports different flows including Oauth 2 implicit, password resets, etc.
Mar 26, 2021 14:52
Well looking at what was written... hopefully this is crazy in a good way. If it's not... well, this is the last bit I'll write without The technical part that's uncertain has to do with authentication, authorization, identity, and access management. The .NET Framework Web API application is a classic monolith that uses self signed certificates and custom OWIN identity objects. In speaking with my
Mar 25, 2021 18:14
One beauty of this approach is the whole thing can be tested and demonstrated without any UI. We have the Postman requests already built
Mar 25, 2021 18:12
It works though and it's part of a full system. It would need to be updated
Mar 25, 2021 18:10
Merge is a piece of crap in SQL Server. This is old code that does not represent my current understanding
Mar 25, 2021 17:37
drop proc api_post_reply_post;
go
create proc api_post_reply_post
@t_id int,
@u_id int,
@reply_p_id bigint,
@title nvarchar(256),
@body nvarchar(4000),
@test_p_id bigint output,
@test_msg varchar(2048) output
as
set nocount on;
set xact_abort on;

begin transaction
begin try
declare
@inserted_reply table(act nvarchar(20),
p_id bigint);

with
branch_cte(p_id, orig_p_id, reply_p_id, tree_path, reply_depth_count, created_dt, calc)
as (
select
p_id,
orig_p_id,
cast(null as bigint),
Mar 25, 2021 17:37
What is not trivial is posting in response to another post
Mar 25, 2021 17:37
drop proc api_post_post;
go
create proc api_post_post
@t_id int,
@u_id int,
@title nvarchar(256),
@body nvarchar(4000),
@test_p_id bigint output,
@test_msg varchar(2048) output
as
set nocount on;
begin try
insert posts(t_id, u_id, reply_depth_count, tree_path, title, body, created_dt, edited_dt) values(@t_id, @u_id, 2, 2, @title, @body, sysutcdatetime(), sysutcdatetime());
select @test_p_id=scope_identity();
select @test_msg='Ok';
end try
begin catch
select @test_p_id=0;
select @test_msg=error_message();;
Mar 25, 2021 17:36
To post to the top level of the thread is trivial as it's the root node of a recursion where orig_p_id is NULL.
Mar 25, 2021 17:34
From these column JSON can be serialized and delivered to Kendo UI data source object and as far as I can tell it will render threaded conversations as tree object
Mar 25, 2021 17:32
If the user replies to another post (instead of directly to the top level of the thread) then columns: orig_p_id is "original post id", reply_depth_count is "degree of separation", tree_path is "ordinal pathway to traverse replies"
Mar 25, 2021 17:30
Users creates posts in response to threads. Users might reply directly to the thread overall or they might reply to a particular post. To persist this and to be able to quickly generate view models there are tradeoffs that have to be made.
Mar 25, 2021 17:28
That's a table called 'posts' which is designed to persist forum posts. p_id is "post id", t_id is "thread id", u_id is "user id"
Mar 25, 2021 17:26
if object_id('dbo.posts') is not null
drop table if exists thr.posts;
create table posts(
p_id bigint identity(2,2) primary key not null,
t_id int not null references threads(t_id),
u_id int not null references users(id),
orig_p_id bigint null references posts(p_id),
reply_p_id bigint null references posts(p_id),
reply_depth_count int not null default 0,
tree_path int not null,
tree_path_bit bit not null default 0,
title nvarchar(256) null,
body nvarchar(4000) not null,
Mar 25, 2021 16:33
So the .NET guy was big into Kendo UI which is what he said he was build into a site. At the time the latest thing in Kendo UI was tree structures to store hierarchical data. So that's what he wanted in the spec. He wanted to display the threaded conversations as a tree.
Mar 25, 2021 16:29
The way it was implemented was to nest the posts within each other within a single thread. This lead to shenanigans where members could/would change history or you'd have to go backward through the thread to find the unaltered original
Mar 25, 2021 16:27
One thing that's cool about Drupal and/or the way the forum was implemented on this site it was possible to have threaded subconversations
Mar 25, 2021 16:24
Technically it was a really interesting SQL challenge
Mar 25, 2021 16:10
I want to pick up the ball and do something with it
Mar 25, 2021 16:09
That's sort of the end of the story because that's where things stand right now
Mar 25, 2021 16:06
So the demo's were done with the side project .NET Framework and the plan was to move the API controllers and such to the .NET Core project type we use for all projects
Mar 25, 2021 16:04
The pipeline and DevOps conform to our current API configuration which is GitHub, Azure DevOps, App Service, .NET Core etc.
Mar 25, 2021 16:02
That client was interested and followed up once or twice but then it was dropped for another priority. We're a consulting company and we different projects. So in anticipation of moving forward we internally created CI/CD DevOps infrastructure for a forum API
Mar 25, 2021 15:53
So as side project that was developed in 2012-sih. Then around 2016-ish my business partner pitched a potential client a content site with a forum.
Mar 25, 2021 15:51
strange person who over-posted crazy things
Mar 25, 2021 15:49
The .NET guys were supposed to build a UI but flaked out and never did. One left the project by nonresponse early and then the second I ended up de-friending on Facebook because he was a
Mar 25, 2021 15:47
The fastest backsplain possible: Many years ago a forum-type website based on Drupal was permanently shut down even though a potential buyer offered the owner of the site 6 figure dollars. So former members of the old site got together to build a new forum. I was the database guy. There were 2 .NET guys who wrote a technical spec for a forum API. Based on the spec I created a data model, procedures, and a .NET Framework API application
Mar 25, 2021 15:37
So it's an idea/plan but I struggle with the story of it and making it flow. Jeff and you are the tops in SQL at explaining things. I feel like I'm pounding sand right now
Mar 25, 2021 15:34
My question here is whether or not this is a coherent good idea or if it seems unworkable. A voice of reason would be greatly appreciated
Mar 25, 2021 15:29
This is a lot to explain as there are many pieces and parts to consider
Mar 25, 2021 15:26
So based on this I came up with an idea/plan to create an alternative
Mar 25, 2021 15:23
Also, in the past I recall discussion where you Solomon mention that the WordPress database is suboptimal and not properly designed. I believe you mentioned there's a fork which is implemented in SQL Server? Anyway, Steve Jones said he would be open to other alternatives which might be interesting
Mar 25, 2021 15:21
It's related to this thread from sqlservercentral where Steve Jones talks about the plans for post-PASS
Mar 25, 2021 15:17
There's something I was hoping to try to explain and it's a lot tho and it's not all worked out yet
Mar 23, 2021 12:46
The stairway series on SSC is really well done. My partner and me have studied it and for technique not just content. Explaining things is the biggest challenge for me
Mar 23, 2021 12:43
We have a little 5 year old in Hoboken New Jersey so I'm quite familiar with these dramas :)
Mar 10, 2021 17:43
Crazy in a good way I hope -- thank you Solomon. Thank you for helping out with this particular issue and for everything else. I'll definitely follow up with you. Maybe after this last bit of automation is complete :) My best contact is [email protected] or GitHub too. Cheers
Mar 10, 2021 17:16
It allows you to create Controllers which are only defined by Attribute objects yet can be fully parameterized.
Mar 10, 2021 17:09
It's a tiny library about 25Kb currently. The filters short circuits the http pipeline using a ResourceFilter triggered by a TypeFilter. It reads the one-way stream and sends generic JSON to the db. github.com/The-Cantor-Set/JsonAutoService
Mar 10, 2021 17:06
Sticking with the native types is always an option if necessary
Mar 10, 2021 17:05
I've made a few videos which explain it and it's an open source library. At some point I would very much like to give you a personal run through if you're Ok with that. There's a lot to explain and I know you're the author the C# CLR library which is amazing
Mar 10, 2021 17:04
Why JSON? JSON can be read/written from directly in SQL Server so I use it to skip custom coding of data access in C# and this has very good system properties. I've mentioned this many times on SSC but haven't really put it out there I guess.
Mar 10, 2021 16:56
Hey Ok, you know what? It does work when returned as JSON
Mar 10, 2021 16:48
I agree with everything you've written. It seems possible I prematurely dumped JSON when the online parser choked on copy/paste
Mar 10, 2021 16:47
Solomon it's much appreciated! It's my pleasure to answer any questions you might have. It's taking me a bit of time to backtrack and test