Source:
<code>private List<SolrArticleAdapter> retrieveRecentArticles(String journalKey, int articleCount, double numberOfDaysAgo, List<String> articleTypes, List<String> articleTypesToExclude) throws IOException { ArrayList<String> journalKeys = new ArrayList<>(); journalKeys.add(journalKey); LocalDate startDate = LocalDate.now().minusDays((long) numberOfDaysAgo); SolrSearchApiImpl.SolrExplicitDateRange dateRange = new SolrSearchApiImpl.SolrExplicitDateRange ("Recent Articles", startDate.toString(), LocalDate.now().toString()); ArticleSearchQuery recentArticleSearchQuery = ArticleSearchQuery.builder() .setStart(0) .setRows(MAXIMUM_RESULTS) .setSortOrder(SolrSearchApiImpl.SolrSortOrder.DATE_NEWEST_FIRST) .setArticleTypes(articleTypes) .setArticleTypesToExclude(articleTypesToExclude) .setDateRange(dateRange) .setJournalKeys(journalKeys) .build(); Map<String, ?> results = solrSearchApi.search(recentArticleSearchQuery); <START> List<SolrArticleAdapter> articles = SolrArticleAdapter.unpackSolrQuery(results); <END> if (articles.size() < articleCount) { if (articleTypes.size() > 1) { String errorMessage = "" + "Service does not support queries for a minimum number of recent articles " + "filtered by multiple article types. " + "To make a valid query, client must either " + "(1) omit the 'min' parameter, " + "(2) use no more than one 'type' parameter, or " + "(3) include the wildcard type parameter ('type=*')."; throw new RuntimeException(errorMessage); } else { articles = getAllArticles(articleTypes, articleTypesToExclude, journalKeys); } } return articles; }</code><technical_language>remove shuffling logic for articles.size() > articleCount? also, need add order type logic articles pub date</technical_language>

Target:
private List<SolrArticleAdapter> retrieveRecentArticles(String journalKey, int articleCount, double numberOfDaysAgo, List<String> articleTypes, List<String> articleTypesToExclude) throws IOException { List<String> journalKeys = ImmutableList.of(journalKey); LocalDate startDate = LocalDate.now().minusDays((long) numberOfDaysAgo); SolrSearchApiImpl.SolrExplicitDateRange dateRange = new SolrSearchApiImpl.SolrExplicitDateRange ("Recent Articles", startDate.toString(), LocalDate.now().toString()); Set<String> uniqueDois = new HashSet<>(); List<SolrArticleAdapter> articles = new ArrayList<>(); for (String articleType : articleTypes) { List<SolrArticleAdapter> recentArticles; if (articleType.equals(ARTICLE_TYPE_WILDCARD)) { recentArticles = getAllRecentArticles(articleTypesToExclude, journalKeys, dateRange); } else { recentArticles = getRecentArticlesByType(articleType, articleTypesToExclude, journalKeys, dateRange); } for (SolrArticleAdapter article : recentArticles) { if (uniqueDois.add(article.getDoi())) { articles.add(article); } } } if (articles.size() < articleCount) { if (articleTypes.size() > 1 && !articleTypes.contains(ARTICLE_TYPE_WILDCARD)) { String errorMessage = "" + "Recent articles results did not contain more articles than the minimum number " + "configured via the resultCount parameter. To make a valid query, alter homepage.yaml: " + "(1) use no more than one article type in the articleType list, or " + "(2) use the wildcard type parameter (*)."; throw new RuntimeException(errorMessage); } else { articles.addAll(getAllArticlesByType(articleTypes, articleTypesToExclude, journalKeys)); } } return articles; }