You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by "Glen Mazza (JIRA)" <ji...@apache.org> on 2014/06/02 00:31:02 UTC
[jira] [Resolved] (ROL-1716) a bug found when call getPopularTags
with the limit=-1 (v4 m1)
[ https://issues.apache.org/jira/browse/ROL-1716?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Glen Mazza resolved ROL-1716.
-----------------------------
Resolution: Fixed
Fix Version/s: 5.1
OK, changed the line to:
List<TagStat> results = new ArrayList<TagStat>(limit >= 0 ? limit : 25);
Thanks for letting us know.
> a bug found when call getPopularTags with the limit=-1 (v4 m1)
> --------------------------------------------------------------
>
> Key: ROL-1716
> URL: https://issues.apache.org/jira/browse/ROL-1716
> Project: Apache Roller
> Issue Type: Bug
> Affects Versions: 5.0
> Environment: all
> Reporter: guoweizhan
> Assignee: Roller Unassigned
> Fix For: 5.1
>
>
> public List getPopularTags(Weblog website, Date startDate, int offset, int limit)
> throws WebloggerException {
> Query query = null;
> List queryResults = null;
>
> if (website != null) {
> if (startDate != null) {
> Timestamp start = new Timestamp(startDate.getTime());
> query = strategy.getNamedQuery(
> "WeblogEntryTagAggregate.getPopularTagsByWebsite&StartDate");
> query.setParameter(1, website);
> query.setParameter(2, start);
> } else {
> query = strategy.getNamedQuery(
> "WeblogEntryTagAggregate.getPopularTagsByWebsite");
> query.setParameter(1, website);
> }
> } else {
> if (startDate != null) {
> Timestamp start = new Timestamp(startDate.getTime());
> query = strategy.getNamedQuery(
> "WeblogEntryTagAggregate.getPopularTagsByWebsiteNull&StartDate");
> query.setParameter(1, start);
> } else {
> query = strategy.getNamedQuery(
> "WeblogEntryTagAggregate.getPopularTagsByWebsiteNull");
> }
> }
> if (offset != 0) {
> query.setFirstResult(offset);
> }
> if (limit != -1) {
> query.setMaxResults(limit);
> }
> queryResults = query.getResultList();
>
> double min = Integer.MAX_VALUE;
> double max = Integer.MIN_VALUE;
>
> List results = new ArrayList(limit); // if the limit is -1 it will thrown the exception and -1 is for no limit
>
> for (Iterator iter = queryResults.iterator(); iter.hasNext();) {
> Object[] row = (Object[]) iter.next();
> TagStat t = new TagStat();
> t.setName((String) row[0]);
> t.setCount(((Number) row[1]).intValue());
>
> min = Math.min(min, t.getCount());
> max = Math.max(max, t.getCount());
> results.add(t);
> }
>
> min = Math.log(1+min);
> max = Math.log(1+max);
>
> double range = Math.max(.01, max - min) * 1.0001;
>
> for (Iterator iter = results.iterator(); iter.hasNext(); ) {
> TagStat t = (TagStat) iter.next();
> t.setIntensity((int) (1 + Math.floor(5 * (Math.log(1+t.getCount()) - min) / range)));
> }
>
> // sort results by name, because query had to sort by total
> Collections.sort(results, tagStatNameComparator);
>
> return results;
> }
--
This message was sent by Atlassian JIRA
(v6.2#6252)