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

Add Activity page to repository #2674

Merged
merged 11 commits into from Oct 14, 2017
Merged

Conversation

lafriks
Copy link
Member

@lafriks lafriks commented Oct 7, 2017

Adds pulse page to repository to display latest activity from issues and pull requests

Screenshot:
attels

@lafriks lafriks added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Oct 7, 2017
@lafriks lafriks added this to the 1.3.0 milestone Oct 7, 2017
@codecov-io
Copy link

codecov-io commented Oct 7, 2017

Codecov Report

Merging #2674 into master will decrease coverage by 0.25%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2674      +/-   ##
==========================================
- Coverage   27.38%   27.12%   -0.26%     
==========================================
  Files          86       87       +1     
  Lines       17014    17176     +162     
==========================================
  Hits         4659     4659              
- Misses      11675    11837     +162     
  Partials      680      680
Impacted Files Coverage Δ
models/repo.go 13.07% <0%> (-0.1%) ⬇️
models/repo_activity.go 0% <0%> (ø)

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 8863e74...2f44af9. Read the comment docs.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 7, 2017
Copy link
Member

@ethantkoenig ethantkoenig left a comment

Choose a reason for hiding this comment

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

With regard to the screenshots, we should try to fix ungrammatical phrases like "1 pull requests" and "1 people".

Also, would "users" be a better word choice than "people"?

sess := x.Where("pull_request.base_repo_id=?", baseRepoID).
Join("INNER", "issue", "pull_request.issue_id = issue.id")

var mergedCond, createdCond builder.Cond
Copy link
Member

Choose a reason for hiding this comment

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

I believe this can be simplified

var cond builder.Cond
if merged {
	cond = cond.Or(...)
}
if created {
	cond = cond.Or(...)
}
sess.And(cond)

timeFrom = timeTill.Add(-time.Hour * 168)
}
ctx.Data["DateFrom"] = timeFrom.Format("January 2, 2006")
ctx.Data["DateTill"] = timeTill.Format("January 2, 2006")
Copy link
Member

Choose a reason for hiding this comment

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

nit: please use "DateUntil"; it is not substanially longer, and is more explicit


if ctx.Repo.Repository.UnitEnabled(models.UnitTypePullRequests) {
if err := models.FillPullRequestsForPulse(stats, ctx.Repo.Repository.ID, timeFrom); err != nil {
ctx.Error(500, "FillPullRequestsForPulse: "+err.Error())
Copy link
Member

Choose a reason for hiding this comment

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

I believe ctx.Status(500, "Function", err) is preferred, and is used everywhere else

@@ -639,6 +644,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/compare/:before([a-z0-9]{40})\\.\\.\\.:after([a-z0-9]{40})", repo.SetEditorconfigIfExists,
repo.SetDiffViewStyle, repo.MustBeNotBare, context.CheckUnit(models.UnitTypeCode), repo.CompareDiff)
}, ignSignIn, context.RepoAssignment(), context.UnitTypes(), context.LoadRepoUnits())

Copy link
Member

Choose a reason for hiding this comment

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

nit: please remove

@bkcsoft
Copy link
Member

bkcsoft commented Oct 9, 2017

Could we call it "Activity" instead? (I never understood they GitHub called it "Pulse" 😂 )

@lafriks
Copy link
Member Author

lafriks commented Oct 12, 2017

@bkcsoft renamed tab to "Activity"
@ethantkoenig done all your requested code changes

As bonus added published releases info

Updated screenshot:
attels

@lafriks lafriks changed the title Add Pulse page to repository Add Activity page to repository Oct 12, 2017
package repo

import (
//"fmt"
Copy link
Member

Choose a reason for hiding this comment

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

Just remove the comment imports?

m.Group("/activity", func() {
m.Get("", repo.Activity)
m.Get("/:period", repo.Activity)
}, context.RepoRef(), repo.MustBeNotBare, context.CheckUnit(models.UnitTypeCode))
Copy link
Member

Choose a reason for hiding this comment

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

This is a sub feature of unit Code?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking at first it should be code but now I don't know actually... What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I think it should be available to users who have permission to view PR and Issues.

Copy link
Member

Choose a reason for hiding this comment

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

@lafriks I agree with @daviian, if you have Issues or Pull Request you could visit the activity.

@lafriks
Copy link
Member Author

lafriks commented Oct 13, 2017

@lunny cleaned up forgotten imports and changed unit check to only needed ones

@lunny
Copy link
Member

lunny commented Oct 14, 2017

LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 14, 2017

// Published releases authors
sess = releasesForActivityStatement(baseRepoID, fromTime)
if _, err = sess.Select("count(distinct release.publisher_id) as `count`").Table("release").Get(row); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

var count int64
sess.Select().Table().Get(&count)

The current vendored xorm already allowed you do that.

@lunny
Copy link
Member

lunny commented Oct 14, 2017

One more improvement.

if err := models.FillUnresolvedIssuesForActivity(stats, ctx.Repo.Repository.ID, timeFrom,
ctx.Repo.Repository.UnitEnabled(models.UnitTypeIssues),
ctx.Repo.Repository.UnitEnabled(models.UnitTypePullRequests)); err != nil {
ctx.Handle(500, "FillIssuesForActivity", err)
Copy link
Member

Choose a reason for hiding this comment

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

wrong error message

package repo

import (
//"fmt"
Copy link
Member

Choose a reason for hiding this comment

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

Please remove all of these commented-out imports

}

// Special rules for Latvian language
if lang == "lv-LV" {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe outside scope of this PR, but...

I'm not sure having hard-coded language-specific rules in the code is the right approach. I think ideally that language-specific rules should be expressed in that language's locale file, not in code. Two reasons for this:

  1. Many gitea translators are not familiar with the codebase
  2. Even hard-coded rules like this one may not be enough to support all languages. For instance, Arabic has three grammatical numbers (singular, dual, plural), so a function taking key1 and keyN arguments wouldn't work for Arabic, regardless of what hard-coded rules we add.

Of course, encoding language-specific rule in the locale may require a more expressive i18n scheme, but that seems like the more sustainable approach.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ethantkoenig I don't see how such rule could be implemented in locale file. That would require to implement math parser in GoLang so that such rules could be used and this is totally out of scope for this PR

models/repo.go Outdated
@@ -392,6 +392,19 @@ func (repo *Repository) UnitEnabled(tp UnitType) bool {
return false
}

// AnyUnitEnabled if this repository has the any of the given units enabled
func (repo *Repository) AnyUnitEnabled(tps ...UnitType) bool {
repo.getUnits(x)
Copy link
Member

Choose a reason for hiding this comment

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

There is also getUnitsByRepoIDAndIDs (currently unused anywhere)

Copy link
Member Author

Choose a reason for hiding this comment

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

As we already discussed in discord it is better to keep same behaviour as in UnitEnabled

@Morlinest
Copy link
Member

Shouldn't this feature be new Unit?

@lafriks
Copy link
Member Author

lafriks commented Oct 14, 2017

@Morlinest Units are like right units. So they are not same as tabs, so no new unit is not needed for this

@Morlinest
Copy link
Member

@lafriks Right, I was thinking about option to disable/enable it. But there's probably no reason to do that.

models/repo.go Outdated
@@ -392,6 +392,19 @@ func (repo *Repository) UnitEnabled(tp UnitType) bool {
return false
}

// AnyUnitEnabled if this repository has the any of the given units enabled
func (repo *Repository) AnyUnitEnabled(tps ...UnitType) bool {
repo.getUnits(x)
Copy link
Member

Choose a reason for hiding this comment

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

Unchecked error returned by repo.getUnits(x)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm keeping same behaviour as in CheckUnit :) I will see if without much of rewriting there is anything I can do about it

Copy link
Member Author

Choose a reason for hiding this comment

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

@ethantkoenig as this needs to be used in templates so it can not return error so I don't see much I can do here and it is same as it is in UnitEnabled method already

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 at least log it?

@lafriks
Copy link
Member Author

lafriks commented Oct 14, 2017

@ethantkoenig I did rewrite plural text translation method a bit to easier support multiple language exceptions but that is all that can be done currently. My native Latvian language also has 3 forms (singular for numbers ending with 1 except if ending with 11, plural and special case for 0) but without completely changing i18n library that is built into go-macaron framework gitea uses there is no way we can support that...

@ethantkoenig
Copy link
Member

@lafriks Okay, definitely an improvement.

To be clear, I didn't mean that this PR be should blocked on the translation issue, but was just trying to make a general comment about a long-term possibility; sorry if that wasn't clear. And yes, I realize that we would need to update the i18n library to do what I was suggesting.

@lafriks
Copy link
Member Author

lafriks commented Oct 14, 2017

@ethantkoenig added repo unit error logging

@ethantkoenig
Copy link
Member

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 14, 2017
@ethantkoenig
Copy link
Member

ethantkoenig commented Oct 14, 2017

One other thing: could we add a test?

@lafriks lafriks merged commit f42dbdb into go-gitea:master Oct 14, 2017
@lafriks lafriks deleted the feat/pulse branch October 14, 2017 23:17
@lafriks
Copy link
Member Author

lafriks commented Oct 14, 2017

@ethantkoenig I thought about it but only test I can add if page opens without errors as stats are depending on time and preparing data for that would be quite hard

@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants