-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add report and active commands
- Loading branch information
Showing
12 changed files
with
161 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package ui | ||
|
||
import ( | ||
"database/sql" | ||
"fmt" | ||
"io" | ||
"os" | ||
) | ||
|
||
func ShowActiveTask(db *sql.DB, writer io.Writer) { | ||
activeTaskDetails, err := fetchActiveTaskFromDB(db) | ||
|
||
if err != nil { | ||
fmt.Fprintf(os.Stdout, "Something went wrong:\n%s", err) | ||
os.Exit(1) | ||
} | ||
|
||
if activeTaskDetails.taskId == -1 { | ||
return | ||
} | ||
|
||
fmt.Fprintf(writer, "%s", activeTaskDetails.taskSummary) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package ui | ||
|
||
import ( | ||
"database/sql" | ||
"fmt" | ||
"io" | ||
"os" | ||
|
||
"github.com/olekukonko/tablewriter" | ||
) | ||
|
||
func RenderTaskLogReport(db *sql.DB, writer io.Writer) { | ||
taskLogEntries, err := fetchTLEntriesFromDB(db, 20) | ||
if err != nil { | ||
fmt.Fprintf(writer, "Something went wrong generating the report:\n%s", err) | ||
os.Exit(1) | ||
} | ||
|
||
if len(taskLogEntries) == 0 { | ||
return | ||
} | ||
|
||
data := make([][]string, len(taskLogEntries)) | ||
var secsSpent int | ||
var timeSpentStr string | ||
|
||
for i, entry := range taskLogEntries { | ||
secsSpent = int(entry.endTS.Sub(entry.beginTS).Seconds()) | ||
timeSpentStr = humanizeDuration(secsSpent) | ||
data[i] = []string{ | ||
fmt.Sprintf("%d", entry.id), | ||
entry.taskSummary, | ||
entry.beginTS.Format(timeFormat), | ||
timeSpentStr, | ||
} | ||
} | ||
|
||
table := tablewriter.NewWriter(writer) | ||
table.SetHeader([]string{"ID", "Task", "Begin TS", "Time Spent"}) | ||
|
||
table.AppendBulk(data) | ||
table.Render() | ||
} |
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