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

Commit

Permalink
Merge pull request #2 from zanata/rhbz1017997
Browse files Browse the repository at this point in the history
Add recalculate remaining hours after add, increase, decrease in statistic count
  • Loading branch information
seanf committed Oct 11, 2013
2 parents 32bced3 + e7ad80b commit 4f4d3be
Showing 1 changed file with 27 additions and 9 deletions.
Expand Up @@ -91,10 +91,20 @@ public TranslationStatistics(TransUnitWords wordCount, String locale) {
this.unit = StatUnit.WORD;
this.locale = locale;

double untransHours = wordCount.getUntranslated() / 250.0;
double fuzzyHours = wordCount.getNeedReview() / 500.0;
double translatedHours = wordCount.getTranslated() / 500.0;
remainingHours = untransHours + fuzzyHours + translatedHours;
countRemainingHours();
}

/**
* Calculate remaining hours if StatUnit equals to 'WORD'.
*/
private void countRemainingHours() {
if (unit.equals(StatUnit.WORD)) {
double untransHours = translationCount.getUntranslated() / 250.0;
double fuzzyHours = translationCount.getNeedReview() / 500.0;
double translatedHours = translationCount.getTranslated() / 500.0;

remainingHours = untransHours + fuzzyHours + translatedHours;
}
}

/**
Expand Down Expand Up @@ -247,14 +257,16 @@ public void setLastTranslated(String lastTranslated) {
}

@XmlTransient
public @Nullable Date getLastTranslatedDate() {
return lastTranslatedDate != null ?
new Date(lastTranslatedDate.getTime()): null;
public @Nullable
Date getLastTranslatedDate() {
return lastTranslatedDate != null ? new Date(
lastTranslatedDate.getTime()) : null;
}

public void setLastTranslatedDate(@Nullable Date lastTranslatedDate) {
this.lastTranslatedDate = lastTranslatedDate != null ?
new Date(lastTranslatedDate.getTime()): null;
this.lastTranslatedDate =
lastTranslatedDate != null ? new Date(
lastTranslatedDate.getTime()) : null;
}

@XmlTransient
Expand Down Expand Up @@ -300,21 +312,27 @@ public void setRemainingHours(double remainingHours) {
this.remainingHours = remainingHours;
}

// TODO Should consolidate with countRemainingHours() as it might return 0
// or null for StatUnit.MESSAGE
@XmlTransient
@Deprecated
public double getRemainingHours() {
return remainingHours;
}

public void add(TranslationStatistics other) {
translationCount.add(other.translationCount);
countRemainingHours();
}

public void increment(ContentState state, long count) {
translationCount.increment(state, (int) count);
countRemainingHours();
}

public void decrement(ContentState state, long count) {
translationCount.decrement(state, (int) count);
countRemainingHours();
}

@Override
Expand Down

0 comments on commit 4f4d3be

Please sign in to comment.