Skip to content

Commit

Permalink
More details while batching logs (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
jzyinq committed Mar 26, 2024
1 parent 75ba78f commit b0749ca
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
- name: Update project version if cmd/version.go exists
shell: bash
run: |
if [ -f "cmd/version.go" ]; then
printf "package cmd\n\nconst projectVersion = \"$(echo $GITHUB_REF | cut -d / -f 3)\"" > cmd/version.go
if [ -f "gojira/version.go" ]; then
printf "package gojira\n\nconst projectVersion = \"$(echo $GITHUB_REF | cut -d / -f 3)\"" > gojira/version.go
fi
- name: Build binary (linux/amd64)
shell: bash
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## [0.5.2] - 2024-03-26
### Changed
- More detailed loader while adding worklogs in a batch

### Fixed
- Version number is now properly synced with the latest release

## [0.5.1] - 2024-03-25
### Fixed
- Summary not updating with worklog changes
Expand Down Expand Up @@ -71,7 +78,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Added
- Initial release of gojira

[Unreleased]: https://github.com/jzyinq/gojira/compare/0.5.1...master
[Unreleased]: https://github.com/jzyinq/gojira/compare/0.5.2...master
[0.5.2]: https://github.com/jzyinq/gojira/compare/0.5.1...0.5.2
[0.5.1]: https://github.com/jzyinq/gojira/compare/0.5.0...0.5.1
[0.5.0]: https://github.com/jzyinq/gojira/compare/0.4.0...0.5.0
[0.4.0]: https://github.com/jzyinq/gojira/compare/0.3.1...0.4.0
Expand Down
23 changes: 9 additions & 14 deletions gojira/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
"time"
)

const GojiraAscii = "" +
" _____ _ _ \n" +
" / ____| (_|_) \n" +
" | | __ ___ _ _ _ __ __ _ \n" +
" | | |_ |/ _ \\| | | '__/ _` |\n" +
" | |__| | (_) | | | | | (_| |\n" +
" \\_____|\\___/| |_|_| \\__,_|\n" +
" _/ | v0.4.0 \n" +
" |__/ \n\n"
var AppAsciiArt = fmt.Sprintf(""+
" _____ _ _ \n"+
" / ____| (_|_) \n"+
" | | __ ___ _ _ _ __ __ _ \n"+
" | | |_ |/ _ \\| | | '__/ _` |\n"+
" | |__| | (_) | | | | | (_| |\n"+
" \\_____|\\___/| |_|_| \\__,_|\n"+
" _/ | v%s \n"+
" |__/ \n\n", projectVersion)

var WorkLogsCommand = &cli.Command{
Name: "worklogs",
Expand Down Expand Up @@ -264,10 +264,5 @@ func (issue Issue) LogWork(logTime *time.Time, timeSpent string) error {
// add this workload to global object
app.workLogs.logs = append(app.workLogs.logs, &worklog)
app.workLogsIssues.issues = append(app.workLogsIssues.issues, WorkLogIssue{Issue: issue, WorkLog: &worklog})
_, err = app.workLogs.LogsOnDate(logTime)
if err != nil {
return err
}
//fmt.Printf("Currently logged time: %s\n", FormatTimeSpent(CalculateTimeSpent(todayWorklog)))
return nil
}
14 changes: 10 additions & 4 deletions gojira/dayview.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ func (d *DayView) loadLatest() {

// DateRange is a struct for holding the start and end dates
type DateRange struct {
StartDate time.Time
EndDate time.Time
StartDate time.Time
EndDate time.Time
NumberOfDays int
}

func ParseDateRange(dateStr string) (DateRange, error) {
Expand Down Expand Up @@ -212,9 +213,13 @@ func ParseDateRange(dateStr string) (DateRange, error) {
endDate = startDate
}

// count number of dayhs between StartDate and EndDate
numberOfDays := int(endDate.Sub(startDate).Hours() / 24)

return DateRange{
StartDate: startDate,
EndDate: endDate,
StartDate: startDate,
EndDate: endDate,
NumberOfDays: numberOfDays,
}, nil
}

Expand All @@ -240,6 +245,7 @@ func NewAddWorklogForm(d *DayView, issues []Issue, row int) *tview.Form {
}
for day := dateRange.StartDate; day.Before(dateRange.EndDate.AddDate(0, 0, 1)); day = day.AddDate(0, 0, 1) {
err := issue.LogWork(&day, timeSpent)
app.ui.loaderView.UpdateText(fmt.Sprintf("Adding worklog for %s ...", day.Format(dateLayout)))
if err != nil {
app.ui.errorView.ShowError(err.Error())
return
Expand Down
2 changes: 1 addition & 1 deletion gojira/gojira.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func Run() {
Calling without arguments will try to detect issue from git branch,
otherwise it will display list of last updated issues you're are assigned to.`,
Version: "0.4.0",
Version: projectVersion,
Before: func(context *cli.Context) error {
if context.Args().First() != "config" {
// dont' check envs on ConfigCommand
Expand Down
10 changes: 8 additions & 2 deletions gojira/loaderview.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ type LoaderView struct {
*LoaderModal
ctx context.Context
cancel context.CancelFunc
text string
}

func NewLoaderView() *LoaderView {
loaderView := &LoaderView{NewModal(), nil, nil}
loaderView := &LoaderView{NewModal(), nil, nil, ""}
loaderView.SetBorder(false)
loaderView.SetBackgroundColor(tview.Styles.PrimitiveBackgroundColor)
app.ui.pages.AddPage("loader", loaderView, true, false)
Expand All @@ -32,6 +33,7 @@ func (e *LoaderView) Wrap(msg string, callable func()) {

func (e *LoaderView) Show(msg string) {
e.ctx, e.cancel = context.WithCancel(context.Background())
e.UpdateText(msg)
app.ui.pages.SendToFront("loader")
go func() {
for {
Expand All @@ -40,7 +42,7 @@ func (e *LoaderView) Show(msg string) {
return
default:
for _, r := range `-\|/` {
e.SetText(fmt.Sprintf("%s%s\n%s", GojiraAscii, msg, string(r)))
e.SetText(fmt.Sprintf("%s%s\n%s", AppAsciiArt, e.text, string(r)))
app.ui.app.Draw()
time.Sleep(100 * time.Millisecond)
}
Expand All @@ -51,6 +53,10 @@ func (e *LoaderView) Show(msg string) {
app.ui.app.Draw()
}

func (e *LoaderView) UpdateText(msg string) {
e.text = msg
}

func (e *LoaderView) Hide() {
if e.cancel != nil {
e.cancel()
Expand Down
3 changes: 3 additions & 0 deletions gojira/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package gojira

const projectVersion = "dev"

0 comments on commit b0749ca

Please sign in to comment.