Skip to content

Commit

Permalink
added seconds to detailed report
Browse files Browse the repository at this point in the history
  • Loading branch information
angerpac committed Jun 6, 2024
1 parent 6f6baa9 commit 3dd9ccc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Binary file modified Wellness_Tracker.db
Binary file not shown.
20 changes: 16 additions & 4 deletions src/main/java/dao/ReportDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,20 @@ public ObservableList<ReportsController.Activity> getDailyReportDetail() {
ObservableList<ReportsController.Activity> data = FXCollections.observableArrayList();
String query = "SELECT " +
"Application, " +
"SUM((EndTime / 1000 - StartTime / 1000) / 3600) || ' hours ' || SUM(((EndTime / 1000 - StartTime / 1000) % 3600) / 60) || ' minutes' AS TimeSpent " +
"printf('%d hours %d minutes %d seconds', " +
"total_seconds / 3600, " +
"(total_seconds % 3600) / 60, " +
"total_seconds % 60) AS TimeSpent " +
"FROM " +
"(SELECT Application, " +
"SUM((EndTime / 1000) - (StartTime / 1000)) AS total_seconds " +
"FROM " +
"Usage " +
"WHERE " +
"UserId = ? " +
"AND DATE(StartTime / 1000, 'unixepoch') = DATE('now') " +
"GROUP BY " +
"Application";
"Application)";
try (PreparedStatement statement = connection.prepareStatement(query)) {
statement.setInt(1, AppUser.getUserId());
ResultSet resultSet = statement.executeQuery();
Expand Down Expand Up @@ -139,14 +145,20 @@ public ObservableList<ReportsController.Activity> getWeeklyReportDetail() {
ObservableList<ReportsController.Activity> data = FXCollections.observableArrayList();
String query = "SELECT " +
"Application, " +
"SUM((EndTime / 1000 - StartTime / 1000) / 3600) || ' hours ' || SUM(((EndTime / 1000 - StartTime / 1000) % 3600) / 60) || ' minutes' AS TimeSpent " +
"printf('%d hours %d minutes %d seconds', " +
"total_seconds / 3600, " +
"(total_seconds % 3600) / 60, " +
"total_seconds % 60) AS TimeSpent " +
"FROM " +
"(SELECT Application, " +
"SUM((EndTime / 1000) - (StartTime / 1000)) AS total_seconds " +
"FROM " +
"Usage " +
"WHERE " +
"UserId = ? " +
"AND DATE(StartTime / 1000, 'unixepoch') BETWEEN DATE('now', '-7 days') AND DATE('now') " +
"GROUP BY " +
"Application";
"Application)";

try (PreparedStatement statement = connection.prepareStatement(query)) {
statement.setInt(1, AppUser.getUserId());
Expand Down

0 comments on commit 3dd9ccc

Please sign in to comment.