Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
fix(stats): fix stats with updated api
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Jan 15, 2016
1 parent 9841bf8 commit 5384f2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Expand Up @@ -32,6 +32,9 @@
import org.zanata.rest.dto.stats.contribution.ContributionStatistics;
import org.zanata.rest.dto.stats.contribution.LocaleStatistics;

import java.util.ArrayList;
import java.util.List;

/**
* @author Patrick Huang <a
* href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
Expand All @@ -54,8 +57,7 @@ private ContainerTranslationStatistics generateStatistics(
stats.setId(id);
for (String locale : locales) {
stats.addStats(new TranslationStatistics(new TransUnitCount(
100, 0,
0, 100, 0), locale.trim()));
100, 0, 0, 100, 0), locale.trim()));
}
return stats;
}
Expand All @@ -70,12 +72,19 @@ public ContainerTranslationStatistics getStatistics(String projectSlug,
@Override
public ContributionStatistics getContributionStatistics(String projectSlug,
String versionSlug, String username, String dateRange, boolean includeAutomatedEntry) {

BaseContributionStatistic transStats = new BaseContributionStatistic(100, 90, 100, 0);
BaseContributionStatistic reviewStats = new BaseContributionStatistic(100, 0, 0, 10);

LocaleStatistics localeStatistics =
new LocaleStatistics(new LocaleId("zh"), transStats, reviewStats);

List<LocaleStatistics> localeStatisticsList = new ArrayList<>();
localeStatisticsList.add(localeStatistics);

ContributionStatistics contributionStatistics =
new ContributionStatistics();
LocaleStatistics localeStatistics = new LocaleStatistics();
localeStatistics.put(new LocaleId("zh"), new BaseContributionStatistic(
100, 90, 100, 0));
contributionStatistics.put(username, localeStatistics);
new ContributionStatistics(username, localeStatisticsList);

return contributionStatistics;
}
}
Expand Down
Expand Up @@ -74,7 +74,7 @@ public void testGetContributorStatistics() {
ContributionStatistics statistics =
client.getContributionStatistics("about-fedora", "master",
"pahuang", "2014-10-01..2014-11-10", false);
assertThat(statistics, Matchers.hasKey("pahuang"));
assertThat(statistics.getUsername(), Matchers.equalTo("pahuang"));
}
}

Expand Down

0 comments on commit 5384f2c

Please sign in to comment.