Skip to content

Commit 4bdb92d

Browse files
committed
[UPD] Update community classes. Add dependencies.
1 parent 6f819e1 commit 4bdb92d

File tree

12 files changed

+99
-82
lines changed

12 files changed

+99
-82
lines changed

src/cls/BI/Comment.cls

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,6 @@ ClassMethod GetGroupName(postId, prop As %String) As %String
122122
Quit result
123123
}
124124

125-
ClassMethod GSContestOrAllDate(date As %Date, groupName As %String) As %String
126-
{
127-
set date = $zdh(date,3)
128-
set result = "NonGSContest"
129-
if (date<=63977)&(date>=63963)&(groupName'="Developer Community Feedback") {set result = "GSContest"} //2016-02-15 - 2016-02-29
130-
elseif (date<=63993)&(date>=63980)
131-
&(groupName'="Developer Community Feedback")
132-
&(groupName'="Announcements")
133-
&(groupName'="Alerts") {set result = "GSContest-2"} //2016-03-03 - 2016-03-16
134-
Quit result
135-
}
136-
137125
ClassMethod GetDaysNumber(date, id)
138126
{
139127
set result = 0

src/cls/BI/CommentCopy.cls

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
88
<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">
99
<dimension name="AuthorName" disabled="false" sharesFrom="Post" hasAll="false" allCaption="All AuthorName" allDisplayName="AuthorName" type="data" hidden="false" showHierarchies="default">
1010
</dimension>
11-
<dimension name="DateDimension" disabled="false" sharesFrom="Post" hasAll="false" allCaption="All DateDimension" allDisplayName="DateDimension" type="data" hidden="false" showHierarchies="default">
12-
</dimension>
1311
<measure name="Comments" disabled="false" sourceProperty="Id" aggregate="COUNT" type="number" scale="0" hidden="false" searchable="false">
1412
</measure>
1513
<measure name="Comment points" disabled="false" sourceExpression="((%source.AvgVote)*(%source.VotesAmount))" aggregate="AVG" type="integer" hidden="false" searchable="false">

src/cls/BI/Member.cls

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
2222
</dimension>
2323
<dimension name="DateDimension" disabled="false" hasAll="false" allCaption="All Created1" allDisplayName="Created1" sourceProperty="Created" type="time" calendar="gregorian" iKnowType="entity" hidden="false" showHierarchies="default">
2424
<additionalDescription>undefined</additionalDescription>
25+
<hierarchy name="H2" disabled="false" hidden="false">
26+
<level name="MonthNum" displayName="Month" disabled="false" timeFunction="MonthNumber" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
27+
</level>
28+
</hierarchy>
2529
<hierarchy name="H1" disabled="false" hidden="false">
2630
<level name="Year" disabled="false" timeFunction="Year" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
2731
</level>
@@ -33,12 +37,6 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
3337
</level>
3438
</hierarchy>
3539
</dimension>
36-
<dimension name="SubSuspended" disabled="false" hasAll="false" allCaption="All SubSuspended" allDisplayName="SubSuspended" type="data" hidden="false" showHierarchies="default">
37-
<hierarchy name="H1" disabled="false" hidden="false">
38-
<level name="SubSuspended" disabled="false" sourceProperty="SubSuspended" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
39-
</level>
40-
</hierarchy>
41-
</dimension>
4240
<measure name="MembersAmountBeforeDate" disabled="true" sourceExpression="%cube.GetMembersAmountBeforeDate(%source.Created)" aggregate="MAX" type="integer" hidden="false" searchable="false">
4341
</measure>
4442
<measure name="Views" disabled="true" sourceExpression="%cube.GetViewsOfAuthor(%source.%ID)" aggregate="SUM" type="number" hidden="false" searchable="false">
@@ -47,7 +45,7 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
4745
</measure>
4846
<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">
4947
</measure>
50-
<listing name="New_listing1" disabled="false" listingType="table" fieldList="Name,Link">
48+
<listing name="New_listing1" disabled="false" listingType="table" fieldList="Name,Position,Email,Company,Link">
5149
</listing>
5250
</cube>
5351
}

src/cls/BI/PC.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
///
2-
Class BI.PC Extends %DeepSee.SubjectArea [ DependsOn = (BI.Post, BI.CommentCopy), ProcedureBlock ]
2+
Class BI.PC Extends %DeepSee.SubjectArea [ DependsOn = (BI.Post, BI.CommentCopy, BI.ViewsHistoryCopy), ProcedureBlock ]
33
{
44

55
/// SubjectArea definition from Architect.

src/cls/BI/Post.cls

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,14 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
6363
</dimension>
6464
<dimension name="DateDimension" disabled="false" hasAll="false" allCaption="All Created1" allDisplayName="Created1" sourceProperty="Created" type="time" calendar="gregorian" iKnowType="entity" hidden="false" showHierarchies="default">
6565
<additionalDescription>undefined</additionalDescription>
66+
<hierarchy name="H2" disabled="false" hidden="false">
67+
<level name="MonthNum" displayName="Month" disabled="false" timeFunction="MonthNumber" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
68+
</level>
69+
</hierarchy>
6670
<hierarchy name="H1" disabled="false" hidden="false">
6771
<level name="Year" disabled="false" timeFunction="Year" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
6872
</level>
69-
<level name="MonthYear" disabled="false" timeFunction="MonthYear" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
73+
<level name="MonthYear" displayName="Month Year" disabled="false" timeFunction="MonthYear" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
7074
</level>
7175
<level name="WeekYear" disabled="false" timeFunction="WeekYear" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
7276
</level>
@@ -93,12 +97,34 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
9397
</level>
9498
</hierarchy>
9599
</dimension>
96-
<dimension name="iKnow" disabled="true" hasAll="false" allCaption="All Text" allDisplayName="Text" type="data" calendar="gregorian" iKnowType="entity" hidden="false" showHierarchies="default">
100+
<dimension name="iKnow" disabled="false" hasAll="false" allCaption="All Text" allDisplayName="Text" type="data" calendar="gregorian" iKnowType="entity" hidden="false" showHierarchies="default">
97101
<hierarchy name="H1" disabled="false" hidden="false">
98102
<level name="iKnowConcept" displayName="iKnowConcept" disabled="false" sourceExpression="##class(Community.iKnow.Post).GetFirstSetsAndConceptsByID(%source.%ID)" list="true" listDelimiter="," useDisplayValue="true" useAsFilter="true" hidden="false">
99103
</level>
100104
</hierarchy>
101105
</dimension>
106+
<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">
107+
<hierarchy name="H1" disabled="false" hidden="false">
108+
<level name="HasCorrectAnswer" disabled="false" sourceProperty="HasCorrectAnswer" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
109+
</level>
110+
</hierarchy>
111+
</dimension>
112+
<dimension name="Published" disabled="false" hasAll="false" allCaption="All Published" allDisplayName="Published" type="data" hidden="false" showHierarchies="default">
113+
<hierarchy name="H1" disabled="false" hidden="false">
114+
<level name="Published" disabled="false" sourceProperty="Published" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
115+
</level>
116+
</hierarchy>
117+
</dimension>
118+
<dimension name="AcceptedAnswerTS" disabled="false" hasAll="false" allCaption="All AcceptedAnswerTS" allDisplayName="AcceptedAnswerTS" sourceProperty="AcceptedAnswerTS" type="time" calendar="gregorian" hidden="false" showHierarchies="default">
119+
<hierarchy name="H1" disabled="false" hidden="false">
120+
<level name="AnswerYear" disabled="false" timeFunction="Year" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
121+
</level>
122+
<level name="AnswerMonthYear" disabled="false" timeFunction="MonthYear" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
123+
</level>
124+
<level name="AnswerDayMonthYear" disabled="false" timeFunction="DayMonthYear" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
125+
</level>
126+
</hierarchy>
127+
</dimension>
102128
<measure name="CommentsAmount" disabled="false" sourceProperty="CommentsAmount" aggregate="SUM" type="number" hidden="false" searchable="false">
103129
</measure>
104130
<measure name="Posts" disabled="false" sourceProperty="%ID" aggregate="COUNT" type="number" hidden="false" searchable="false" formatString="#">
@@ -111,7 +137,7 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
111137
</measure>
112138
<measure name="SubsCount" displayName="Subscriptions" disabled="false" sourceProperty="SubsCount" aggregate="SUM" type="number" hidden="false" searchable="false" formatString="#">
113139
</measure>
114-
<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">
140+
<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;">
115141
</listing>
116142
</cube>
117143
}
@@ -162,18 +188,6 @@ ClassMethod GetGroupName(postId, prop As %String) As %String
162188
Quit result
163189
}
164190

165-
ClassMethod GSContestOrAllDate(date As %Date, groupName As %String) As %String
166-
{
167-
set date = $zdh(date,3)
168-
set result = "NonGSContest"
169-
if (date<=63977)&(date>=63963)&(groupName'="Developer Community Feedback") {set result = "GSContest"} //2016-02-15 - 2016-02-29
170-
elseif (date<=63994)&(date>=63980)
171-
&(groupName'="Developer Community Feedback")
172-
&(groupName'="Announcements")
173-
&(groupName'="Alerts") {set result = "GSContest-2"} //2016-03-03 - 2016-03-17
174-
Quit result
175-
}
176-
177191
ClassMethod GetViewsHistoryDelta(date As %Date) As %Integer
178192
{
179193
set date = $zdh(date,3)

src/cls/Community/Comment.cls

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Include Community
22

3-
Class Community.Comment Extends %Persistent
3+
Class Community.Comment Extends %Persistent [ DependsOn = (Community.Member, Community.Post, Community.Utils.Hash) ]
44
{
55

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

41+
Property TextHash As %String;
42+
43+
Index TextHashIndex On TextHash;
44+
4145
Relationship Votes As Community.Vote [ Cardinality = many, Inverse = Comment ];
4246

47+
Property AcceptedAnswerTS As %TimeStamp;
48+
4349
ClassMethod Upsert(Id, Type, Nid, Created, Uid, AvgVote, VotesAmount, Text, Correct) As %Status
4450
{
4551
Set Id1 = Type _ "||" _ Id
46-
Set Hash = ##class(Community.Utils.Hash).Hash(Id, Type, Nid, Created, Uid, AvgVote, VotesAmount, Text, Correct)
52+
Set Hash = ##class(Community.Utils.Hash).Hash(Id, Type, Nid, Created, Uid, AvgVote, VotesAmount, Text, Correct)
4753
Return:(Hash=..HashGetStored(Id1)) $$$OK
4854

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

65-
set Text = $replace(Text,"</p>"," ")
66-
set reg = ##class(%Regex.Matcher).%New("<(([^>]|\n)*)>")
67-
set reg.Text = Text
68-
set Text = reg.ReplaceAll("")
71+
Set modify = 0
72+
If (Correct = 1) & (Comment.AcceptedAnswerTS = "") {
73+
Set Comment.AcceptedAnswerTS = $zdt($now(300),3)
74+
Set modify = 1
75+
} ElseIf (Correct = 0) & (Comment.AcceptedAnswerTS '= "") {
76+
Set Comment.AcceptedAnswerTS = ""
77+
Set modify = 1
78+
}
6979

70-
set Text = $replace(Text,"&nbsp;"," ")
71-
set Text = $replace(Text,"&gt;",">")
72-
set Text = $replace(Text,"&lt;","<")
73-
set Text = $replace(Text,"&amp;","&")
74-
set Text = $replace(Text,"&quot;","""")
75-
set Text = $replace(Text,"$#39;","'")
76-
Set Comment.Text = Text
80+
if modify = 1 {
81+
Set Comment.Post.AcceptedAnswerTS = Comment.AcceptedAnswerTS
82+
Set st = Comment.Post.%Save()
83+
}
7784

78-
Set st = Comment.%Save()
85+
Set TextHash = ##class(Community.Utils.Hash).Hash(Text)
7986

80-
Return st
87+
If TextHash '= Comment.TextHash {
88+
Set Text = $replace(Text,"</p>"," ")
89+
Set reg = ##class(%Regex.Matcher).%New("<(([^>]|\n)*)>")
90+
Set reg.Text = Text
91+
Set Text = reg.ReplaceAll("")
92+
Set Text = $replace(Text,"&nbsp;"," ")
93+
Set Text = $replace(Text,"&gt;",">")
94+
Set Text = $replace(Text,"&lt;","<")
95+
Set Text = $replace(Text,"&amp;","&")
96+
Set Text = $replace(Text,"&quot;","""")
97+
Set Text = $replace(Text,"$#39;","'")
98+
Set Comment.Text = Text
99+
Set Comment.TextHash = TextHash
100+
}
101+
102+
set st = Comment.%Save()
103+
104+
return st
81105
}
82106

83107
Storage Default
@@ -116,6 +140,15 @@ Storage Default
116140
<Value name="11">
117141
<Value>Correct</Value>
118142
</Value>
143+
<Value name="12">
144+
<Value>TextHash</Value>
145+
</Value>
146+
<Value name="13">
147+
<Value>AsseptedAnswerTS</Value>
148+
</Value>
149+
<Value name="14">
150+
<Value>AcceptedAnswerTS</Value>
151+
</Value>
119152
</Data>
120153
<DataLocation>^Community.CommentD</DataLocation>
121154
<DefaultData>CommentDefaultData</DefaultData>

src/cls/Community/Group.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Include Community
22

3-
Class Community.Group Extends %Persistent [ SqlTableName = GroupClass ]
3+
Class Community.Group Extends %Persistent [ DependsOn = Community.Utils.Hash, SqlTableName = GroupClass ]
44
{
55

66
Parameter DSTIME = "AUTO";

src/cls/Community/GroupPost.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Class Community.GroupPost Extends %Persistent
1+
Class Community.GroupPost Extends %Persistent [ DependsOn = (Community.Group, Community.Member) ]
22
{
33

44
Relationship GroupClass As Community.Group [ Cardinality = one, Inverse = Posts, OnDelete = cascade, Required ];

src/cls/Community/Member.cls

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Include Community
22

3-
Class Community.Member Extends %Persistent
3+
Class Community.Member Extends %Persistent [ DependsOn = Community.Utils.Hash ]
44
{
55

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

2020
Property LastName As %String(MAXLEN = 255);
2121

22-
Property Company As %String(MAXLEN = 255);
23-
24-
Property Position As %String(MAXLEN = 255);
25-
2622
Property Created As %TimeStamp;
2723

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

3026
Index Link On Link [ Unique ];
3127

32-
Property SubSuspended As %Numeric;
33-
3428
Property Hash As %String;
3529

3630
Relationship Posts As Community.Post [ Cardinality = many, Inverse = Author ];
@@ -54,11 +48,8 @@ ClassMethod Upsert(Uid, FirstName, LastName, Company, Position, Created, SubSusp
5448
Set Member.Hash = Hash
5549
Set Member.FirstName = FirstName
5650
Set Member.LastName = LastName
57-
Set Member.Company = Company
58-
Set Member.Position = Position
5951

6052
Set Member.Created = Created
61-
Set Member.SubSuspended = SubSuspended
6253

6354
Set st = Member.%Save()
6455

src/cls/Community/Post.cls

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Include Community
22

3-
Class Community.Post Extends %Persistent
3+
Class Community.Post Extends %Persistent [ DependsOn = (Community.Member, Community.Utils.Hash) ]
44
{
55

66
Parameter DSTIME = "AUTO";
@@ -56,6 +56,8 @@ Property HasCorrectAnswer As %Boolean;
5656

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

59+
Property AcceptedAnswerTS As %TimeStamp;
60+
5961
ClassMethod GetCommentsAmount(id) As %Integer
6062
{
6163
set result = 0
@@ -67,8 +69,7 @@ ClassMethod GetCommentsAmount(id) As %Integer
6769

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

7475
If ..%ExistsId(Nid) {
@@ -91,14 +92,12 @@ ClassMethod Upsert(Nid, Name, Created, Uid, Tags, Type, Views, AvgVote, VotesAmo
9192
set reg = ##class(%Regex.Matcher).%New("<(([^>]|\n)*)>")
9293
set reg.Text = Text
9394
set Text = reg.ReplaceAll("")
94-
9595
set Text = $replace(Text,"&nbsp;"," ")
9696
set Text = $replace(Text,"&gt;",">")
9797
set Text = $replace(Text,"&lt;","<")
9898
set Text = $replace(Text,"&amp;","&")
9999
set Text = $replace(Text,"&quot;","""")
100100
set Text = $replace(Text,"&#39;","'")
101-
102101
Set Post.Text = Text
103102
Set Post.SubsCount = SubsCount
104103
Set Post.HasCorrectAnswer = HasCorrectAnswer
@@ -191,6 +190,9 @@ Storage Default
191190
<Value name="20">
192191
<Value>HasCorrectAnswer</Value>
193192
</Value>
193+
<Value name="21">
194+
<Value>AcceptedAnswerTS</Value>
195+
</Value>
194196
</Data>
195197
<DataLocation>^Community.PostD</DataLocation>
196198
<DefaultData>PostDefaultData</DefaultData>

0 commit comments

Comments
 (0)