Skip to content

Commit

Permalink
[UPD] Update community classes. Add dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
MakarovS96 committed Jan 26, 2018
1 parent 6f819e1 commit 4bdb92d
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 82 deletions.
12 changes: 0 additions & 12 deletions src/cls/BI/Comment.cls
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,6 @@ ClassMethod GetGroupName(postId, prop As %String) As %String
Quit result
}

ClassMethod GSContestOrAllDate(date As %Date, groupName As %String) As %String
{
set date = $zdh(date,3)
set result = "NonGSContest"
if (date<=63977)&(date>=63963)&(groupName'="Developer Community Feedback") {set result = "GSContest"} //2016-02-15 - 2016-02-29
elseif (date<=63993)&(date>=63980)
&(groupName'="Developer Community Feedback")
&(groupName'="Announcements")
&(groupName'="Alerts") {set result = "GSContest-2"} //2016-03-03 - 2016-03-16
Quit result
}

ClassMethod GetDaysNumber(date, id)
{
set result = 0
Expand Down
2 changes: 0 additions & 2 deletions src/cls/BI/CommentCopy.cls
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
<cube xmlns="http://www.intersystems.com/deepsee" name="CommentCopy" displayName="CommentCopy" disabled="false" abstract="false" sourceClass="Community.Comment" countMeasureName="COMCOUNT" bucketSize="8" bitmapChunkInMemory="false" precompute="0" disableListingGroups="false">
<dimension name="AuthorName" disabled="false" sharesFrom="Post" hasAll="false" allCaption="All AuthorName" allDisplayName="AuthorName" type="data" hidden="false" showHierarchies="default">
</dimension>
<dimension name="DateDimension" disabled="false" sharesFrom="Post" hasAll="false" allCaption="All DateDimension" allDisplayName="DateDimension" type="data" hidden="false" showHierarchies="default">
</dimension>
<measure name="Comments" disabled="false" sourceProperty="Id" aggregate="COUNT" type="number" scale="0" hidden="false" searchable="false">
</measure>
<measure name="Comment points" disabled="false" sourceExpression="((%source.AvgVote)*(%source.VotesAmount))" aggregate="AVG" type="integer" hidden="false" searchable="false">
Expand Down
12 changes: 5 additions & 7 deletions src/cls/BI/Member.cls
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
</dimension>
<dimension name="DateDimension" disabled="false" hasAll="false" allCaption="All Created1" allDisplayName="Created1" sourceProperty="Created" type="time" calendar="gregorian" iKnowType="entity" hidden="false" showHierarchies="default">
<additionalDescription>undefined</additionalDescription>
<hierarchy name="H2" disabled="false" hidden="false">
<level name="MonthNum" displayName="Month" disabled="false" timeFunction="MonthNumber" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
</hierarchy>
<hierarchy name="H1" disabled="false" hidden="false">
<level name="Year" disabled="false" timeFunction="Year" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
Expand All @@ -33,12 +37,6 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
</level>
</hierarchy>
</dimension>
<dimension name="SubSuspended" disabled="false" hasAll="false" allCaption="All SubSuspended" allDisplayName="SubSuspended" type="data" hidden="false" showHierarchies="default">
<hierarchy name="H1" disabled="false" hidden="false">
<level name="SubSuspended" disabled="false" sourceProperty="SubSuspended" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
</hierarchy>
</dimension>
<measure name="MembersAmountBeforeDate" disabled="true" sourceExpression="%cube.GetMembersAmountBeforeDate(%source.Created)" aggregate="MAX" type="integer" hidden="false" searchable="false">
</measure>
<measure name="Views" disabled="true" sourceExpression="%cube.GetViewsOfAuthor(%source.%ID)" aggregate="SUM" type="number" hidden="false" searchable="false">
Expand All @@ -47,7 +45,7 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
</measure>
<measure name="MembersAmountBeforeDateMonth" disabled="true" sourceExpression="%cube.GetMembersAmountBeforeDate($zdateh($piece($zdate(%source.Created,3),&quot;-&quot;,1,2)_&quot;-01&quot;,3))" aggregate="AVG" type="integer" hidden="false" searchable="false">
</measure>
<listing name="New_listing1" disabled="false" listingType="table" fieldList="Name,Link">
<listing name="New_listing1" disabled="false" listingType="table" fieldList="Name,Position,Email,Company,Link">
</listing>
</cube>
}
Expand Down
2 changes: 1 addition & 1 deletion src/cls/BI/PC.cls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///
Class BI.PC Extends %DeepSee.SubjectArea [ DependsOn = (BI.Post, BI.CommentCopy), ProcedureBlock ]
Class BI.PC Extends %DeepSee.SubjectArea [ DependsOn = (BI.Post, BI.CommentCopy, BI.ViewsHistoryCopy), ProcedureBlock ]
{

/// SubjectArea definition from Architect.
Expand Down
44 changes: 29 additions & 15 deletions src/cls/BI/Post.cls
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
</dimension>
<dimension name="DateDimension" disabled="false" hasAll="false" allCaption="All Created1" allDisplayName="Created1" sourceProperty="Created" type="time" calendar="gregorian" iKnowType="entity" hidden="false" showHierarchies="default">
<additionalDescription>undefined</additionalDescription>
<hierarchy name="H2" disabled="false" hidden="false">
<level name="MonthNum" displayName="Month" disabled="false" timeFunction="MonthNumber" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
</hierarchy>
<hierarchy name="H1" disabled="false" hidden="false">
<level name="Year" disabled="false" timeFunction="Year" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
<level name="MonthYear" disabled="false" timeFunction="MonthYear" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
<level name="MonthYear" displayName="Month Year" disabled="false" timeFunction="MonthYear" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
<level name="WeekYear" disabled="false" timeFunction="WeekYear" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
Expand All @@ -93,12 +97,34 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
</level>
</hierarchy>
</dimension>
<dimension name="iKnow" disabled="true" hasAll="false" allCaption="All Text" allDisplayName="Text" type="data" calendar="gregorian" iKnowType="entity" hidden="false" showHierarchies="default">
<dimension name="iKnow" disabled="false" hasAll="false" allCaption="All Text" allDisplayName="Text" type="data" calendar="gregorian" iKnowType="entity" hidden="false" showHierarchies="default">
<hierarchy name="H1" disabled="false" hidden="false">
<level name="iKnowConcept" displayName="iKnowConcept" disabled="false" sourceExpression="##class(Community.iKnow.Post).GetFirstSetsAndConceptsByID(%source.%ID)" list="true" listDelimiter="," useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
</hierarchy>
</dimension>
<dimension name="CorrectAnswer" displayName="Correct Answer" disabled="false" hasAll="false" allCaption="All HasCorrectAnswer" allDisplayName="HasCorrectAnswer" type="data" calendar="gregorian" iKnowType="entity" hidden="false" showHierarchies="default">
<hierarchy name="H1" disabled="false" hidden="false">
<level name="HasCorrectAnswer" disabled="false" sourceProperty="HasCorrectAnswer" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
</hierarchy>
</dimension>
<dimension name="Published" disabled="false" hasAll="false" allCaption="All Published" allDisplayName="Published" type="data" hidden="false" showHierarchies="default">
<hierarchy name="H1" disabled="false" hidden="false">
<level name="Published" disabled="false" sourceProperty="Published" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
</hierarchy>
</dimension>
<dimension name="AcceptedAnswerTS" disabled="false" hasAll="false" allCaption="All AcceptedAnswerTS" allDisplayName="AcceptedAnswerTS" sourceProperty="AcceptedAnswerTS" type="time" calendar="gregorian" hidden="false" showHierarchies="default">
<hierarchy name="H1" disabled="false" hidden="false">
<level name="AnswerYear" disabled="false" timeFunction="Year" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
<level name="AnswerMonthYear" disabled="false" timeFunction="MonthYear" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
<level name="AnswerDayMonthYear" disabled="false" timeFunction="DayMonthYear" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
</level>
</hierarchy>
</dimension>
<measure name="CommentsAmount" disabled="false" sourceProperty="CommentsAmount" aggregate="SUM" type="number" hidden="false" searchable="false">
</measure>
<measure name="Posts" disabled="false" sourceProperty="%ID" aggregate="COUNT" type="number" hidden="false" searchable="false" formatString="#">
Expand All @@ -111,7 +137,7 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
</measure>
<measure name="SubsCount" displayName="Subscriptions" disabled="false" sourceProperty="SubsCount" aggregate="SUM" type="number" hidden="false" searchable="false" formatString="#">
</measure>
<listing name="New_listing1" disabled="false" listingType="table" fieldList="Link,Name As Post,Created,Views,CommentsAmount As Comments,AvgVote as Votes,&apos;&lt;a href=&quot;&apos;||$Extract(Author-&gt;Link,7,Length(Author-&gt;Link))||&apos;&quot; target=&quot;_blank&quot; onclick=&quot;var e=event||window.event;e.stopPropagation();e.cancelBubble=true;&quot;&gt;&apos;||Author-&gt;Name||&apos;&lt;/a&gt;&apos; As Author,SubsCount as Favorites">
<listing name="New_listing1" disabled="false" listingType="table" fieldList="Link,Name As Post,Created,Views,CommentsAmount As Comments,AvgVote as Votes,SubsCount as Favorites,Author-&gt;Name as Author,Author-&gt;Email as &quot;Author Email&quot;">
</listing>
</cube>
}
Expand Down Expand Up @@ -162,18 +188,6 @@ ClassMethod GetGroupName(postId, prop As %String) As %String
Quit result
}

ClassMethod GSContestOrAllDate(date As %Date, groupName As %String) As %String
{
set date = $zdh(date,3)
set result = "NonGSContest"
if (date<=63977)&(date>=63963)&(groupName'="Developer Community Feedback") {set result = "GSContest"} //2016-02-15 - 2016-02-29
elseif (date<=63994)&(date>=63980)
&(groupName'="Developer Community Feedback")
&(groupName'="Announcements")
&(groupName'="Alerts") {set result = "GSContest-2"} //2016-03-03 - 2016-03-17
Quit result
}

ClassMethod GetViewsHistoryDelta(date As %Date) As %Integer
{
set date = $zdh(date,3)
Expand Down
63 changes: 48 additions & 15 deletions src/cls/Community/Comment.cls
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Include Community

Class Community.Comment Extends %Persistent
Class Community.Comment Extends %Persistent [ DependsOn = (Community.Member, Community.Post, Community.Utils.Hash) ]
{

Parameter DSTIME = "AUTO";
Expand Down Expand Up @@ -38,12 +38,18 @@ Property Correct As %Boolean;
/// Hash of input row, used to build this object
Property Hash As %String;

Property TextHash As %String;

Index TextHashIndex On TextHash;

Relationship Votes As Community.Vote [ Cardinality = many, Inverse = Comment ];

Property AcceptedAnswerTS As %TimeStamp;

ClassMethod Upsert(Id, Type, Nid, Created, Uid, AvgVote, VotesAmount, Text, Correct) As %Status
{
Set Id1 = Type _ "||" _ Id
Set Hash = ##class(Community.Utils.Hash).Hash(Id, Type, Nid, Created, Uid, AvgVote, VotesAmount, Text, Correct)
Set Hash = ##class(Community.Utils.Hash).Hash(Id, Type, Nid, Created, Uid, AvgVote, VotesAmount, Text, Correct)
Return:(Hash=..HashGetStored(Id1)) $$$OK

If ..%ExistsId(Id1) {
Expand All @@ -62,22 +68,40 @@ ClassMethod Upsert(Id, Type, Nid, Created, Uid, AvgVote, VotesAmount, Text, Corr
Set Comment.VotesAmount = VotesAmount
Set Comment.Correct = Correct

set Text = $replace(Text,"</p>"," ")
set reg = ##class(%Regex.Matcher).%New("<(([^>]|\n)*)>")
set reg.Text = Text
set Text = reg.ReplaceAll("")
Set modify = 0
If (Correct = 1) & (Comment.AcceptedAnswerTS = "") {
Set Comment.AcceptedAnswerTS = $zdt($now(300),3)
Set modify = 1
} ElseIf (Correct = 0) & (Comment.AcceptedAnswerTS '= "") {
Set Comment.AcceptedAnswerTS = ""
Set modify = 1
}

set Text = $replace(Text,"&nbsp;"," ")
set Text = $replace(Text,"&gt;",">")
set Text = $replace(Text,"&lt;","<")
set Text = $replace(Text,"&amp;","&")
set Text = $replace(Text,"&quot;","""")
set Text = $replace(Text,"$#39;","'")
Set Comment.Text = Text
if modify = 1 {
Set Comment.Post.AcceptedAnswerTS = Comment.AcceptedAnswerTS
Set st = Comment.Post.%Save()
}

Set st = Comment.%Save()
Set TextHash = ##class(Community.Utils.Hash).Hash(Text)

Return st
If TextHash '= Comment.TextHash {
Set Text = $replace(Text,"</p>"," ")
Set reg = ##class(%Regex.Matcher).%New("<(([^>]|\n)*)>")
Set reg.Text = Text
Set Text = reg.ReplaceAll("")
Set Text = $replace(Text,"&nbsp;"," ")
Set Text = $replace(Text,"&gt;",">")
Set Text = $replace(Text,"&lt;","<")
Set Text = $replace(Text,"&amp;","&")
Set Text = $replace(Text,"&quot;","""")
Set Text = $replace(Text,"$#39;","'")
Set Comment.Text = Text
Set Comment.TextHash = TextHash
}

set st = Comment.%Save()

return st
}

Storage Default
Expand Down Expand Up @@ -116,6 +140,15 @@ Storage Default
<Value name="11">
<Value>Correct</Value>
</Value>
<Value name="12">
<Value>TextHash</Value>
</Value>
<Value name="13">
<Value>AsseptedAnswerTS</Value>
</Value>
<Value name="14">
<Value>AcceptedAnswerTS</Value>
</Value>
</Data>
<DataLocation>^Community.CommentD</DataLocation>
<DefaultData>CommentDefaultData</DefaultData>
Expand Down
2 changes: 1 addition & 1 deletion src/cls/Community/Group.cls
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Include Community

Class Community.Group Extends %Persistent [ SqlTableName = GroupClass ]
Class Community.Group Extends %Persistent [ DependsOn = Community.Utils.Hash, SqlTableName = GroupClass ]
{

Parameter DSTIME = "AUTO";
Expand Down
2 changes: 1 addition & 1 deletion src/cls/Community/GroupPost.cls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Class Community.GroupPost Extends %Persistent
Class Community.GroupPost Extends %Persistent [ DependsOn = (Community.Group, Community.Member) ]
{

Relationship GroupClass As Community.Group [ Cardinality = one, Inverse = Posts, OnDelete = cascade, Required ];
Expand Down
11 changes: 1 addition & 10 deletions src/cls/Community/Member.cls
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Include Community

Class Community.Member Extends %Persistent
Class Community.Member Extends %Persistent [ DependsOn = Community.Utils.Hash ]
{

Parameter MANAGEDEXTENT = 0;
Expand All @@ -19,18 +19,12 @@ Property FirstName As %String(MAXLEN = 255);

Property LastName As %String(MAXLEN = 255);

Property Company As %String(MAXLEN = 255);

Property Position As %String(MAXLEN = 255);

Property Created As %TimeStamp;

Property Link As %String(MAXLEN = 150) [ SqlComputeCode = {set {*} = $$$Server _ "user/" _ {Uid}}, SqlComputed, SqlComputeOnChange = %%INSERT ];

Index Link On Link [ Unique ];

Property SubSuspended As %Numeric;

Property Hash As %String;

Relationship Posts As Community.Post [ Cardinality = many, Inverse = Author ];
Expand All @@ -54,11 +48,8 @@ ClassMethod Upsert(Uid, FirstName, LastName, Company, Position, Created, SubSusp
Set Member.Hash = Hash
Set Member.FirstName = FirstName
Set Member.LastName = LastName
Set Member.Company = Company
Set Member.Position = Position

Set Member.Created = Created
Set Member.SubSuspended = SubSuspended

Set st = Member.%Save()

Expand Down
12 changes: 7 additions & 5 deletions src/cls/Community/Post.cls
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Include Community

Class Community.Post Extends %Persistent
Class Community.Post Extends %Persistent [ DependsOn = (Community.Member, Community.Utils.Hash) ]
{

Parameter DSTIME = "AUTO";
Expand Down Expand Up @@ -56,6 +56,8 @@ Property HasCorrectAnswer As %Boolean;

Relationship Votes As Community.Vote [ Cardinality = many, Inverse = Post ];

Property AcceptedAnswerTS As %TimeStamp;

ClassMethod GetCommentsAmount(id) As %Integer
{
set result = 0
Expand All @@ -67,8 +69,7 @@ ClassMethod GetCommentsAmount(id) As %Integer

ClassMethod Upsert(Nid, Name, Created, Uid, Tags, Type, Views, AvgVote, VotesAmount, Text, Groups, Published, PostType, SubsCount, HasCorrectAnswer) As %Status
{
Set Hash = ##class(Community.Utils.Hash).Hash(Nid, Name, Created, Uid, Tags, Type, Views, AvgVote, VotesAmount, Text,
Groups, Published, PostType, SubsCount, HasCorrectAnswer)
Set Hash = ##class(Community.Utils.Hash).Hash(Nid, Name, Created, Uid, Tags, Type, Views, AvgVote, VotesAmount, Text, Groups, Published, PostType, SubsCount, HasCorrectAnswer)
Return:(Hash=..HashGetStored(Nid)) $$$OK

If ..%ExistsId(Nid) {
Expand All @@ -91,14 +92,12 @@ ClassMethod Upsert(Nid, Name, Created, Uid, Tags, Type, Views, AvgVote, VotesAmo
set reg = ##class(%Regex.Matcher).%New("<(([^>]|\n)*)>")
set reg.Text = Text
set Text = reg.ReplaceAll("")

set Text = $replace(Text,"&nbsp;"," ")
set Text = $replace(Text,"&gt;",">")
set Text = $replace(Text,"&lt;","<")
set Text = $replace(Text,"&amp;","&")
set Text = $replace(Text,"&quot;","""")
set Text = $replace(Text,"&#39;","'")

Set Post.Text = Text
Set Post.SubsCount = SubsCount
Set Post.HasCorrectAnswer = HasCorrectAnswer
Expand Down Expand Up @@ -191,6 +190,9 @@ Storage Default
<Value name="20">
<Value>HasCorrectAnswer</Value>
</Value>
<Value name="21">
<Value>AcceptedAnswerTS</Value>
</Value>
</Data>
<DataLocation>^Community.PostD</DataLocation>
<DefaultData>PostDefaultData</DefaultData>
Expand Down
Loading

0 comments on commit 4bdb92d

Please sign in to comment.