Commit d9b5fe64 authored by Liang Ding's avatar Liang Ding

#12633

parent a90fc29d
...@@ -409,8 +409,7 @@ public class ArticleProcessor { ...@@ -409,8 +409,7 @@ public class ArticleProcessor {
} }
final List<JSONObject> articles = (List<JSONObject>) tagArticleResult.opt(Keys.RESULTS); final List<JSONObject> articles = (List<JSONObject>) tagArticleResult.opt(Keys.RESULTS);
final int tagArticleCount = tagArticleResult.optJSONObject(Pagination.PAGINATION).optInt(Pagination.PAGINATION_PAGE_COUNT); final int pageCount = tagArticleResult.optJSONObject(Pagination.PAGINATION).optInt(Pagination.PAGINATION_PAGE_COUNT);
final int pageCount = (int) Math.ceil((double) tagArticleCount / (double) pageSize);
dataModelService.setArticlesExProperties(context, articles, preference); dataModelService.setArticlesExProperties(context, articles, preference);
final JSONObject result = new JSONObject(); final JSONObject result = new JSONObject();
......
...@@ -141,12 +141,8 @@ public class TagProcessor { ...@@ -141,12 +141,8 @@ public class TagProcessor {
final List<JSONObject> articles = (List<JSONObject>) tagArticleResult.opt(Keys.RESULTS); final List<JSONObject> articles = (List<JSONObject>) tagArticleResult.opt(Keys.RESULTS);
dataModelService.setArticlesExProperties(context, articles, preference); dataModelService.setArticlesExProperties(context, articles, preference);
final int tagArticleCount = tagArticleResult.optJSONObject(Pagination.PAGINATION).optInt(Pagination.PAGINATION_PAGE_COUNT); final int pageCount = tagArticleResult.optJSONObject(Pagination.PAGINATION).optInt(Pagination.PAGINATION_PAGE_COUNT);
final int pageCount = (int) Math.ceil((double) tagArticleCount / (double) pageSize);
LOGGER.log(Level.TRACE, "Paginate tag-articles [currentPageNum={0}, pageSize={1}, pageCount={2}, windowSize={3}]",
currentPageNum, pageSize, pageCount, windowSize);
final List<Integer> pageNums = Paginator.paginate(currentPageNum, pageSize, pageCount, windowSize); final List<Integer> pageNums = Paginator.paginate(currentPageNum, pageSize, pageCount, windowSize);
LOGGER.log(Level.TRACE, "tag-articles [pageNums={0}]", pageNums);
fillPagination(dataModel, pageCount, currentPageNum, articles, pageNums); fillPagination(dataModel, pageCount, currentPageNum, articles, pageNums);
dataModel.put(Common.PATH, "/tags/" + URLs.encode(tagTitle)); dataModel.put(Common.PATH, "/tags/" + URLs.encode(tagTitle));
dataModel.put(Keys.OBJECT_ID, tagId); dataModel.put(Keys.OBJECT_ID, tagId);
......
...@@ -76,7 +76,7 @@ public class TagConsole { ...@@ -76,7 +76,7 @@ public class TagConsole {
* { * {
* "sc": boolean, * "sc": boolean,
* "tags": [ * "tags": [
* {"tagTitle": "", tagReferenceCount": int, ....}, * {"tagTitle": "", ....},
* .... * ....
* ] * ]
* } * }
...@@ -110,7 +110,7 @@ public class TagConsole { ...@@ -110,7 +110,7 @@ public class TagConsole {
* { * {
* "sc": boolean, * "sc": boolean,
* "unusedTags": [ * "unusedTags": [
* {"tagTitle": "", tagReferenceCount": int, ....}, * {"tagTitle": "", ....},
* .... * ....
* ] * ]
* } * }
......
...@@ -93,8 +93,7 @@ public class ArchiveDateQueryService { ...@@ -93,8 +93,7 @@ public class ArchiveDateQueryService {
* "archiveDate": { * "archiveDate": {
* "oId": "", * "oId": "",
* "archiveTime": "", * "archiveTime": "",
* "archiveDatePublishedArticleCount": int, * "archiveDatePublishedArticleCount": int
* "archiveDateArticleCount": int
* } * }
* } * }
* </pre>, returns {@code null} if not found * </pre>, returns {@code null} if not found
......
...@@ -630,6 +630,7 @@ public class ArticleQueryService { ...@@ -630,6 +630,7 @@ public class ArticleQueryService {
if (0 == tagArticleRelations.length()) { if (0 == tagArticleRelations.length()) {
return null; return null;
} }
final JSONObject pagination = result.optJSONObject(Pagination.PAGINATION);
final Set<String> articleIds = new HashSet<>(); final Set<String> articleIds = new HashSet<>();
for (int i = 0; i < tagArticleRelations.length(); i++) { for (int i = 0; i < tagArticleRelations.length(); i++) {
...@@ -656,7 +657,7 @@ public class ArticleQueryService { ...@@ -656,7 +657,7 @@ public class ArticleQueryService {
retArticles.add(article); retArticles.add(article);
} }
final JSONObject ret = new JSONObject(); final JSONObject ret = new JSONObject();
ret.put(Pagination.PAGINATION, result.optJSONObject(Pagination.PAGINATION)); ret.put(Pagination.PAGINATION, pagination);
ret.put(Keys.RESULTS, (Object) retArticles); ret.put(Keys.RESULTS, (Object) retArticles);
return ret; return ret;
......
...@@ -77,7 +77,6 @@ public class TagQueryService { ...@@ -77,7 +77,6 @@ public class TagQueryService {
* "tag": { * "tag": {
* "oId": "", * "oId": "",
* "tagTitle": "", * "tagTitle": "",
* "tagReferenceCount": int,
* "tagPublishedRefCount": int * "tagPublishedRefCount": int
* } * }
* } * }
...@@ -86,15 +85,13 @@ public class TagQueryService { ...@@ -86,15 +85,13 @@ public class TagQueryService {
*/ */
public JSONObject getTagByTitle(final String tagTitle) throws ServiceException { public JSONObject getTagByTitle(final String tagTitle) throws ServiceException {
try { try {
final JSONObject ret = new JSONObject();
final JSONObject tag = tagRepository.getByTitle(tagTitle); final JSONObject tag = tagRepository.getByTitle(tagTitle);
if (null == tag) { if (null == tag) {
return null; return null;
} }
final JSONObject ret = new JSONObject();
ret.put(Tag.TAG, tag); ret.put(Tag.TAG, tag);
LOGGER.log(Level.DEBUG, "Got an tag[title={0}]", tagTitle);
return ret; return ret;
} catch (final RepositoryException e) { } catch (final RepositoryException e) {
...@@ -123,7 +120,7 @@ public class TagQueryService { ...@@ -123,7 +120,7 @@ public class TagQueryService {
* *
* @return for example, <pre> * @return for example, <pre>
* [ * [
* {"tagTitle": "", "tagReferenceCount": int, ....}, * {"tagTitle": "", ....},
* .... * ....
* ] * ]
* </pre>, returns an empty list if not found * </pre>, returns an empty list if not found
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment