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
d2dad771
Unverified
Commit
d2dad771
authored
Apr 18, 2020
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
♻
彻底移除浏览数统计相关代码 Fix #110
parent
44dd7433
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
7 additions
and
243 deletions
+7
-243
src/main/java/org/b3log/solo/processor/ArticleProcessor.java
src/main/java/org/b3log/solo/processor/ArticleProcessor.java
+1
-17
src/main/java/org/b3log/solo/processor/CategoryProcessor.java
...main/java/org/b3log/solo/processor/CategoryProcessor.java
+1
-9
src/main/java/org/b3log/solo/processor/IndexProcessor.java
src/main/java/org/b3log/solo/processor/IndexProcessor.java
+2
-11
src/main/java/org/b3log/solo/processor/TagProcessor.java
src/main/java/org/b3log/solo/processor/TagProcessor.java
+1
-8
src/main/java/org/b3log/solo/processor/UserTemplateProcessor.java
.../java/org/b3log/solo/processor/UserTemplateProcessor.java
+1
-9
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
+0
-40
src/main/java/org/b3log/solo/service/StatisticMgmtService.java
...ain/java/org/b3log/solo/service/StatisticMgmtService.java
+1
-149
No files found.
src/main/java/org/b3log/solo/processor/ArticleProcessor.java
View file @
d2dad771
...
@@ -52,7 +52,7 @@ import java.util.*;
...
@@ -52,7 +52,7 @@ import java.util.*;
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/ZephyrJung">Zephyr</a>
* @author <a href="https://hacpai.com/member/ZephyrJung">Zephyr</a>
* @version 2.0.0.
0, Feb 9
, 2020
* @version 2.0.0.
1, Apr 18
, 2020
* @since 0.3.1
* @since 0.3.1
*/
*/
@Singleton
@Singleton
...
@@ -117,12 +117,6 @@ public class ArticleProcessor {
...
@@ -117,12 +117,6 @@ public class ArticleProcessor {
@Inject
@Inject
private
ArticleMgmtService
articleMgmtService
;
private
ArticleMgmtService
articleMgmtService
;
/**
* Statistic management service.
*/
@Inject
private
StatisticMgmtService
statisticMgmtService
;
/**
/**
* Event manager.
* Event manager.
*/
*/
...
@@ -608,8 +602,6 @@ public class ArticleProcessor {
...
@@ -608,8 +602,6 @@ public class ArticleProcessor {
dataModelService
.
fillFaviconURL
(
dataModel
,
preference
);
dataModelService
.
fillFaviconURL
(
dataModel
,
preference
);
dataModelService
.
fillUsite
(
dataModel
);
dataModelService
.
fillUsite
(
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
(
String
)
context
.
attr
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
(
String
)
context
.
attr
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
statisticMgmtService
.
incBlogViewCount
(
context
,
response
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
@@ -663,8 +655,6 @@ public class ArticleProcessor {
...
@@ -663,8 +655,6 @@ public class ArticleProcessor {
dataModelService
.
fillCommon
(
context
,
dataModel
,
preference
);
dataModelService
.
fillCommon
(
context
,
dataModel
,
preference
);
dataModelService
.
fillFaviconURL
(
dataModel
,
preference
);
dataModelService
.
fillFaviconURL
(
dataModel
,
preference
);
dataModelService
.
fillUsite
(
dataModel
);
dataModelService
.
fillUsite
(
dataModel
);
statisticMgmtService
.
incBlogViewCount
(
context
,
response
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
context
.
sendError
(
404
);
context
.
sendError
(
404
);
...
@@ -725,12 +715,6 @@ public class ArticleProcessor {
...
@@ -725,12 +715,6 @@ public class ArticleProcessor {
dataModelService
.
fillUsite
(
dataModel
);
dataModelService
.
fillUsite
(
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
(
String
)
context
.
attr
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
(
String
)
context
.
attr
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
if
(!
StatisticMgmtService
.
hasBeenServed
(
context
,
response
))
{
articleMgmtService
.
incViewCount
(
articleId
);
}
statisticMgmtService
.
incBlogViewCount
(
context
,
response
);
// Fire [Before Render Article] event
// Fire [Before Render Article] event
final
JSONObject
eventData
=
new
JSONObject
();
final
JSONObject
eventData
=
new
JSONObject
();
eventData
.
put
(
Article
.
ARTICLE
,
article
);
eventData
.
put
(
Article
.
ARTICLE
,
article
);
...
...
src/main/java/org/b3log/solo/processor/CategoryProcessor.java
View file @
d2dad771
...
@@ -43,7 +43,7 @@ import java.util.Map;
...
@@ -43,7 +43,7 @@ import java.util.Map;
* Category processor.
* Category processor.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.0.
1, Feb 27
, 2020
* @version 2.0.0.
2, Apr 18
, 2020
* @since 2.0.0
* @since 2.0.0
*/
*/
@Singleton
@Singleton
...
@@ -90,12 +90,6 @@ public class CategoryProcessor {
...
@@ -90,12 +90,6 @@ public class CategoryProcessor {
@Inject
@Inject
private
CategoryQueryService
categoryQueryService
;
private
CategoryQueryService
categoryQueryService
;
/**
* Statistic management service.
*/
@Inject
private
StatisticMgmtService
statisticMgmtService
;
/**
/**
* Gets category articles paged with the specified context.
* Gets category articles paged with the specified context.
*
*
...
@@ -191,8 +185,6 @@ public class CategoryProcessor {
...
@@ -191,8 +185,6 @@ public class CategoryProcessor {
dataModelService
.
fillCommon
(
context
,
dataModel
,
preference
);
dataModelService
.
fillCommon
(
context
,
dataModel
,
preference
);
dataModelService
.
fillFaviconURL
(
dataModel
,
preference
);
dataModelService
.
fillFaviconURL
(
dataModel
,
preference
);
dataModelService
.
fillUsite
(
dataModel
);
dataModelService
.
fillUsite
(
dataModel
);
statisticMgmtService
.
incBlogViewCount
(
context
,
response
);
}
catch
(
final
ServiceException
|
JSONException
e
)
{
}
catch
(
final
ServiceException
|
JSONException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
src/main/java/org/b3log/solo/processor/IndexProcessor.java
View file @
d2dad771
...
@@ -36,7 +36,6 @@ import org.b3log.solo.model.Option;
...
@@ -36,7 +36,6 @@ import org.b3log.solo.model.Option;
import
org.b3log.solo.service.DataModelService
;
import
org.b3log.solo.service.DataModelService
;
import
org.b3log.solo.service.InitService
;
import
org.b3log.solo.service.InitService
;
import
org.b3log.solo.service.OptionQueryService
;
import
org.b3log.solo.service.OptionQueryService
;
import
org.b3log.solo.service.StatisticMgmtService
;
import
org.b3log.solo.util.Skins
;
import
org.b3log.solo.util.Skins
;
import
org.b3log.solo.util.Solos
;
import
org.b3log.solo.util.Solos
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
...
@@ -49,8 +48,8 @@ import java.util.Map;
...
@@ -49,8 +48,8 @@ import java.util.Map;
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/DASHU">DASHU</a>
* @author <a href="https://hacpai.com/member/DASHU">DASHU</a>
* @author <a href="http
s
://vanessa.b3log.org">Vanessa</a>
* @author <a href="http://vanessa.b3log.org">Vanessa</a>
* @version 2.0.0.
0, Feb 9
, 2020
* @version 2.0.0.
1, Apr 18
, 2020
* @since 0.3.1
* @since 0.3.1
*/
*/
@Singleton
@Singleton
...
@@ -79,12 +78,6 @@ public class IndexProcessor {
...
@@ -79,12 +78,6 @@ public class IndexProcessor {
@Inject
@Inject
private
LangPropsService
langPropsService
;
private
LangPropsService
langPropsService
;
/**
* Statistic management service.
*/
@Inject
private
StatisticMgmtService
statisticMgmtService
;
/**
/**
* Initialization service.
* Initialization service.
*/
*/
...
@@ -142,8 +135,6 @@ public class IndexProcessor {
...
@@ -142,8 +135,6 @@ public class IndexProcessor {
final
int
nextPageNum
=
currentPageNum
+
1
>
pageCount
?
pageCount
:
currentPageNum
+
1
;
final
int
nextPageNum
=
currentPageNum
+
1
>
pageCount
?
pageCount
:
currentPageNum
+
1
;
dataModel
.
put
(
Pagination
.
PAGINATION_NEXT_PAGE_NUM
,
nextPageNum
);
dataModel
.
put
(
Pagination
.
PAGINATION_NEXT_PAGE_NUM
,
nextPageNum
);
dataModel
.
put
(
Common
.
PATH
,
""
);
dataModel
.
put
(
Common
.
PATH
,
""
);
statisticMgmtService
.
incBlogViewCount
(
context
,
response
);
}
catch
(
final
ServiceException
e
)
{
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
src/main/java/org/b3log/solo/processor/TagProcessor.java
View file @
d2dad771
...
@@ -38,7 +38,7 @@ import java.util.Map;
...
@@ -38,7 +38,7 @@ import java.util.Map;
* Tag processor.
* Tag processor.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.0.
0, Feb 9
, 2020
* @version 2.0.0.
1, Apr 18
, 2020
* @since 0.3.1
* @since 0.3.1
*/
*/
@Singleton
@Singleton
...
@@ -85,12 +85,6 @@ public class TagProcessor {
...
@@ -85,12 +85,6 @@ public class TagProcessor {
@Inject
@Inject
private
TagQueryService
tagQueryService
;
private
TagQueryService
tagQueryService
;
/**
* Statistic management service.
*/
@Inject
private
StatisticMgmtService
statisticMgmtService
;
/**
/**
* Shows articles related with a tag with the specified context.
* Shows articles related with a tag with the specified context.
*
*
...
@@ -138,7 +132,6 @@ public class TagProcessor {
...
@@ -138,7 +132,6 @@ public class TagProcessor {
dataModelService
.
fillCommon
(
context
,
dataModel
,
preference
);
dataModelService
.
fillCommon
(
context
,
dataModel
,
preference
);
dataModelService
.
fillFaviconURL
(
dataModel
,
preference
);
dataModelService
.
fillFaviconURL
(
dataModel
,
preference
);
dataModelService
.
fillUsite
(
dataModel
);
dataModelService
.
fillUsite
(
dataModel
);
statisticMgmtService
.
incBlogViewCount
(
context
,
context
.
getResponse
());
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
src/main/java/org/b3log/solo/processor/UserTemplateProcessor.java
View file @
d2dad771
...
@@ -29,7 +29,6 @@ import org.b3log.latke.util.Locales;
...
@@ -29,7 +29,6 @@ import org.b3log.latke.util.Locales;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.service.DataModelService
;
import
org.b3log.solo.service.DataModelService
;
import
org.b3log.solo.service.OptionQueryService
;
import
org.b3log.solo.service.OptionQueryService
;
import
org.b3log.solo.service.StatisticMgmtService
;
import
org.b3log.solo.util.Markdowns
;
import
org.b3log.solo.util.Markdowns
;
import
org.b3log.solo.util.Skins
;
import
org.b3log.solo.util.Skins
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
...
@@ -46,7 +45,7 @@ import java.util.Map;
...
@@ -46,7 +45,7 @@ import java.util.Map;
* </p>
* </p>
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.0.
0, Feb 9
, 2020
* @version 2.0.0.
1, Apr 18
, 2020
* @since 0.4.5
* @since 0.4.5
*/
*/
@Singleton
@Singleton
...
@@ -69,12 +68,6 @@ public class UserTemplateProcessor {
...
@@ -69,12 +68,6 @@ public class UserTemplateProcessor {
@Inject
@Inject
private
LangPropsService
langPropsService
;
private
LangPropsService
langPropsService
;
/**
* Statistic management service.
*/
@Inject
private
StatisticMgmtService
statisticMgmtService
;
/**
/**
* Option query service.
* Option query service.
*/
*/
...
@@ -127,7 +120,6 @@ public class UserTemplateProcessor {
...
@@ -127,7 +120,6 @@ public class UserTemplateProcessor {
dataModelService
.
fillUsite
(
dataModel
);
dataModelService
.
fillUsite
(
dataModel
);
dataModelService
.
fillUserTemplate
(
context
,
template
,
dataModel
,
preference
);
dataModelService
.
fillUserTemplate
(
context
,
template
,
dataModel
,
preference
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
(
String
)
context
.
attr
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
(
String
)
context
.
attr
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
statisticMgmtService
.
incBlogViewCount
(
context
,
response
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
View file @
d2dad771
...
@@ -644,46 +644,6 @@ public class ArticleMgmtService {
...
@@ -644,46 +644,6 @@ public class ArticleMgmtService {
}
}
}
}
/**
* Increments the view count of the article specified by the given article id.
*
* @param articleId the given article id
* @throws ServiceException service exception
*/
public
void
incViewCount
(
final
String
articleId
)
throws
ServiceException
{
// v3.7.0 后开始使用社区浏览计数服务 https://github.com/Vanessa219/uvstat
// JSONObject article;
//
// try {
// article = articleRepository.get(articleId);
//
// if (null == article) {
// return;
// }
// } catch (final RepositoryException e) {
// LOGGER.log(Level.ERROR, "Gets article [id=" + articleId + "] failed", e);
//
// return;
// }
//
// final Transaction transaction = articleRepository.beginTransaction();
// try {
// article.put(Article.ARTICLE_VIEW_COUNT, article.getInt(Article.ARTICLE_VIEW_COUNT) + 1);
// articleRepository.update(articleId, article, ARTICLE_VIEW_COUNT);
//
// transaction.commit();
// } catch (final Exception e) {
// if (transaction.isActive()) {
// transaction.rollback();
// }
//
// LOGGER.log(Level.WARN, "Updates article view count failed");
//
// throw new ServiceException(e);
// }
}
/**
/**
* Un-archive an article specified by the given specified article id.
* Un-archive an article specified by the given specified article id.
*
*
...
...
src/main/java/org/b3log/solo/service/StatisticMgmtService.java
View file @
d2dad771
...
@@ -14,33 +14,24 @@ package org.b3log.solo.service;
...
@@ -14,33 +14,24 @@ package org.b3log.solo.service;
import
org.apache.logging.log4j.Level
;
import
org.apache.logging.log4j.Level
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.b3log.latke.http.Cookie
;
import
org.b3log.latke.http.Request
;
import
org.b3log.latke.http.Request
;
import
org.b3log.latke.http.RequestContext
;
import
org.b3log.latke.http.Response
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.service.LangPropsService
;
import
org.b3log.latke.service.LangPropsService
;
import
org.b3log.latke.service.ServiceException
;
import
org.b3log.latke.service.annotation.Service
;
import
org.b3log.latke.service.annotation.Service
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.latke.util.URLs
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.OptionRepository
;
import
org.b3log.solo.repository.OptionRepository
;
import
org.b3log.solo.util.Solos
;
import
org.b3log.solo.util.Solos
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
/**
* Statistic management service.
* Statistic management service.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.1.
6, Apr 14
, 2020
* @version 2.0.1.
7, Apr 18
, 2020
* @since 0.5.0
* @since 0.5.0
*/
*/
@Service
@Service
...
@@ -107,134 +98,6 @@ public class StatisticMgmtService {
...
@@ -107,134 +98,6 @@ public class StatisticMgmtService {
LOGGER
.
log
(
Level
.
DEBUG
,
"Current online visitor count [{}]"
,
ONLINE_VISITORS
.
size
());
LOGGER
.
log
(
Level
.
DEBUG
,
"Current online visitor count [{}]"
,
ONLINE_VISITORS
.
size
());
}
}
/**
* Determines whether the specified request has been served.
* <p>
* A "served request" is a request a URI as former one. For example, if a client is request "/test", all requests from the client
* subsequent in 24 hours will be treated as served requests, requested URIs save in client cookie (name: "visited").
* </p>
* <p>
* If the specified request has not been served, appends the request URI in client cookie.
* </p>
* <p>
* Sees this issue (https://github.com/b3log/solo/issues/44) for more details.
* </p>
*
* @param context the specified request context
* @param response the specified response
* @return {@code true} if the specified request has been served, returns {@code false} otherwise
*/
public
static
boolean
hasBeenServed
(
final
RequestContext
context
,
final
Response
response
)
{
final
Request
request
=
context
.
getRequest
();
final
Set
<
Cookie
>
cookies
=
request
.
getCookies
();
if
(
cookies
.
isEmpty
())
{
return
false
;
}
boolean
needToCreate
=
true
;
boolean
needToAppend
=
true
;
JSONArray
cookieJSONArray
=
null
;
try
{
for
(
final
Cookie
cookie
:
cookies
)
{
if
(!
"visited"
.
equals
(
cookie
.
getName
()))
{
continue
;
}
final
String
value
=
URLs
.
decode
(
cookie
.
getValue
());
cookieJSONArray
=
new
JSONArray
(
value
);
if
(
0
==
cookieJSONArray
.
length
())
{
return
false
;
}
needToCreate
=
false
;
for
(
int
j
=
0
;
j
<
cookieJSONArray
.
length
();
j
++)
{
final
String
visitedURL
=
cookieJSONArray
.
optString
(
j
);
if
(
request
.
getRequestURI
().
equals
(
visitedURL
))
{
return
true
;
}
}
}
if
(
needToCreate
)
{
final
StringBuilder
builder
=
new
StringBuilder
(
"["
).
append
(
"\""
).
append
(
request
.
getRequestURI
()).
append
(
"\"]"
);
final
Cookie
c
=
new
Cookie
(
"visited"
,
URLs
.
encode
(
builder
.
toString
()));
c
.
setMaxAge
(
COOKIE_EXPIRY
);
c
.
setPath
(
"/"
);
response
.
addCookie
(
c
);
}
else
if
(
needToAppend
)
{
cookieJSONArray
.
put
(
request
.
getRequestURI
());
final
Cookie
c
=
new
Cookie
(
"visited"
,
URLs
.
encode
(
cookieJSONArray
.
toString
()));
c
.
setMaxAge
(
COOKIE_EXPIRY
);
c
.
setPath
(
"/"
);
response
.
addCookie
(
c
);
}
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Parses cookie failed, clears the cookie[name=visited]"
);
final
Cookie
c
=
new
Cookie
(
"visited"
,
""
);
c
.
setMaxAge
(
0
);
c
.
setPath
(
"/"
);
response
.
addCookie
(
c
);
}
return
false
;
}
/**
* Blog statistic view count +1.
* <p>
* If it is a search engine bot made the specified request, will NOT increment blog statistic view count.
* </p>
* <p>
* There is a cron job (/console/stat/viewcnt) to flush the blog view count from cache to datastore.
* </p>
*
* @param context the specified request context
* @param response the specified response
* @throws ServiceException service exception
*/
public
void
incBlogViewCount
(
final
RequestContext
context
,
final
Response
response
)
throws
ServiceException
{
// v3.7.0 后开始使用社区浏览计数服务 https://github.com/Vanessa219/uvstat
// if (Solos.isBot(context.getRequest())) {
// return;
// }
//
// if (hasBeenServed(context, response)) {
// return;
// }
//
// final Transaction transaction = optionRepository.beginTransaction();
// JSONObject statistic;
// try {
// statistic = optionRepository.get(Option.ID_C_STATISTIC_BLOG_VIEW_COUNT);
// if (null == statistic) {
// return;
// }
//
// LOGGER.log(Level.TRACE, "Before inc blog view count is [{}]", statistic);
//
// statistic.put(Option.OPTION_VALUE, statistic.optInt(Option.OPTION_VALUE) + 1);
//
// updateStatistic(Option.ID_C_STATISTIC_BLOG_VIEW_COUNT, statistic);
//
// transaction.commit();
// } catch (final RepositoryException e) {
// if (transaction.isActive()) {
// transaction.rollback();
// }
//
// LOGGER.log(Level.ERROR, "Updates blog view count failed", e);
//
// return;
// }
//
// LOGGER.log(Level.TRACE, "Inced blog view count[statistic={}]", statistic);
}
/**
/**
* Refreshes online visitor count for the specified request.
* Refreshes online visitor count for the specified request.
*
*
...
@@ -250,15 +113,4 @@ public class StatisticMgmtService {
...
@@ -250,15 +113,4 @@ public class StatisticMgmtService {
ONLINE_VISITORS
.
put
(
remoteAddr
,
System
.
currentTimeMillis
());
ONLINE_VISITORS
.
put
(
remoteAddr
,
System
.
currentTimeMillis
());
LOGGER
.
log
(
Level
.
DEBUG
,
"Current online visitor count [{}]"
,
ONLINE_VISITORS
.
size
());
LOGGER
.
log
(
Level
.
DEBUG
,
"Current online visitor count [{}]"
,
ONLINE_VISITORS
.
size
());
}
}
/**
* Updates the statistic with the specified statistic.
*
* @param id the specified statistic id
* @param statistic the specified statistic
* @throws RepositoryException repository exception
*/
private
void
updateStatistic
(
final
String
id
,
final
JSONObject
statistic
)
throws
RepositoryException
{
optionRepository
.
update
(
id
,
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