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 contributors graph #27882

Merged
merged 190 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 157 commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
9fd24bc
Create new page
sahinakkaya Jun 16, 2023
3975abd
Implement simple api
sahinakkaya Jun 18, 2023
19deef6
Implement basic graph render
sahinakkaya Jun 19, 2023
715fc15
Handle dates by grouping them into weeks
sahinakkaya Jun 19, 2023
136d8be
Split vue file into meaningful pieces
sahinakkaya Jun 19, 2023
be50ead
Remove non-needed code
sahinakkaya Jun 19, 2023
3211417
Implement contributors graph
sahinakkaya Jun 20, 2023
88247fd
Switch to unix timestamp
sahinakkaya Jun 20, 2023
a393093
Show contributor rank
sahinakkaya Jun 20, 2023
e8e0e34
Multiply x with 1000 to make it milliseconds
sahinakkaya Jun 20, 2023
ff17e01
Remove legend, format numbers
sahinakkaya Jun 20, 2023
664747a
Implement contribution type selection
sahinakkaya Jun 20, 2023
2c567ea
Draw charts basaed on selected contribution type
sahinakkaya Jun 20, 2023
8ef0c35
Show all sundays until today instead of latest commit
sahinakkaya Jun 20, 2023
bc396c0
Show date range in title
sahinakkaya Jun 20, 2023
630c2dd
Add zoom/pan support to charts
sahinakkaya Jun 21, 2023
d293f24
Sync charts on zoom/pan events
sahinakkaya Jun 21, 2023
2304a5d
Format everything with gofmt
sahinakkaya Jun 21, 2023
a047e07
Disable animations for performance
sahinakkaya Jun 21, 2023
34f9d92
Reset zoom when clicking on chart
sahinakkaya Jun 21, 2023
f210a51
Disable grid for x axis
sahinakkaya Jun 22, 2023
9af88ec
Refactor
sahinakkaya Jun 22, 2023
4399890
Remove unused api endpoint
sahinakkaya Jun 22, 2023
e94b9c7
Merge branch 'main' into main
sahinakkaya Jun 22, 2023
a4b6666
Use a better name for variable
sahinakkaya Jun 22, 2023
c75b7a5
Implement new endpoint for fetching contributors data
sahinakkaya Jun 22, 2023
e29efb2
Use new endpoint for fetching contributors data
sahinakkaya Jun 22, 2023
b516a67
Introduce a new endpoint for fetching data in frontend
sahinakkaya Jun 22, 2023
4ee972c
Apply suggestions from code review
sahinakkaya Jun 23, 2023
90e3d50
Do not use hard-coded colors
sahinakkaya Jun 23, 2023
0dfd908
Make object key snake_case
sahinakkaya Jun 24, 2023
2c174d6
Add copyright header
sahinakkaya Jun 24, 2023
730368e
Fix linting errors
sahinakkaya Jun 24, 2023
32fe51e
Use actual commit ID instead of empty string
sahinakkaya Jun 24, 2023
5e16adf
Merge branch 'main' into main
6543 Jun 24, 2023
0dd9095
Generate swagger
sahinakkaya Jun 24, 2023
ffab20b
Merge branch 'main' into main
sahinakkaya Jun 24, 2023
3196641
Lower height of graph
sahinakkaya Jun 24, 2023
5e66e27
Merge branch 'main' into main
sahinakkaya Jun 25, 2023
a886f57
Remove translation to other languages
sahinakkaya Jun 26, 2023
f278598
Add newline at end of swagger file
sahinakkaya Jun 26, 2023
beb7382
Move header from Go template to Vue
sahinakkaya Jun 26, 2023
e169731
Merge branch 'main' into main
sahinakkaya Jun 26, 2023
4c5170b
Merge branch 'main' into main
sahinakkaya Jun 28, 2023
8dce947
Fix package-lock.json
sahinakkaya Jun 28, 2023
4f74932
Adjust the location of the contributors page
hiifong Jun 28, 2023
677ac20
Merge branch 'go-gitea:main' into contributors
hiifong Jun 28, 2023
1cbeabf
fix lint
hiifong Jun 28, 2023
e047458
make generate-swagger
hiifong Jun 28, 2023
49eaf6d
fix typo
hiifong Jun 28, 2023
3dcbba3
Merge pull request #1 from hiifong/contributors
sahinakkaya Jun 28, 2023
a8d2a9c
Merge branch 'main' into main
sahinakkaya Jun 30, 2023
3e156ab
Cherry-pick 64f2d7026 and resolve conflicts
silverwind Jun 29, 2023
7947bf9
Try updating date range when zoom or pan occurs
sahinakkaya Jun 30, 2023
3d62edc
Use v-memo to avoid unnecessary re-render
sahinakkaya Jun 30, 2023
e27ea6c
Merge branch 'update-date'
sahinakkaya Jun 30, 2023
e5537cc
Preparation step for sorting contributor graphs
sahinakkaya Jun 30, 2023
7a69f2e
Update contributor graphs based on selected date range
sahinakkaya Jun 30, 2023
5d2b764
Calculate total stats while looping to avoid unnecessary computation …
sahinakkaya Jun 30, 2023
d0714e7
Sort contributors based on selected contribution type
sahinakkaya Jun 30, 2023
b273ba7
Do not show contributor graph if total contribution is 0 on selected …
sahinakkaya Jun 30, 2023
1e163bb
Set highest value for contributor graphs dynamically
sahinakkaya Jun 30, 2023
e4ccffd
Fix a bug while parsing the commits
sahinakkaya Jun 30, 2023
1ba2157
Merge branch 'main' into main
sahinakkaya Jun 30, 2023
6ffe1f1
Fix linting errors
sahinakkaya Jun 30, 2023
43bf7ec
Merge branch 'main' into main
sahinakkaya Jul 1, 2023
497ce76
Fix linting errors
sahinakkaya Jul 1, 2023
145d3ca
Fix linting errors
sahinakkaya Jul 1, 2023
d550ba7
Merge branch 'main' into main
sahinakkaya Jul 2, 2023
991e3c0
Show loading animation while fetching data
sahinakkaya Jul 6, 2023
8ba3674
Eliminate unnecessary fetch when contribution type changes
sahinakkaya Jul 6, 2023
b148d1a
Reset all charts when main chart is clicked
sahinakkaya Jul 6, 2023
5de9fbf
Handle errors which can occure while fetching data
sahinakkaya Jul 6, 2023
79dfb84
Apply suggestions from code review
sahinakkaya Jul 7, 2023
ec30e3b
Apply suggestions from code review
sahinakkaya Jul 7, 2023
51f8118
Use translated strings
sahinakkaya Jul 9, 2023
7e68c7c
Do code splitting on contributors page
sahinakkaya Jul 9, 2023
056745b
Use author information instead of committer
sahinakkaya Jul 9, 2023
d6887e4
Move contributor related code under service
sahinakkaya Jul 9, 2023
8ed40fe
Apply suggestions from code review
sahinakkaya Jul 14, 2023
3fc79af
Apply suggestions from code review
sahinakkaya Jul 14, 2023
d51417d
Merge branch 'main' into main
6543 Jul 14, 2023
75b92e3
Merge remote-tracking branch 'upstream/main' into main
sahinakkaya Oct 17, 2023
09d249d
Apply suggestions from code review
sahinakkaya Oct 17, 2023
023bbbb
Use GET instead of fetch
sahinakkaya Oct 17, 2023
e83b562
Re-order tags to script - template - style in vue file
sahinakkaya Oct 17, 2023
f2d3394
Remove useless error checking
sahinakkaya Oct 18, 2023
ca59188
Merge branch 'main' into main
6543 Oct 20, 2023
7f1f49f
Merge remote-tracking branch 'upstream/main'
sahinakkaya Oct 26, 2023
e953057
Merge remote-tracking branch 'upstream/main'
sahinakkaya Oct 30, 2023
88ffba5
Apply suggestions from code review
sahinakkaya Oct 31, 2023
12cc6d6
Merge remote-tracking branch 'upstream/main'
sahinakkaya Oct 31, 2023
ce1306b
Merge branch 'main' into main
6543 Nov 1, 2023
80e6614
Fix linting errors
sahinakkaya Nov 1, 2023
8d07fdd
Merge branch 'main' into main
6543 Nov 1, 2023
248065f
dayjs
6543 Nov 1, 2023
ba4e738
generate
6543 Nov 1, 2023
b6b4881
fmt
6543 Nov 2, 2023
9e50232
Merge branch 'main' into sahinakkaya/main
6543 Nov 2, 2023
2bf4ce0
Fix locale usage
sahinakkaya Nov 2, 2023
0d08f06
layout fixes
silverwind Nov 2, 2023
f47560c
Merge branch 'main' into contributors-graph
silverwind Nov 5, 2023
325fc9b
Combine email addresses linked to same gitea user together
sahinakkaya Nov 6, 2023
4135808
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Nov 7, 2023
2b2d0ef
reduce main graph to 280px height
silverwind Nov 7, 2023
36d8e81
color and chart rendering enhancements
silverwind Nov 7, 2023
4d2905b
make fmt
silverwind Nov 7, 2023
a151d51
js formatting
silverwind Nov 7, 2023
6ebc6ce
Use constant from time package instead of manually defining it
sahinakkaya Nov 8, 2023
86e0204
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Nov 8, 2023
b50929b
Remove useless data from page context
sahinakkaya Nov 8, 2023
043f2a2
Update templates/repo/navbar.tmpl
silverwind Nov 9, 2023
dd2664d
Update templates/repo/navbar.tmpl
silverwind Nov 9, 2023
1c9b0f5
Apply suggestions from code review
sahinakkaya Nov 9, 2023
efd6ace
Merge branch 'main' into contributors-graph
6543 Nov 10, 2023
ebf5af2
Backend Asnyc
6543 Nov 10, 2023
6dc6438
Merge branch 'main' into contributors-graph
6543 Nov 10, 2023
8c35b11
use status 216
6543 Nov 11, 2023
de1b537
Handle http 216 on client side
sahinakkaya Nov 11, 2023
bf35e58
Merge branch 'main' into contributors-graph
6543 Nov 13, 2023
cc4f996
body
6543 Nov 13, 2023
1660802
fix
6543 Nov 13, 2023
af7463a
Merge branch 'main' into contributors-graph
6543 Nov 13, 2023
ed1506e
Fix frontend
sahinakkaya Nov 13, 2023
6b1593f
Fix a small error
sahinakkaya Nov 13, 2023
f31d0a3
Fix frontend
sahinakkaya Nov 13, 2023
112897d
Use status 202
sahinakkaya Nov 13, 2023
130f3f4
Fix linting errors
sahinakkaya Nov 13, 2023
2c2d376
sync x axis in all graph
yp05327 Nov 16, 2023
3777a9e
fix lint
yp05327 Nov 16, 2023
f3bf5a4
display the whole graph
yp05327 Nov 16, 2023
f0ef0f3
improve avatar
yp05327 Nov 16, 2023
8552c9e
convert click into double click
yp05327 Nov 16, 2023
1f3b9f8
Apply suggestions from code review
sahinakkaya Nov 16, 2023
ade291c
Merge pull request #3 from yp05327/pr27882
sahinakkaya Nov 16, 2023
dec493b
Fix max chart value
sahinakkaya Nov 19, 2023
34be281
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Nov 19, 2023
2665147
Use drag to zoom
sahinakkaya Nov 19, 2023
bc04a82
Add instructions on how to zoom pan etc.
sahinakkaya Nov 19, 2023
8de2f7d
Fix title
sahinakkaya Nov 19, 2023
cbd51b3
Merge branch 'main' into contributors-graph
silverwind Nov 20, 2023
44311a0
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Nov 21, 2023
e43e6b9
generate swagger
sahinakkaya Nov 21, 2023
20b6bb7
fmt
sahinakkaya Nov 21, 2023
fab3f83
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Nov 24, 2023
07794ca
Merge branch 'main' into contributors-graph
6543 Dec 2, 2023
4834f97
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Dec 12, 2023
d0bca3f
Merge branch 'main' into contributors-graph
6543 Dec 21, 2023
51ea778
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Jan 8, 2024
31f459e
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Jan 22, 2024
c860b02
Fix linting error in swagger file
sahinakkaya Jan 23, 2024
e8a5c57
Target correct dropdown
sahinakkaya Jan 24, 2024
51a9e8d
Move ExtendedCommitStats to service layer
sahinakkaya Jan 24, 2024
7a134de
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Jan 25, 2024
3740877
Remove exposed endpoint as it is not needed by this PR
sahinakkaya Jan 25, 2024
ae47624
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Jan 25, 2024
0f61e59
Move types out from "modules/structs" to not pollute api
sahinakkaya Jan 25, 2024
07eb1d1
Apply suggestions from code review
sahinakkaya Jan 26, 2024
e52db02
Do not render 'a' tag if user is not present on the server
sahinakkaya Jan 26, 2024
cd23a86
Fix linting error
sahinakkaya Jan 26, 2024
7c91b21
Merge branch 'main' into contributors-graph
silverwind Jan 27, 2024
3216a74
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Feb 1, 2024
9b337dc
Adopt changes in upstream
sahinakkaya Feb 1, 2024
63cf7f2
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Feb 1, 2024
48f175c
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Feb 4, 2024
ae97fbd
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Feb 4, 2024
6094559
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Feb 7, 2024
93987ca
Merge branch 'main' into contributors-graph
6543 Feb 10, 2024
6e87cd8
unexport internal used func
6543 Feb 10, 2024
09a9c62
fix nil pointer issue found by test
6543 Feb 10, 2024
e968a8f
unexport another internal used func
6543 Feb 10, 2024
93f9b2b
add test and expected outcome + add some codecoments to be solved
6543 Feb 10, 2024
2b06e09
expand test with total "summary user"
6543 Feb 10, 2024
3ba73e3
Fix linting error
sahinakkaya Feb 11, 2024
1d0eca1
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Feb 11, 2024
ecb412b
Fix implementation to satisfy unit test
sahinakkaya Feb 13, 2024
88c57f9
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Feb 13, 2024
344ed41
Fix linting error
sahinakkaya Feb 13, 2024
09d5d27
fix lint error and use dayjs to get sundays
silverwind Feb 14, 2024
c05d215
refactor property access, remove empty line
silverwind Feb 14, 2024
1c203d1
fix eslint parser error
silverwind Feb 14, 2024
9fb946b
rename 'sundays' to 'startDays' in js, add trailing commas
silverwind Feb 14, 2024
5e51092
Add raw hours to generate timestamps correctly
sahinakkaya Feb 15, 2024
0c53d38
Use current time as end date instead of last commit's time
sahinakkaya Feb 15, 2024
c3f8e93
Fix linting error
sahinakkaya Feb 15, 2024
20520c9
Merge remote-tracking branch 'upstream/main' into contributors-graph
sahinakkaya Feb 15, 2024
ee1de50
extract time-related functions to file and add test for startDaysBetween
silverwind Feb 15, 2024
3b7b636
use better end date
silverwind Feb 15, 2024
eb3c797
Explain issue in comment instead of writing external link
sahinakkaya Feb 15, 2024
316e871
Merge branch 'main' into contributors-graph
6543 Feb 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions modules/util/dates.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package util

import (
"time"
)

const layout = time.DateOnly

func ListSundaysBetween(startStr, endStr string) ([]int64, error) {
startDate, err := time.Parse(layout, startStr)
if err != nil {
return nil, err
}

endDate, err := time.Parse(layout, endStr)
if err != nil {
return nil, err
}

// Ensure the start date is a Sunday
for startDate.Weekday() != time.Sunday {
startDate = startDate.AddDate(0, 0, 1)
}

var sundays []int64

// Iterate from start date to end date and find all Sundays
for currentDate := startDate; currentDate.Before(endDate); currentDate = currentDate.AddDate(0, 0, 7) {
sundays = append(sundays, currentDate.UnixMilli())
}

return sundays, nil
}

func FindLastSundayBeforeDate(dateStr string) (string, error) {
date, err := time.Parse(layout, dateStr)
if err != nil {
return "", err
}

weekday := date.Weekday()
daysToSubtract := int(weekday) - int(time.Sunday)
if daysToSubtract < 0 {
daysToSubtract += 7
}

lastSunday := date.AddDate(0, 0, -daysToSubtract)
return lastSunday.Format(layout), nil
}

func FindFirstSundayAfterDate(dateStr string) (string, error) {
date, err := time.Parse(layout, dateStr)
if err != nil {
return "", err
}

weekday := date.Weekday()
daysToAdd := int(time.Sunday) - int(weekday)
if daysToAdd <= 0 {
daysToAdd += 7
}

firstSunday := date.AddDate(0, 0, daysToAdd)
return firstSunday.Format(layout), nil
}
12 changes: 12 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,8 @@ wiki.page_name_desc = Enter a name for this Wiki page. Some special names are: '
wiki.original_git_entry_tooltip = View original Git file instead of using friendly link.

activity = Activity
activity.navbar.pulse = Pulse
activity.navbar.contributors = Contributors
activity.period.filter_label = Period:
activity.period.daily = 1 day
activity.period.halfweekly = 3 days
Expand Down Expand Up @@ -1976,6 +1978,16 @@ activity.git_stats_and_deletions = and
activity.git_stats_deletion_1 = %d deletion
activity.git_stats_deletion_n = %d deletions

contributors = Contributors
contributors.contribution_type.filter_label = Contribution type:
contributors.contribution_type.commits = Commits
contributors.contribution_type.additions = Additions
contributors.contribution_type.deletions = Deletions
contributors.loading_title = Loading contributions...
contributors.loading_title_failed = Could not load contributions
contributors.loading_info = This might take a bit…
contributors.component_failed_to_load = An unexpected error happened.

search = Search
search.search_repo = Search repository
search.type.tooltip = Search type
Expand Down
61 changes: 61 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
"add-asset-webpack-plugin": "2.0.1",
"ansi_up": "6.0.2",
"asciinema-player": "3.6.3",
"chart.js": "4.3.0",
"chartjs-adapter-dayjs-4": "1.0.4",
"chartjs-plugin-zoom": "2.0.1",
"clippie": "4.0.6",
"css-loader": "6.8.1",
"dayjs": "1.11.10",
"dropzone": "6.0.0-beta.2",
"easymde": "2.18.0",
"esbuild-loader": "4.0.2",
Expand All @@ -46,6 +50,7 @@
"uint8-to-base64": "0.2.0",
"vue": "3.3.13",
"vue-bar-graph": "2.0.0",
"vue-chartjs": "5.2.0",
"vue-loader": "17.3.1",
"vue3-calendar-heatmap": "2.0.5",
"webpack": "5.89.0",
Expand Down
2 changes: 2 additions & 0 deletions routers/web/repo/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func Activity(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.activity")
ctx.Data["PageIsActivity"] = true

ctx.Data["PageIsPulse"] = true

ctx.Data["Period"] = ctx.Params("period")

timeUntil := time.Now()
Expand Down
44 changes: 44 additions & 0 deletions routers/web/repo/contributors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package repo

import (
"errors"
"net/http"

"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
contributors_service "code.gitea.io/gitea/services/repository"
)

const (
tplContributors base.TplName = "repo/activity"
)

// Contributors render the page to show repository contributors graph
func Contributors(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.contributors")

ctx.Data["PageIsActivity"] = true
ctx.Data["PageIsContributors"] = true

ctx.PageData["contributionType"] = "commits"

ctx.PageData["repoLink"] = ctx.Repo.RepoLink

ctx.HTML(http.StatusOK, tplContributors)
}

// ContributorsData renders JSON of contributors along with their weekly commit statistics
func ContributorsData(ctx *context.Context) {
if contributorStats, err := contributors_service.GetContributorStats(ctx, ctx.Cache, ctx.Repo.Repository, ctx.Repo.CommitID); err != nil {
if errors.Is(err, contributors_service.ErrAwaitGeneration) {
ctx.Status(http.StatusAccepted)
return
}
ctx.ServerError("GetContributorStats", err)
} else {
ctx.JSON(http.StatusOK, contributorStats)
}
}
4 changes: 4 additions & 0 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,10 @@ func registerRoutes(m *web.Route) {
m.Group("/activity", func() {
m.Get("", repo.Activity)
m.Get("/{period}", repo.Activity)
m.Group("/contributors", func() {
m.Get("", repo.Contributors)
m.Get("/data", repo.ContributorsData)
})
}, context.RepoRef(), repo.MustBeNotEmpty, context.RequireRepoReaderOr(unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases))

m.Group("/activity_author_data", func() {
Expand Down
Loading