The Wayback Machine - https://web.archive.org/web/20220507124219/https://github.com/go-gitea/gitea/pull/16870
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

implemented add custom date to spent time #16870

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Copy link

@vsysoev vsysoev commented Aug 29, 2021

Implemented issue #16841

@@ -804,8 +804,9 @@ func (f *DeleteRepoFileForm) Validate(req *http.Request, errs binding.Errors) bi

// AddTimeManuallyForm form that adds spent time manually.
type AddTimeManuallyForm struct {
Hours int `binding:"Range(0,1000)"`
Minutes int `binding:"Range(0,1000)"`
Created string `form:"created" binding:"OmitEmpty;Size(10)"`
Copy link
Contributor

@delvh delvh Aug 29, 2021

Choose a reason for hiding this comment

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

That will fail after the year 9999 😉

<div class="header">{{.i18n.Tr "repo.issues.add_time"}}</div>
<div class="content">
<form method="POST" id="add_time_manual_form" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/times/add" class="ui action input fluid">
{{$.CsrfTokenHtml}}
<input type="date" name="created">
Copy link
Contributor

@delvh delvh Aug 29, 2021

Choose a reason for hiding this comment

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

I think it would be a good idea to add pattern="\d{4,}-\d{2}-\d{2}" according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#handling_browser_support. Otherwise, a correct date could be added in an incorrect format that would then subsequently be reset to today.

Additionally, we could even think about using a maximum value of "today" or "tomorrow", as future times should in my opinion not be possible to be added. (Maybe except for timezones, hence why I would argue to leave "tomorrow" as a valid option). The problem with that is that the HTML standard does not support "today" or "tomorrow" as values and hence these values would need to be inserted on the server-side.
Thoughts on the maximum value?

Copy link
Author

@vsysoev vsysoev Aug 30, 2021

Choose a reason for hiding this comment

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

Regrading your proposal to add pattern="...". I am not sure that is necessary to do. I look through Yandex Browser, Firefox, Google Chrome, Opera, Safari. Default behaviour of browsers while adding input type=date looks reasonable. I can't add incorrect date and can't add extra range values.

Yandex Browser
Screenshot 2021-08-30 at 17 11 44

Firefox
Screenshot 2021-08-30 at 17 11 59

Google Chrome
Screenshot 2021-08-30 at 17 12 37

Opera
Screenshot 2021-08-30 at 17 13 18

Safari
Screenshot 2021-08-30 at 17 13 51

Second part of your review to use maximum value "today" or "tomorrow" is a good proposal. I try to find how to implement it and add it to this PR.

@@ -20,7 +20,7 @@ type TrackedTime struct {
UserID int64 `xorm:"INDEX"`
User *User `xorm:"-"`
Created time.Time `xorm:"-"`
CreatedUnix int64 `xorm:"created"`
CreatedUnix int64 `xorm:"created_unix"`
Copy link
Member

@6543 6543 Aug 29, 2021

Choose a reason for hiding this comment

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

why do you rename the table column in db there is no need to do so
PS: migrations would be missing too - but just drop that change

Copy link
Author

@vsysoev vsysoev Aug 30, 2021

Choose a reason for hiding this comment

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

I am not. Looks like this is an error in xorm.

This is what i have in sqlite db.
sqlite> .dump tracked_time
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE tracked_time (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, issue_id INTEGER NULL, user_id INTEGER NULL, created_unix INTEGER NULL, time INTEGER NOT NULL, deleted INTEGER DEFAULT 0 NOT NULL);

Copy link
Member

@6543 6543 Aug 30, 2021

Choose a reason for hiding this comment

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

need to look closer ... cc @lunny

Copy link
Contributor

@wxiaoguang wxiaoguang May 2, 2022

Choose a reason for hiding this comment

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

The created here is a XORM keyword, not a column name. The keyword shouldn't be changed.

So the column name is CreatedUnix => created_unix (implicitly), it was correct already.

@6543
Copy link

@6543 6543 commented Aug 29, 2021

there are two option to handle it in the backend: either allow the user to optional specify arbitrary creation timestamps to be inserted into db (not fan of it) or to add a new column who would be either NULL or specify when the spent time should be "proposed" to be happened

@vsysoev
Copy link
Author

@vsysoev vsysoev commented Aug 30, 2021

there are two option to handle it in the backend: either allow the user to optional specify arbitrary creation timestamps to be inserted into db (not fan of it) or to add a new column who would be either NULL or specify when the spent time should be "proposed" to be happened

Thank you for your review and proposals.
I have several opens to share:

  1. I suppose that tracked_time is for time which has been spent already. Not for estimation. For accounting purpose. Estimation is for planning future work. So estimation should be added for planning and balancing spendings.
  2. There is "created_unix" field In the tracked_time table. I try to find any reference to this field in code or documentation and think this field isn't used anywhere. So I utilise this field. Don't think adding another field with date is necessary.

Any thoughts regarding this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

5 participants