Commit 5fb57526 authored by Liang Ding's avatar Liang Ding

🎨 #12676 目录生成

parent 84c5daf0
...@@ -190,27 +190,47 @@ public class ExportService { ...@@ -190,27 +190,47 @@ public class ExportService {
bodyBuilder.append("\n* [").append(title).append("](").append(link).append(")"); bodyBuilder.append("\n* [").append(title).append("](").append(link).append(")");
articleIds.add(article.optString(Keys.OBJECT_ID)); articleIds.add(article.optString(Keys.OBJECT_ID));
} }
bodyBuilder.append("\n\n热门\n\n"); bodyBuilder.append("\n\n");
final List<JSONObject> mostViewArticles = articleRepository.getList(new Query().select(Keys.OBJECT_ID, Article.ARTICLE_TITLE, Article.ARTICLE_PERMALINK).addSort(Article.ARTICLE_VIEW_COUNT, SortDirection.DESCENDING).setPage(1, 20));
final StringBuilder mostViewBuilder = new StringBuilder();
final List<JSONObject> mostViewArticles = articleRepository.getList(new Query().select(Keys.OBJECT_ID, Article.ARTICLE_TITLE, Article.ARTICLE_PERMALINK).addSort(Article.ARTICLE_VIEW_COUNT, SortDirection.DESCENDING).setPage(1, 40));
int count = 0;
for (final JSONObject article : mostViewArticles) { for (final JSONObject article : mostViewArticles) {
final String articleId = article.optString(Keys.OBJECT_ID); final String articleId = article.optString(Keys.OBJECT_ID);
if (!articleIds.contains(articleId)) { if (!articleIds.contains(articleId)) {
final String title = article.optString(Article.ARTICLE_TITLE); final String title = article.optString(Article.ARTICLE_TITLE);
final String link = Latkes.getServePath() + article.optString(Article.ARTICLE_PERMALINK); final String link = Latkes.getServePath() + article.optString(Article.ARTICLE_PERMALINK);
bodyBuilder.append("\n* [").append(title).append("](").append(link).append(")"); mostViewBuilder.append("\n* [").append(title).append("](").append(link).append(")");
articleIds.add(articleId);
count++;
} }
if (20 <= count) {
break;
}
}
if (0 < mostViewBuilder.length()) {
bodyBuilder.append("热门\n\n").append(mostViewBuilder).append("\n\n");
} }
bodyBuilder.append("\n\n热议\n\n");
final List<JSONObject> mostCmtArticles = articleRepository.getList(new Query().select(Keys.OBJECT_ID, Article.ARTICLE_TITLE, Article.ARTICLE_PERMALINK).addSort(Article.ARTICLE_COMMENT_COUNT, SortDirection.DESCENDING).setPage(1, 20)); final StringBuilder mostCmtBuilder = new StringBuilder();
final List<JSONObject> mostCmtArticles = articleRepository.getList(new Query().select(Keys.OBJECT_ID, Article.ARTICLE_TITLE, Article.ARTICLE_PERMALINK).addSort(Article.ARTICLE_COMMENT_COUNT, SortDirection.DESCENDING).setPage(1, 60));
count = 0;
for (final JSONObject article : mostCmtArticles) { for (final JSONObject article : mostCmtArticles) {
final String articleId = article.optString(Keys.OBJECT_ID); final String articleId = article.optString(Keys.OBJECT_ID);
if (!articleIds.contains(articleId)) { if (!articleIds.contains(articleId)) {
final String title = article.optString(Article.ARTICLE_TITLE); final String title = article.optString(Article.ARTICLE_TITLE);
final String link = Latkes.getServePath() + article.optString(Article.ARTICLE_PERMALINK); final String link = Latkes.getServePath() + article.optString(Article.ARTICLE_PERMALINK);
bodyBuilder.append("\n* [").append(title).append("](").append(link).append(")"); mostCmtBuilder.append("\n* [").append(title).append("](").append(link).append(")");
articleIds.add(articleId);
count++;
}
if (20 <= count) {
break;
} }
} }
bodyBuilder.append("\n\n"); if (0 < mostCmtBuilder.length()) {
bodyBuilder.append("热议\n\n").append(mostCmtBuilder).append("\n\n");
}
final HttpResponse response = HttpRequest.post("http://localhost:8080/github/repos").connectionTimeout(7000).timeout(60000).header("User-Agent", Solos.USER_AGENT). final HttpResponse response = HttpRequest.post("http://localhost:8080/github/repos").connectionTimeout(7000).timeout(60000).header("User-Agent", Solos.USER_AGENT).
form("userName", userName, form("userName", userName,
......
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