Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement adding notes to timespans in the backend #81

Merged
merged 2 commits into from
Jan 30, 2021

Conversation

simhnna
Copy link
Contributor

@simhnna simhnna commented Nov 28, 2020

This implements the backend part of #74

Should I just try updating the frontend as well, or do you have something specific in mind?

@codecov
Copy link

codecov bot commented Nov 28, 2020

Codecov Report

Merging #81 (46c798c) into master (2f1a4d6) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
+ Coverage   92.08%   92.09%   +0.01%     
==========================================
  Files          70       70              
  Lines        1326     1328       +2     
==========================================
+ Hits         1221     1223       +2     
  Misses         71       71              
  Partials       34       34              
Impacted Files Coverage Δ
timespan/convert.go 100.00% <100.00%> (ø)
timespan/copy.go 100.00% <100.00%> (ø)
timespan/create.go 100.00% <100.00%> (ø)
timespan/update.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f1a4d6...46c798c. Read the comment docs.

@simhnna
Copy link
Contributor Author

simhnna commented Nov 28, 2020

Is there a reason why updates are done by deleting and recreating the timespan?
I would have expected that only what's included in the update operation is stored and everything else is left untouched

Copy link
Member

@jmattheis jmattheis left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

Remarks in subcomments.

@@ -12,6 +12,7 @@ type TimeSpan struct {
OffsetUTC int
UserID int `gorm:"type:int REFERENCES users(id) ON DELETE CASCADE"`
Tags []TimeSpanTag
Notes *string
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this not nullable? In the UI we don't need to differentiate between nil and empty string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also not nullable in the graphql types?

Copy link
Member

Choose a reason for hiding this comment

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

Yes.

timespan/copy.go Outdated
@@ -17,5 +17,5 @@ func (r *ResolverForTimeSpan) CopyTimeSpan(ctx context.Context, id int, start mo
return nil, fmt.Errorf("time span with id %d does not exist", id)
}

return r.CreateTimeSpan(ctx, start, end, tagsToInputTag(old.Tags))
return r.CreateTimeSpan(ctx, start, end, tagsToInputTag(old.Tags), nil)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure, but shouldn't this copy the note as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess you can make an argument for both options. I added it

@@ -12,6 +12,7 @@ type TimeSpan struct {
OffsetUTC int
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, feel free to do the UI part as well. I'd say the UI could look like this, the notes should be defined as Markdown and then are rendered like this inside the ui.
image

Copy link
Member

Choose a reason for hiding this comment

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

The note can then be edited by clicking it.

Copy link
Member

Choose a reason for hiding this comment

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

Do you want to include this in the current pr or another?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll see if I can come up with something. Currently this PR breaks the client due to the required notes input field

@simhnna
Copy link
Contributor Author

simhnna commented Nov 29, 2020

I've added a basic implementation. I'm a complete react noob. This is the first time I've done any react whatsoever...
I hope I got it right.
I've observed that a lot of mutations are made when using the time picker for instance. I've added a debounce to updating the notes. You might want to merge all these update methods and add a central debounce there.

There's one issue with the current debounce. If the user changes some other value during that period, the change is overwritten when the debounce completes. I'm not sure if you can live with that, or you want to change it, but updating the notes on each keystroke doesn't sound right...

@jmattheis
Copy link
Member

Alright, I'll hopefully have a look at this on the weekend.

@jmattheis
Copy link
Member

@simhnna This looks good so far, as I'm currently a little busy I'll postpone this another 2 weeks then I'm on vacation and have a little more free time.

@muety
Copy link

muety commented Jan 9, 2021

Any news here? I'm excited for this feature to come :)

@jmattheis
Copy link
Member

@muety nearly done I guess.
@simhnna Could you recheck if it still works? I've moved the hide/show button to the left, and hopefully fixed the race condition.

@muety
Copy link

muety commented Jan 28, 2021

@simhnna Would you mind taking a quick look? This missing feature is essentially the only thing that hinders me from switching from Toggl to Traggo :)

@jmattheis
Copy link
Member

I'll probably merge it tomorrow or on Saturday when I find some time to test and create a release.

@jmattheis jmattheis merged commit e90db23 into traggo:master Jan 30, 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.

None yet

3 participants