Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
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
Commits
e074c44c
Commit
e074c44c
authored
Jul 23, 2012
by
Liang Ding
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #51 from 88250/master
#16
parents
707d008b
ded32103
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
core/src/main/java/org/b3log/solo/processor/StatProcessor.java
...src/main/java/org/b3log/solo/processor/StatProcessor.java
+20
-12
No files found.
core/src/main/java/org/b3log/solo/processor/StatProcessor.java
View file @
e074c44c
...
@@ -15,12 +15,10 @@
...
@@ -15,12 +15,10 @@
*/
*/
package
org
.
b3log
.
solo
.
processor
;
package
org
.
b3log
.
solo
.
processor
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.Set
;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.RuntimeEnv
;
import
org.b3log.latke.action.AbstractCacheablePageAction
;
import
org.b3log.latke.action.AbstractCacheablePageAction
;
import
org.b3log.latke.annotation.RequestProcessing
;
import
org.b3log.latke.annotation.RequestProcessing
;
import
org.b3log.latke.annotation.RequestProcessor
;
import
org.b3log.latke.annotation.RequestProcessor
;
...
@@ -31,6 +29,7 @@ import org.b3log.latke.service.LangPropsService;
...
@@ -31,6 +29,7 @@ import org.b3log.latke.service.LangPropsService;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.renderer.DoNothingRenderer
;
import
org.b3log.latke.servlet.renderer.DoNothingRenderer
;
import
org.b3log.latke.util.CollectionUtils
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.PageTypes
;
import
org.b3log.solo.model.PageTypes
;
import
org.b3log.solo.model.Statistic
;
import
org.b3log.solo.model.Statistic
;
...
@@ -54,7 +53,7 @@ import org.json.JSONObject;
...
@@ -54,7 +53,7 @@ import org.json.JSONObject;
* <p>
* <p>
*
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.1.
5, May 31
, 2012
* @version 1.0.1.
7, Jul 24
, 2012
* @since 0.4.0
* @since 0.4.0
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -76,6 +75,10 @@ public final class StatProcessor {
...
@@ -76,6 +75,10 @@ public final class StatProcessor {
* Language service.
* Language service.
*/
*/
private
LangPropsService
langPropsService
=
LangPropsService
.
getInstance
();
private
LangPropsService
langPropsService
=
LangPropsService
.
getInstance
();
/**
* Flush size.
*/
private
static
final
int
FLUSH_SIZE
=
30
;
/**
/**
* Online visitor count refresher.
* Online visitor count refresher.
...
@@ -115,9 +118,19 @@ public final class StatProcessor {
...
@@ -115,9 +118,19 @@ public final class StatProcessor {
try
{
try
{
// For blog view counter
// For blog view counter
statisticRepository
.
update
(
Statistic
.
STATISTIC
,
statistic
);
statisticRepository
.
update
(
Statistic
.
STATISTIC
,
statistic
);
// For article view counter
// For article view counter
final
Set
<
String
>
cachedPageKeys
=
PageCaches
.
getKeys
();
final
Set
<
String
>
keys
=
PageCaches
.
getKeys
();
final
List
<
String
>
keyList
=
new
ArrayList
<
String
>(
keys
);
final
int
size
=
keys
.
size
()
>
FLUSH_SIZE
?
FLUSH_SIZE
:
keys
.
size
();
// Flush FLUSH_SIZE articles at most
final
List
<
Integer
>
idx
=
CollectionUtils
.
getRandomIntegers
(
0
,
keys
.
size
(),
size
);
final
Set
<
String
>
cachedPageKeys
=
new
HashSet
<
String
>();
for
(
final
Integer
i
:
idx
)
{
cachedPageKeys
.
add
(
keyList
.
get
(
i
));
}
for
(
final
String
cachedPageKey
:
cachedPageKeys
)
{
for
(
final
String
cachedPageKey
:
cachedPageKeys
)
{
final
JSONObject
cachedPage
=
PageCaches
.
get
(
cachedPageKey
);
final
JSONObject
cachedPage
=
PageCaches
.
get
(
cachedPageKey
);
if
(
null
==
cachedPage
)
{
if
(
null
==
cachedPage
)
{
...
@@ -131,11 +144,6 @@ public final class StatProcessor {
...
@@ -131,11 +144,6 @@ public final class StatProcessor {
}
}
final
int
hitCount
=
cachedPage
.
optInt
(
PageCaches
.
CACHED_HIT_COUNT
);
final
int
hitCount
=
cachedPage
.
optInt
(
PageCaches
.
CACHED_HIT_COUNT
);
if
(
2
>
hitCount
&&
RuntimeEnv
.
GAE
==
Latkes
.
getRuntimeEnv
())
{
// Skips for view count tiny-changes, reduces Datastore Write Quota for Solo GAE version
continue
;
}
final
String
articleId
=
cachedPage
.
optString
(
AbstractCacheablePageAction
.
CACHED_OID
);
final
String
articleId
=
cachedPage
.
optString
(
AbstractCacheablePageAction
.
CACHED_OID
);
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
...
@@ -152,7 +160,7 @@ public final class StatProcessor {
...
@@ -152,7 +160,7 @@ public final class StatProcessor {
article
.
put
(
Article
.
ARTICLE_VIEW_COUNT
,
viewCount
);
article
.
put
(
Article
.
ARTICLE_VIEW_COUNT
,
viewCount
);
article
.
put
(
Article
.
ARTICLE_RANDOM_DOUBLE
,
Math
.
random
());
// Updates random value
article
.
put
(
Article
.
ARTICLE_RANDOM_DOUBLE
,
Math
.
random
());
// Updates random value
articleRepository
.
update
(
articleId
,
article
);
articleRepository
.
update
(
articleId
,
article
);
cachedPage
.
put
(
PageCaches
.
CACHED_HIT_COUNT
,
0
);
cachedPage
.
put
(
PageCaches
.
CACHED_HIT_COUNT
,
0
);
...
...
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