aboutsummaryrefslogtreecommitdiffstats
path: root/models/activities
Commit message (Collapse)AuthorAgeFilesLines
* Enable addtional linters (#34085)TheFox0x712 days1-1/+2
| | | | | | | | enable mirror, usestdlibbars and perfsprint part of: https://github.com/go-gitea/gitea/issues/34083 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Enable testifylint rules (#34075)TheFox0x714 days2-7/+7
| | | | enable testifylint rules disabled in: https://github.com/go-gitea/gitea/pull/34054
* Optimize total count of feed when loading activities in user dashboard. (#33841)Lunny Xiao2025-03-202-6/+19
| | | | | | | | | | | | Two SQLs are very slow when `action` table have over 5M records. ``` database duration=1.8881s db.sql="SELECT created_unix DIV 900 * 900 AS timestamp, count(user_id) as contributions FROM `action` WHERE user_id=? AND act_user_id=? AND (created_unix > ?) GROUP BY timestamp ORDER BY timestamp" database duration=1.5408s db.sql="SELECT count(*) FROM `action` WHERE (user_id = ?) AND (is_deleted = ?)" ``` This will cache the count for the first loading or when the activities changed.
* Optimize heatmap query (#33853)Lunny Xiao2025-03-201-1/+4
| | | | | | | | | | | When there are over 5M records on `action` table, the heatmap on dashboard is very slow as below SQL. ``` database duration=1.8881s db.sql="SELECT created_unix DIV 900 * 900 AS timestamp, count(user_id) as contributions FROM `action` WHERE user_id=? AND act_user_id=? AND (created_unix > ?) GROUP BY timestamp ORDER BY timestamp" ``` This PR add a new index for `action` table with columns `user_id`, `act_user_id` and `created_unix` so that this query will become about 6 times faster than before.
* Move notifywatch to service layer (#33825)Lunny Xiao2025-03-102-170/+5
| | | No logic change.
* Decouple context from repository related structs (#33823)TheFox0x72025-03-081-2/+2
| | | Calls that required context implicitly are made to pass it as argument
* Optimize user dashboard loading (#33686)Lunny Xiao2025-02-242-14/+44
| | | | | | | | Fix #33582 Fix #31698 When a user login, the dashboard should load all feed belongs to him with no any conditions. The complicated conditions should be applied only for another user view this user's profile.
* Add missed auto merge feed message on dashboard (#33309)Lunny Xiao2025-01-261-2/+2
|
* Refactor RefName (#33234)wxiaoguang2025-01-131-1/+1
| | | And fix some FIXMEs
* Refactor tests (#33021)wxiaoguang2024-12-291-5/+3
| | | | | | | | | | | | | | | | 1. fix incorrect tests, for example: BeanExists doesn't do assert and shouldn't be used 2. remove unnecessary test functions 3. introduce DumpQueryResult to help to see the database rows during test (at least I need it) ``` ====== DumpQueryResult: SELECT * FROM action_runner_token ====== - # row[0] id: 1 token: xeiWBL5kuTYxGPynHCqQdoeYmJAeG3IzGXCYTrDX owner_id: 0 ... ```
* Fix bug on activities (#33008)Lunny Xiao2024-12-281-2/+5
| | | | | | A repository with no issue will display a random number on activities page. This is caused by wrong usage of `And` and `Or`. ![9cdbbf81d50aa5d9bd16604e0dab5eb0](https://github.com/user-attachments/assets/828cebdc-bd35-4716-a58c-c1b43ddf8bf0)
* Refactor "string truncate" (#32984)wxiaoguang2024-12-261-4/+4
|
* Move RepoTransfer from models to models/repo sub package (#32506)Lunny Xiao2024-12-181-1/+1
| | | | | | | | | | | | | `RepoTransfer` now is at models, but if we want to move it into `repo` model, it will depend on `Team`. So this PR also makes repo model depend on org model to make it possible. Just refactor, no code change. - [x] Move `DeleteOrganization` from `models/organization` to service layer - [x] Move `AccessibleTeamReposEnv` to `models/repo` - [x] Move `RepoTransfer` from `models` to `models/repo` - [x] Merge `getUserTeamIDs` and `GetUserTeamIDs`, Merge `GetUserTeams` and `getUserTeams`. - [x] Remove `Team`'s `Repos []*repo_model.Repository` to avoid dependency recycle.
* Enable tenv and testifylint rules (#32852)TheFox0x72024-12-151-3/+2
| | | | Enables tenv and testifylint linters closes: https://github.com/go-gitea/gitea/issues/32842
* Move GetFeeds to service layer (#32526)Lunny Xiao2024-11-294-203/+54
| | | Move GetFeeds from models to service layer, no code change.
* Fix markup render regression and fix some tests (#32640)wxiaoguang2024-11-262-3/+3
| | | | | | | Fix #32639, https://github.com/go-gitea/gitea/issues/32608#issuecomment-2497918210 By the way, fix some incorrect SQLs (use single quote but not double quote)
* Refactor markup render system (#32612)wxiaoguang2024-11-241-4/+4
| | | | | | | | | | This PR removes (almost) all path tricks, and introduces "renderhelper" package. Now we can clearly see the rendering behaviors for comment/file/wiki, more details are in "renderhelper" tests. Fix #31411 , fix #18592, fix #25632 and maybe more problems. (ps: fix #32608 by the way)
* Fix nil panic if repo doesn't exist (#32501)wxiaoguang2024-11-141-0/+6
| | | fix #32496
* Perf: add extra index to notification table (#32395)BoYanZh2024-11-131-9/+49
| | | | | | | | | | | Index SQL: `CREATE INDEX u_s_uu ON notification(user_id, status, updated_unix);` The naming follows `action.go` in the same dir. I am unsure which version I should add SQL to the migration folder, so I have not modified it. Fix #32390
* Add new index for action to resolve the performance problem (#32333)Lunny Xiao2024-11-061-1/+4
| | | Fix #32224
* Don't join repository when loading action table data (#32127)Lunny Xiao2024-09-262-14/+8
|
* Repo Activity: count new issues that were closed (#31776)Timon van der Berg2024-09-211-2/+28
| | | | | | | | | | | | | | | | | | | | I'm new to go and contributing to gitea, your guidance is much appreciated. This is meant to solve https://github.com/go-gitea/gitea/issues/13309 Previously, closed issues would not be shown under new issues in the activity tab, even if they were newly created. changes: * Split out newlyCreatedIssues from issuesForActivityStatement to count both currently open and closed issues. * Use a seperate function to count active issues to prevent double-counting issues after the above change. Result is that new issues that have been closed are shown both under "new" and "closed". Signed-off-by: Timon van der Berg <tmnvanderberg@gmail.com>
* Improve get feed with pagination (#31821)Lunny Xiao2024-09-021-9/+38
| | | | | | | | | Fix #31752 @somera --------- Co-authored-by: delvh <dev.lh@web.de>
* Refactor webhook (#31587)wxiaoguang2024-07-101-1/+3
| | | | | | A more complete fix for #31588 1. Make "generic" code more readable 2. Clarify HTML or Markdown for the payload content
* Fix web notification icon not updated once you read all notifications (#31447)kiatt2102024-06-231-4/+5
| | | | | | | | | Fix #29065 Remove status filtering from GetUIDsAndNotificationCounts sql. --------- Co-authored-by: kiatt210 <kiatt210@github.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Rename project board -> column to make the UI less confusing (#30170)Lunny Xiao2024-05-271-2/+2
| | | | | | | | | | | | | This PR split the `Board` into two parts. One is the struct has been renamed to `Column` and the second we have a `Template Type`. But to make it easier to review, this PR will not change the database schemas, they are just renames. The database schema changes could be in future PRs. --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: yp05327 <576951401@qq.com>
* Filter out duplicate action(activity) items for a repository (#30957)wxiaoguang2024-05-142-1/+31
| | | Fix #20986
* Reduce unnecessary database queries on actions table (#30509)Lunny Xiao2024-04-171-0/+6
|
* Refactor more filterslice (#30370)Lunny Xiao2024-04-101-7/+5
|
* Add container.FilterSlice function (#30339)oliverpool2024-04-091-18/+12
| | | | | | | | | | | | | | | | | | | | | | | | | Many places have the following logic: ```go func (jobs ActionJobList) GetRunIDs() []int64 { ids := make(container.Set[int64], len(jobs)) for _, j := range jobs { if j.RunID == 0 { continue } ids.Add(j.RunID) } return ids.Values() } ``` this introduces a `container.FilterMapUnique` function, which reduces the code above to: ```go func (jobs ActionJobList) GetRunIDs() []int64 { return container.FilterMapUnique(jobs, func(j *ActionRunJob) (int64, bool) { return j.RunID, j.RunID != 0 }) } ```
* Performance improvements for pull request list page (#29900)Lunny Xiao2024-03-211-0/+29
| | | | | | | | | | | This PR will avoid load pullrequest.Issue twice in pull request list page. It will reduce x times database queries for those WIP pull requests. Partially fix #29585 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Move notifications to a standalone file (#29930)Lunny Xiao2024-03-202-457/+472
| | | | There is no code change. Just move notification list related structs/functions from one file to another.
* Add more stats tables (#29730)Lunny Xiao2024-03-121-1/+6
| | | Add `Tags`, `Branches` and `CommitStatus` to monitor/stats
* Some performance optimization on dashboard and issues page (#29010)Lunny Xiao2024-03-122-74/+166
| | | | | | | | | This PR do some loading speed optimization for feeds user interface pages. - Load action users batchly but not one by one. - Load action repositories batchly but not one by one. - Load action's Repo Owners batchly but not one by one. - Load action's possible issues batchly but not one by one. - Load action's possible comments batchly but not one by one.
* Avoid issue info panic (#29625)wxiaoguang2024-03-061-3/+7
| | | Fix #29624
* Rename Action.GetDisplayName to GetActDisplayName (#29540)wxiaoguang2024-03-021-4/+4
| | | | | | To avoid conflicting with User.GetDisplayName, because there is no data type in template. And it matches other methods like GetActFullName / GetActUserName
* Revert "Speed up loading the dashboard on mysql/mariadb (#28546)" (#29006)Lunny Xiao2024-02-011-6/+3
| | | | This reverts commit fa8c3beb26acfcc7e732038c947225857ebcbf31. #28546 Because it seems performance become worse.
* Simplify how git repositories are opened (#28937)Lunny Xiao2024-01-271-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## Purpose This is a refactor toward building an abstraction over managing git repositories. Afterwards, it does not matter anymore if they are stored on the local disk or somewhere remote. ## What this PR changes We used `git.OpenRepository` everywhere previously. Now, we should split them into two distinct functions: Firstly, there are temporary repositories which do not change: ```go git.OpenRepository(ctx, diskPath) ``` Gitea managed repositories having a record in the database in the `repository` table are moved into the new package `gitrepo`: ```go gitrepo.OpenRepository(ctx, repo_model.Repo) ``` Why is `repo_model.Repository` the second parameter instead of file path? Because then we can easily adapt our repository storage strategy. The repositories can be stored locally, however, they could just as well be stored on a remote server. ## Further changes in other PRs - A Git Command wrapper on package `gitrepo` could be created. i.e. `NewCommand(ctx, repo_model.Repository, commands...)`. `git.RunOpts{Dir: repo.RepoPath()}`, the directory should be empty before invoking this method and it can be filled in the function only. #28940 - Remove the `RepoPath()`/`WikiPath()` functions to reduce the possibility of mistakes. --------- Co-authored-by: delvh <dev.lh@web.de>
* Speed up loading the dashboard on mysql/mariadb (#28546)Lunny Xiao2024-01-141-3/+6
| | | Fixes #28155
* Refactor timeutil package (#28623)wxiaoguang2023-12-281-2/+2
| | | | | 1. make names more readable 2. remove unused FormatLong/FormatShort 3. use `FormatDate` instead of `Format "2006-01-02"`
* Use db.Find instead of writing methods for every object (#28084)Lunny Xiao2023-11-243-104/+130
| | | | For those simple objects, it's unnecessary to write the find and count methods again and again.
* Refactor Find Sources and fix bug when view a user who belongs to an ↵Lunny Xiao2023-11-031-1/+1
| | | | | | | | | | | | unactive auth source (#27798) The steps to reproduce it. First, create a new oauth2 source. Then, a user login with this oauth2 source. Disable the oauth2 source. Visit users -> settings -> security, 500 will be displayed. This is because this page only load active Oauth2 sources but not all Oauth2 sources.
* Upgrade to golangci-lint@v1.55.0 (#27756)silverwind2023-10-241-2/+1
| | | https://github.com/golangci/golangci-lint/releases/tag/v1.55.0
* Penultimate round of `db.DefaultContext` refactor (#27414)JakobDev2023-10-111-1/+1
| | | | | | | Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Add Index to `action.user_id` (#27403)JakobDev2023-10-031-1/+1
| | | | | | Another Column that needs a Index. Found at https://codeberg.org/forgejo/discussions/issues/61#issuecomment-1258744. Co-authored-by: Giteabot <teabot@gitea.io>
* Even more `db.DefaultContext` refactor (#27352)JakobDev2023-10-032-2/+2
| | | | | | | | Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
* More `db.DefaultContext` refactor (#27265)JakobDev2023-09-295-67/+66
| | | | | | | Part of #27065 This PR touches functions used in templates. As templates are not static typed, errors are harder to find, but I hope I catch it all. I think some tests from other persons do not hurt.
* make writing main test easier (#27270)Lunny Xiao2023-09-281-4/+1
| | | | | | | | | This PR removed `unittest.MainTest` the second parameter `TestOptions.GiteaRoot`. Now it detects the root directory by current working directory. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Another round of `db.DefaultContext` refactor (#27103)JakobDev2023-09-252-7/+9
| | | | | | | Part of #27065 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Quote table `release` in sql queries (#27205)KN4CK3R2023-09-231-5/+5
| | | | | | | | | | Fixes #27174 `release` is a reserved keyword in MySql. I can't reproduce the issue on my setup and we have a test for that code but it seems there can be setups where it fails. https://github.com/go-gitea/gitea/blob/a101dbaa7952e359843c6d8303ca24a0e63c865c/tests/integration/repo_activity_test.go#L45-L46