summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorgordon-- <gordon_vdlg@gmx.de>2021-02-20 23:08:58 +0100
committerGitHub <noreply@github.com>2021-02-20 17:08:58 -0500
commit343c75635713ecbb494b7729558d0ba05eaf85dc (patch)
tree1c0e61f4d9e015b0036238517c246e1b50fba646 /models
parentf3e64f677fd242850beafb1767504722f2dc2703 (diff)
downloadgitea-343c75635713ecbb494b7729558d0ba05eaf85dc.tar.gz
gitea-343c75635713ecbb494b7729558d0ba05eaf85dc.zip
Heatmap days clickable (#13935)
* Heatmap days clickable * Error handling * Unselect filter * better dayclick handler * made linter happy * clickable heatmap for profiles Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'models')
-rw-r--r--models/action.go25
1 files changed, 19 insertions, 6 deletions
diff --git a/models/action.go b/models/action.go
index e8a1336566..47d056ae3a 100644
--- a/models/action.go
+++ b/models/action.go
@@ -289,12 +289,13 @@ func (a *Action) GetIssueContent() string {
// GetFeedsOptions options for retrieving feeds
type GetFeedsOptions struct {
- RequestedUser *User // the user we want activity for
- RequestedTeam *Team // the team we want activity for
- Actor *User // the user viewing the activity
- IncludePrivate bool // include private actions
- OnlyPerformedBy bool // only actions performed by requested user
- IncludeDeleted bool // include deleted actions
+ RequestedUser *User // the user we want activity for
+ RequestedTeam *Team // the team we want activity for
+ Actor *User // the user viewing the activity
+ IncludePrivate bool // include private actions
+ OnlyPerformedBy bool // only actions performed by requested user
+ IncludeDeleted bool // include deleted actions
+ Date string // the day we want activity for: YYYY-MM-DD
}
// GetFeeds returns actions according to the provided options
@@ -380,5 +381,17 @@ func activityQueryCondition(opts GetFeedsOptions) (builder.Cond, error) {
cond = cond.And(builder.Eq{"is_deleted": false})
}
+ if opts.Date != "" {
+ dateLow, err := time.Parse("2006-01-02", opts.Date)
+ if err != nil {
+ log.Warn("Unable to parse %s, filter not applied: %v", opts.Date, err)
+ } else {
+ dateHigh := dateLow.Add(86399000000000) // 23h59m59s
+
+ cond = cond.And(builder.Gte{"created_unix": dateLow.Unix()})
+ cond = cond.And(builder.Lte{"created_unix": dateHigh.Unix()})
+ }
+ }
+
return cond, nil
}