-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce instance start date in api and billing (#3204)
* Introduce instance start date in database * Use instance start date in api * Use instance start date in billing * Repair tests * Resolve checkstyle and pmd issues * Move instance start date to run entity
- Loading branch information
Showing
26 changed files
with
593 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
api/src/main/java/com/epam/pipeline/utils/RunDurationUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.epam.pipeline.utils; | ||
|
||
import com.epam.pipeline.entity.pipeline.PipelineRun; | ||
import com.epam.pipeline.entity.utils.DateUtils; | ||
|
||
import java.time.Duration; | ||
import java.util.Date; | ||
import java.util.Optional; | ||
|
||
public final class RunDurationUtils { | ||
|
||
private RunDurationUtils() { | ||
} | ||
|
||
public static Duration getOverallDuration(final PipelineRun run) { | ||
return durationBetween(run.getStartDate(), run.getEndDate()); | ||
} | ||
|
||
public static Duration getBillableDuration(final PipelineRun run) { | ||
return durationBetween(run.getInstanceStartDate(), run.getEndDate()); | ||
} | ||
|
||
private static Duration durationBetween(final Date from, final Date to) { | ||
final Date end = Optional.ofNullable(to).orElseGet(DateUtils::now); | ||
final Date start = Optional.ofNullable(from).orElse(end); | ||
return Duration.ofMillis(end.getTime() - start.getTime()).abs(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.