-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Added progressbar for issues (#1146). #3171
Changes from 7 commits
904ee41
d9f4e82
4ca3005
5d78b7f
c220a27
265636c
7ce012b
74adf36
890349e
2fdeeb5
7088869
3b7a161
ae0d1df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ package models | |
import ( | ||
"fmt" | ||
"path" | ||
"regexp" | ||
"sort" | ||
"strings" | ||
|
||
|
@@ -31,9 +32,11 @@ type Issue struct { | |
Title string `xorm:"name"` | ||
Content string `xorm:"TEXT"` | ||
RenderedContent string `xorm:"-"` | ||
Labels []*Label `xorm:"-"` | ||
MilestoneID int64 `xorm:"INDEX"` | ||
Milestone *Milestone `xorm:"-"` | ||
Tasks int | ||
Tasksdone int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Labels []*Label `xorm:"-"` | ||
MilestoneID int64 `xorm:"INDEX"` | ||
Milestone *Milestone `xorm:"-"` | ||
Priority int | ||
AssigneeID int64 `xorm:"INDEX"` | ||
Assignee *User `xorm:"-"` | ||
|
@@ -740,7 +743,16 @@ func AddDeletePRBranchComment(doer *User, repo *Repository, issueID int64, branc | |
func (issue *Issue) ChangeContent(doer *User, content string) (err error) { | ||
oldContent := issue.Content | ||
issue.Content = content | ||
if err = UpdateIssueCols(issue, "content"); err != nil { | ||
|
||
regExpTasks := regexp.MustCompile(`(^\s*-\s\[[\sx]\]\s)|(\n\s*-\s\[[\sx]\]\s)`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is duplicated code, please consider refactoring. Also, it would be nice if we didn't have to compile the regexp every time. |
||
tasksMatches := regExpTasks.FindAllStringIndex(content, -1) | ||
issue.Tasks = len(tasksMatches) | ||
|
||
regExpTasksdone := regexp.MustCompile(`(^\s*-\s\[[x]\]\s)|(\n\s*-\s\[[x]\]\s)`) | ||
tasksdoneMatches := regExpTasksdone.FindAllStringIndex(content, -1) | ||
issue.Tasksdone = len(tasksdoneMatches) | ||
|
||
if err = UpdateIssueCols(issue, "content", "tasks", "tasksdone"); err != nil { | ||
return fmt.Errorf("UpdateIssueCols: %v", err) | ||
} | ||
|
||
|
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're adding new columns to the
issue
table, then we need a migration.However, I think the case could be made that we shouldn't store tasks/tasksDone in the database, but instead just calculate them from the
Content
field.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about leaving the parsing to the clients? Then we would not have to store anything on the server, and the only files being changed would be the template files (and the css rules). Since it is just a cosmetic addition, the clients could determine the progress themselves upon viewing the issue list - but the server has to provide the content for the clients to parse (additional network load).
I would realize this as a javascript function in the issue list and in the user dashboard issue list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ethantkoenig I don't think so. If the page has 10 issues. We have to parse all the 10 issues' markdowns on the browser one time. And also we need add a javascript markdown library. I don't think this is a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lunny We don't need to render the issue content as markdown, we just need to look at the raw string (which we load from the DB anyway). The regexps in this PR would not work if the issue contents were rendered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ethantkoenig and another thing, we didn't transfer issue content to client on issue list. If you want client to parse that. We have to transfer the contents. This will also reduce the load speed of the page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not suggesting we send the issues' content to the client. That was @modmew8's comment.
I am proposing that we calculate the number of tasks server-side; this can be computed easily with regexps, and does not require rendering the contents as markdown. If our regexps are pre-compiled, I don't think this will be very expensive, since (as I mentioned above) we already load the contents from the DB.
I am hesitant to add new columns to the
issue
table because I'm afraid that if we will add new columns for every new feature, our schemas will eventually become very complicated and confusing.