Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
78f0ff30
Unverified
Commit
78f0ff30
authored
Jan 28, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
♻
#12633
parent
40cb1365
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
9 additions
and
149 deletions
+9
-149
src/main/java/org/b3log/solo/model/Option.java
src/main/java/org/b3log/solo/model/Option.java
+0
-5
src/main/java/org/b3log/solo/processor/BlogProcessor.java
src/main/java/org/b3log/solo/processor/BlogProcessor.java
+3
-2
src/main/java/org/b3log/solo/processor/api/B3CommentReceiver.java
.../java/org/b3log/solo/processor/api/B3CommentReceiver.java
+2
-8
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
+0
-31
src/main/java/org/b3log/solo/service/CommentMgmtService.java
src/main/java/org/b3log/solo/service/CommentMgmtService.java
+3
-26
src/main/java/org/b3log/solo/service/InitService.java
src/main/java/org/b3log/solo/service/InitService.java
+1
-16
src/main/java/org/b3log/solo/service/StatisticMgmtService.java
...ain/java/org/b3log/solo/service/StatisticMgmtService.java
+0
-45
src/main/java/org/b3log/solo/service/StatisticQueryService.java
...in/java/org/b3log/solo/service/StatisticQueryService.java
+0
-16
No files found.
src/main/java/org/b3log/solo/model/Option.java
View file @
78f0ff30
...
...
@@ -319,11 +319,6 @@ public final class Option {
*/
public
static
final
String
ID_C_STATISTIC_BLOG_VIEW_COUNT
=
"statisticBlogViewCount"
;
/**
* Key of statistic blog comment(published article) count.
*/
public
static
final
String
ID_C_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT
=
"statisticPublishedBlogCommentCount"
;
/**
* Key of oauth GitHub.
*/
...
...
src/main/java/org/b3log/solo/processor/BlogProcessor.java
View file @
78f0ff30
...
...
@@ -113,8 +113,9 @@ public class BlogProcessor {
final
JSONObject
statistic
=
statisticQueryService
.
getStatistic
();
// TODO: 重构数据统计计数 #12633 jsonObject.put("articleCount", statistic.getLong(Option.ID_C_STATISTIC_PUBLISHED_ARTICLE_COUNT));
jsonObject
.
put
(
"commentCount"
,
statistic
.
getLong
(
Option
.
ID_C_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT
));
// TODO: 重构数据统计计数 #12633
// jsonObject.put("articleCount", statistic.getLong(Option.ID_C_STATISTIC_PUBLISHED_ARTICLE_COUNT));
// jsonObject.put("commentCount", statistic.getLong(Option.ID_C_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT));
jsonObject
.
put
(
"tagCount"
,
tagQueryService
.
getTagCount
());
jsonObject
.
put
(
"servePath"
,
Latkes
.
getServePath
());
jsonObject
.
put
(
"staticServePath"
,
Latkes
.
getStaticServePath
());
...
...
src/main/java/org/b3log/solo/processor/api/B3CommentReceiver.java
View file @
78f0ff30
...
...
@@ -52,7 +52,7 @@ import java.util.Date;
* Receiving comments from B3log community. Visits <a href="https://hacpai.com/b3log">B3log 构思</a> for more details.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.
19, Nov 6, 2018
* @version 1.1.1.
20, Jan 28, 2019
* @since 0.5.5
*/
@RequestProcessor
...
...
@@ -224,26 +224,20 @@ public class B3CommentReceiver {
}
ret
.
put
(
Comment
.
COMMENT_THUMBNAIL_URL
,
comment
.
getString
(
Comment
.
COMMENT_THUMBNAIL_URL
));
// Sets comment on article....
comment
.
put
(
Comment
.
COMMENT_ON_ID
,
articleId
);
comment
.
put
(
Comment
.
COMMENT_ON_TYPE
,
Article
.
ARTICLE
);
final
String
commentSharpURL
=
Comment
.
getCommentSharpURLForArticle
(
article
,
commentId
);
comment
.
put
(
Comment
.
COMMENT_SHARP_URL
,
commentSharpURL
);
commentRepository
.
add
(
comment
);
// Step 2: Update article comment count
articleMgmtService
.
incArticleCommentCount
(
articleId
);
// Step 3: Update blog statistic comment count
statisticMgmtService
.
incPublishedBlogCommentCount
();
// Step 4: Send an email to admin
try
{
commentMgmtService
.
sendNotificationMail
(
article
,
comment
,
originalComment
,
preference
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Send mail failed"
,
e
);
}
// Step 5: Fire add comment event
final
JSONObject
eventData
=
new
JSONObject
();
final
JSONObject
eventData
=
new
JSONObject
();
eventData
.
put
(
Comment
.
COMMENT
,
comment
);
eventData
.
put
(
Article
.
ARTICLE
,
article
);
eventManager
.
fireEventSynchronously
(
new
Event
<>(
EventTypes
.
ADD_COMMENT_TO_ARTICLE_FROM_SYMPHONY
,
eventData
));
...
...
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
View file @
78f0ff30
...
...
@@ -202,11 +202,6 @@ public class ArticleMgmtService {
decArchiveDatePublishedRefCount
(
articleId
);
articleRepository
.
update
(
articleId
,
article
);
final
int
blogCmtCnt
=
statisticQueryService
.
getPublishedBlogCommentCount
();
final
int
articleCmtCnt
=
article
.
getInt
(
ARTICLE_COMMENT_COUNT
);
statisticMgmtService
.
setPublishedBlogCommentCount
(
blogCmtCnt
-
articleCmtCnt
);
final
JSONObject
author
=
userRepository
.
get
(
article
.
optString
(
Article
.
ARTICLE_AUTHOR_ID
));
author
.
put
(
UserExt
.
USER_PUBLISHED_ARTICLE_COUNT
,
author
.
optInt
(
UserExt
.
USER_PUBLISHED_ARTICLE_COUNT
)
-
1
);
userRepository
.
update
(
author
.
optString
(
Keys
.
OBJECT_ID
),
author
);
...
...
@@ -339,11 +334,6 @@ public class ArticleMgmtService {
// Set statistic
if
(
publishNewArticle
)
{
// This article is updated from unpublished to published
final
int
blogCmtCnt
=
statisticQueryService
.
getPublishedBlogCommentCount
();
final
int
articleCmtCnt
=
article
.
getInt
(
ARTICLE_COMMENT_COUNT
);
statisticMgmtService
.
setPublishedBlogCommentCount
(
blogCmtCnt
+
articleCmtCnt
);
final
JSONObject
author
=
userRepository
.
get
(
article
.
optString
(
Article
.
ARTICLE_AUTHOR_ID
));
author
.
put
(
UserExt
.
USER_PUBLISHED_ARTICLE_COUNT
,
author
.
optInt
(
UserExt
.
USER_PUBLISHED_ARTICLE_COUNT
)
+
1
);
userRepository
.
update
(
author
.
optString
(
Keys
.
OBJECT_ID
),
author
);
...
...
@@ -536,7 +526,6 @@ public class ArticleMgmtService {
decTagRefCount
(
articleId
);
unArchiveDate
(
articleId
);
removeTagArticleRelations
(
articleId
);
removeArticleComments
(
articleId
);
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
...
...
@@ -955,26 +944,6 @@ public class ArticleMgmtService {
return
ret
;
}
/**
* Removes article comments by the specified article id.
* <p>
* Removes related comments, sets article/blog comment statistic count.
* </p>
*
* @param articleId the specified article id
* @throws Exception exception
*/
private
void
removeArticleComments
(
final
String
articleId
)
throws
Exception
{
final
int
removedCnt
=
commentRepository
.
removeComments
(
articleId
);
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
if
(
article
.
optBoolean
(
Article
.
ARTICLE_IS_PUBLISHED
))
{
int
publishedBlogCommentCount
=
statisticQueryService
.
getPublishedBlogCommentCount
();
publishedBlogCommentCount
-=
removedCnt
;
statisticMgmtService
.
setPublishedBlogCommentCount
(
publishedBlogCommentCount
);
}
}
/**
* Archive the create date with the specified article.
*
...
...
src/main/java/org/b3log/solo/service/CommentMgmtService.java
View file @
78f0ff30
...
...
@@ -445,13 +445,10 @@ public class CommentMgmtService {
}
setCommentThumbnailURL
(
comment
);
ret
.
put
(
Comment
.
COMMENT_THUMBNAIL_URL
,
comment
.
getString
(
Comment
.
COMMENT_THUMBNAIL_URL
));
// Sets comment on page....
comment
.
put
(
Comment
.
COMMENT_ON_ID
,
pageId
);
comment
.
put
(
Comment
.
COMMENT_ON_TYPE
,
Page
.
PAGE
);
final
String
commentId
=
Ids
.
genTimeMillisId
();
ret
.
put
(
Keys
.
OBJECT_ID
,
commentId
);
// Save comment sharp URL
final
String
commentSharpURL
=
Comment
.
getCommentSharpURLForPage
(
page
,
commentId
);
ret
.
put
(
Comment
.
COMMENT_NAME
,
commentName
);
ret
.
put
(
Comment
.
COMMENT_CONTENT
,
commentContent
);
...
...
@@ -461,19 +458,14 @@ public class CommentMgmtService {
comment
.
put
(
Comment
.
COMMENT_SHARP_URL
,
commentSharpURL
);
comment
.
put
(
Keys
.
OBJECT_ID
,
commentId
);
commentRepository
.
add
(
comment
);
// Step 2: Update page comment count
incPageCommentCount
(
pageId
);
// Step 3: Update blog statistic comment count
statisticMgmtService
.
incPublishedBlogCommentCount
();
// Step 4: Send an email to admin
try
{
sendNotificationMail
(
page
,
comment
,
originalComment
,
preference
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Send mail failed"
,
e
);
}
// Step 5: Fire add comment event
final
JSONObject
eventData
=
new
JSONObject
();
final
JSONObject
eventData
=
new
JSONObject
();
eventData
.
put
(
Comment
.
COMMENT
,
comment
);
eventData
.
put
(
Page
.
PAGE
,
page
);
eventManager
.
fireEventSynchronously
(
new
Event
<>(
EventTypes
.
ADD_COMMENT_TO_PAGE
,
eventData
));
...
...
@@ -586,7 +578,6 @@ public class CommentMgmtService {
}
setCommentThumbnailURL
(
comment
);
ret
.
put
(
Comment
.
COMMENT_THUMBNAIL_URL
,
comment
.
getString
(
Comment
.
COMMENT_THUMBNAIL_URL
));
// Sets comment on article....
comment
.
put
(
Comment
.
COMMENT_ON_ID
,
articleId
);
comment
.
put
(
Comment
.
COMMENT_ON_TYPE
,
Article
.
ARTICLE
);
final
String
commentId
=
Ids
.
genTimeMillisId
();
...
...
@@ -598,19 +589,15 @@ public class CommentMgmtService {
ret
.
put
(
Comment
.
COMMENT_SHARP_URL
,
commentSharpURL
);
commentRepository
.
add
(
comment
);
// Step 2: Update article comment count
articleMgmtService
.
incArticleCommentCount
(
articleId
);
// Step 3: Update blog statistic comment count
statisticMgmtService
.
incPublishedBlogCommentCount
();
// Step 4: Send an email to admin
try
{
sendNotificationMail
(
article
,
comment
,
originalComment
,
preference
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Send mail failed"
,
e
);
}
// Step 5: Fire add comment event
final
JSONObject
eventData
=
new
JSONObject
();
final
JSONObject
eventData
=
new
JSONObject
();
eventData
.
put
(
Comment
.
COMMENT
,
comment
);
eventData
.
put
(
Article
.
ARTICLE
,
article
);
eventManager
.
fireEventSynchronously
(
new
Event
<>(
EventTypes
.
ADD_COMMENT_TO_ARTICLE
,
eventData
));
...
...
@@ -639,13 +626,8 @@ public class CommentMgmtService {
try
{
final
JSONObject
comment
=
commentRepository
.
get
(
commentId
);
final
String
pageId
=
comment
.
getString
(
Comment
.
COMMENT_ON_ID
);
// Step 1: Remove comment
commentRepository
.
remove
(
commentId
);
// Step 2: Update page comment count
decPageCommentCount
(
pageId
);
// Step 3: Update blog statistic comment count
statisticMgmtService
.
decPublishedBlogCommentCount
();
transaction
.
commit
();
}
catch
(
final
Exception
e
)
{
...
...
@@ -671,13 +653,8 @@ public class CommentMgmtService {
try
{
final
JSONObject
comment
=
commentRepository
.
get
(
commentId
);
final
String
articleId
=
comment
.
getString
(
Comment
.
COMMENT_ON_ID
);
// Step 1: Remove comment
commentRepository
.
remove
(
commentId
);
// Step 2: Update article comment count
decArticleCommentCount
(
articleId
);
// Step 3: Update blog statistic comment count
statisticMgmtService
.
decPublishedBlogCommentCount
();
transaction
.
commit
();
}
catch
(
final
Exception
e
)
{
...
...
src/main/java/org/b3log/solo/service/InitService.java
View file @
78f0ff30
...
...
@@ -302,23 +302,14 @@ public class InitService {
try
{
article
.
put
(
Keys
.
OBJECT_ID
,
ret
);
// Step 1: Add tags
final
String
tagsString
=
article
.
optString
(
Article
.
ARTICLE_TAGS_REF
);
final
String
[]
tagTitles
=
tagsString
.
split
(
","
);
final
JSONArray
tags
=
tag
(
tagTitles
,
article
);
// Step 2: Add tag-article relations
addTagArticleRelation
(
tags
,
article
);
// Step 3: Inc blog article and comment count statictis
statisticMgmtService
.
incPublishedBlogCommentCount
();
// Step 4: Add archive date-article relations
archiveDate
(
article
);
// Step 5: Add article
articleRepository
.
add
(
article
);
// Step 6: Update admin user for article statistic
final
JSONObject
admin
=
userRepository
.
getAdmin
();
final
JSONObject
admin
=
userRepository
.
getAdmin
();
admin
.
put
(
UserExt
.
USER_ARTICLE_COUNT
,
1
);
admin
.
put
(
UserExt
.
USER_PUBLISHED_ARTICLE_COUNT
,
1
);
userRepository
.
update
(
admin
.
optString
(
Keys
.
OBJECT_ID
),
admin
);
...
...
@@ -484,12 +475,6 @@ public class InitService {
statisticBlogViewCountOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_STATISTIC
);
optionRepository
.
add
(
statisticBlogViewCountOpt
);
final
JSONObject
statisticPublishedBlogCommentCountOpt
=
new
JSONObject
();
statisticPublishedBlogCommentCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT
);
statisticPublishedBlogCommentCountOpt
.
put
(
Option
.
OPTION_VALUE
,
"0"
);
statisticPublishedBlogCommentCountOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_STATISTIC
);
optionRepository
.
add
(
statisticPublishedBlogCommentCountOpt
);
LOGGER
.
debug
(
"Initialized statistic"
);
}
...
...
src/main/java/org/b3log/solo/service/StatisticMgmtService.java
View file @
78f0ff30
...
...
@@ -253,51 +253,6 @@ public class StatisticMgmtService {
LOGGER
.
log
(
Level
.
TRACE
,
"Inced blog view count[statistic={0}]"
,
statistic
);
}
/**
* Blog statistic comment(published article) count +1.
*
* @throws RepositoryException repository exception
*/
public
void
incPublishedBlogCommentCount
()
throws
RepositoryException
{
final
JSONObject
statistic
=
optionRepository
.
get
(
Option
.
ID_C_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT
);
if
(
null
==
statistic
)
{
throw
new
RepositoryException
(
"Not found statistic"
);
}
statistic
.
put
(
Option
.
OPTION_VALUE
,
statistic
.
optInt
(
Option
.
OPTION_VALUE
)
+
1
);
updateStatistic
(
Option
.
ID_C_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT
,
statistic
);
}
/**
* Blog statistic comment(published article) count -1.
*
* @throws RepositoryException repository exception
*/
public
void
decPublishedBlogCommentCount
()
throws
RepositoryException
{
final
JSONObject
statistic
=
optionRepository
.
get
(
Option
.
ID_C_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT
);
if
(
null
==
statistic
)
{
throw
new
RepositoryException
(
"Not found statistic"
);
}
statistic
.
put
(
Option
.
OPTION_VALUE
,
statistic
.
optInt
(
Option
.
OPTION_VALUE
)
-
1
);
updateStatistic
(
Option
.
ID_C_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT
,
statistic
);
}
/**
* Sets blog comment(published article) count with the specified count.
*
* @param count the specified count
* @throws RepositoryException repository exception
*/
public
void
setPublishedBlogCommentCount
(
final
int
count
)
throws
RepositoryException
{
final
JSONObject
statistic
=
optionRepository
.
get
(
Option
.
ID_C_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT
);
if
(
null
==
statistic
)
{
throw
new
RepositoryException
(
"Not found statistic"
);
}
statistic
.
put
(
Option
.
OPTION_VALUE
,
count
);
updateStatistic
(
Option
.
ID_C_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT
,
statistic
);
}
/**
* Refreshes online visitor count for the specified request.
*
...
...
src/main/java/org/b3log/solo/service/StatisticQueryService.java
View file @
78f0ff30
...
...
@@ -20,7 +20,6 @@ package org.b3log.solo.service;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.service.ServiceException
;
import
org.b3log.latke.service.annotation.Service
;
import
org.b3log.solo.model.Option
;
import
org.json.JSONObject
;
...
...
@@ -55,21 +54,6 @@ public class StatisticQueryService {
return
StatisticMgmtService
.
ONLINE_VISITORS
.
size
();
}
/**
* Get blog comment(published article) count.
*
* @return blog comment count
* @throws ServiceException service exception
*/
public
int
getPublishedBlogCommentCount
()
throws
ServiceException
{
final
JSONObject
opt
=
optionQueryService
.
getOptionById
(
Option
.
ID_C_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT
);
if
(
null
==
opt
)
{
throw
new
ServiceException
(
"Not found statistic"
);
}
return
opt
.
optInt
(
Option
.
OPTION_VALUE
);
}
/**
* Gets the statistic.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment