Skip to content

Conversation

KonstantinGasser
Copy link
Contributor

@KonstantinGasser KonstantinGasser commented May 31, 2021

This is a first proposal for the report command.
Supported flags:

  • --billable
  • --project
  • --start / --end
  • --format (json/csv) csv is not yet implemented...
  • --out

The command is designed the way it is discussed in #88.

In the cli/report.go I commented TODOs. Here I would be happy to get some input as I don't like the way I have implemented the checks if a Flags.StringVarP has its default value...

@KonstantinGasser
Copy link
Contributor Author

@dominikbraun while using the report feature my self I found a bug causing a panic if --start or --end where given.. I have fixed that bug and appended it to this PR. I also fixed another bug where the --end time would not be inclusive.

@dominikbraun
Copy link
Owner

Thanks! Is this ready to review already?

@KonstantinGasser
Copy link
Contributor Author

Yes it is ready to be reviewed - all of the above mentioned flags are supported (only serialisation to csv is not implemented yet)

@dominikbraun dominikbraun self-requested a review June 2, 2021 07:37
@KonstantinGasser
Copy link
Contributor Author

@dominikbraun I noticed a merge conflict for this PR after the latest release - I fixed that one PR is ok again.

Copy link
Owner

@dominikbraun dominikbraun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good so far, I'm going to test it locally today.

cli/report.go Outdated
Comment on lines 18 to 19
fromTime string
toTime string
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as we're supporting dates only, I'd probably name this startDate and endDate.

cli/report.go Outdated
var fromDate, toDate time.Time
var formatErr error

// TODO: find better way to check if flag is default
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use "" as a default here.

cli/report.go Outdated
Comment on lines 56 to 57
core.FilterNoneNilEndTime,
core.FilterByTimeRange(fromDate, toDate),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea 👍

cli/report.go Outdated
Comment on lines 27 to 28
Short: "Report allows to view or output tracked records as defined report",
Run: func(cmd *cobra.Command, args []string) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to include the report feature in one of the next timetrace releases, but in a sort of beta phase, and officially publish it in its very own release.

Suggested change
Short: "Report allows to view or output tracked records as defined report",
Run: func(cmd *cobra.Command, args []string) {
Short: "Report allows to view or output tracked records as defined report",
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {

core/record.go Outdated
Comment on lines 313 to 324
// apply all filter on record to check if Records should be used
var useRecord = true
for _, f := range filter {
if !f(record) {
useRecord = false
break
}
}
// check if eighter filter negates useRecord
if !useRecord {
continue
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could label the outer loop with outer: and just run

if !f(record) {
    continue outer
}

This way, we could get rid of the useRecord variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why there are Reviews! :D Didn't thought of that - I will implement that.

@KonstantinGasser
Copy link
Contributor Author

@dominikbraun I have Uni until 6pm I will implement your changes afterwards and update the PR 👍

Comment on lines 53 to 58
year := input.Local().Year()
day := input.Local().Day()
weekday := input.Local().Weekday()
month := input.Local().Month()

return fmt.Sprintf("%v %d. %v %d", weekday, day, month, year)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace this with

Suggested change
year := input.Local().Year()
day := input.Local().Day()
weekday := input.Local().Weekday()
month := input.Local().Month()
return fmt.Sprintf("%v %d. %v %d", weekday, day, month, year)
return input.Format("Monday, 02. January 2006")

@KonstantinGasser
Copy link
Contributor Author

I have incorporated your suggestions and updated the PR

Copy link
Owner

@dominikbraun dominikbraun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank alot for implementing this feature!

It will be included in one of the next releases and officially published in its very own release.

@KonstantinGasser
Copy link
Contributor Author

Cool, great to hear!

@dominikbraun dominikbraun added this to the timetrace v0.11.0 milestone Jun 13, 2021
@dominikbraun dominikbraun self-requested a review June 14, 2021 18:18
Copy link
Owner

@dominikbraun dominikbraun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be merged and included in timetrace v0.11.0 as an hidden feature.

@dominikbraun dominikbraun merged commit 75b19bd into dominikbraun:main Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants