activities

package
v1.17.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 30 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivityReadable

func ActivityReadable(user, doer *user_model.User) bool

ActivityReadable return whether doer can read activities of user

func CountActionCreatedUnixString

func CountActionCreatedUnixString(ctx context.Context) (int64, error)

CountActionCreatedUnixString count actions where created_unix is an empty string

func CountNotifications

func CountNotifications(ctx context.Context, opts *FindNotificationOptions) (int64, error)

CountNotifications count all notifications that fit to the given options and ignore pagination.

func CountUnread

func CountUnread(ctx context.Context, userID int64) int64

CountUnread count unread notifications for a user

func CreateOrUpdateIssueNotifications

func CreateOrUpdateIssueNotifications(issueID, commentID, notificationAuthorID, receiverID int64) error

CreateOrUpdateIssueNotifications creates an issue notification for each watcher, or updates it if already exists receiverID > 0 just send to receiver, else send to all watcher

func CreateRepoTransferNotification

func CreateRepoTransferNotification(ctx context.Context, doer, newOwner *user_model.User, repo *repo_model.Repository) error

CreateRepoTransferNotification creates notification for the user a repository was transferred to

func DeleteIssueActions

func DeleteIssueActions(ctx context.Context, repoID, issueID int64) error

DeleteIssueActions delete all actions related with issueID

func DeleteOldActions

func DeleteOldActions(olderThan time.Duration) (err error)

DeleteOldActions deletes all old actions from database.

func FixActionCreatedUnixString

func FixActionCreatedUnixString(ctx context.Context) (int64, error)

FixActionCreatedUnixString set created_unix to zero if it is an empty string

func GetNotificationCount

func GetNotificationCount(ctx context.Context, user *user_model.User, status NotificationStatus) (count int64, err error)

GetNotificationCount returns the notification count for user

func NotifyWatchers

func NotifyWatchers(ctx context.Context, actions ...*Action) error

NotifyWatchers creates batch of actions for every watcher.

func NotifyWatchersActions

func NotifyWatchersActions(acts []*Action) error

NotifyWatchersActions creates batch of actions for every watcher.

func SetIssueReadBy

func SetIssueReadBy(ctx context.Context, issueID, userID int64) error

SetIssueReadBy sets issue to be read by given user.

func SetRepoReadBy

func SetRepoReadBy(ctx context.Context, userID, repoID int64) error

SetRepoReadBy sets repo to be visited by given user.

func UpdateNotificationStatuses

func UpdateNotificationStatuses(ctx context.Context, user *user_model.User, currentStatus, desiredStatus NotificationStatus) error

UpdateNotificationStatuses updates the statuses of all of a user's notifications that are of the currentStatus type to the desiredStatus

Types

type Action

type Action struct {
	ID          int64 `xorm:"pk autoincr"`
	UserID      int64 // Receiver user id.
	OpType      ActionType
	ActUserID   int64            // Action user id.
	ActUser     *user_model.User `xorm:"-"`
	RepoID      int64
	Repo        *repo_model.Repository `xorm:"-"`
	CommentID   int64                  `xorm:"INDEX"`
	Comment     *issues_model.Comment  `xorm:"-"`
	IsDeleted   bool                   `xorm:"NOT NULL DEFAULT false"`
	RefName     string
	IsPrivate   bool               `xorm:"NOT NULL DEFAULT false"`
	Content     string             `xorm:"TEXT"`
	CreatedUnix timeutil.TimeStamp `xorm:"created"`
}

Action represents user operation type and other information to repository. It implemented interface base.Actioner so that can be used in template render.

func (*Action) GetActFullName

func (a *Action) GetActFullName() string

GetActFullName gets the action's user full name.

func (*Action) GetActUserName

func (a *Action) GetActUserName() string

GetActUserName gets the action's user name.

func (*Action) GetBranch

func (a *Action) GetBranch() string

GetBranch returns the action's repository branch.

func (a *Action) GetCommentLink() string

GetCommentLink returns link to action comment.

func (*Action) GetContent

func (a *Action) GetContent() string

GetContent returns the action's content.

func (*Action) GetCreate

func (a *Action) GetCreate() time.Time

GetCreate returns the action creation time.

func (*Action) GetDisplayName

func (a *Action) GetDisplayName() string

GetDisplayName gets the action's display name based on DEFAULT_SHOW_FULL_NAME, or falls back to the username if it is blank.

func (*Action) GetDisplayNameTitle

func (a *Action) GetDisplayNameTitle() string

GetDisplayNameTitle gets the action's display name used for the title (tooltip) based on DEFAULT_SHOW_FULL_NAME

func (*Action) GetIssueContent

func (a *Action) GetIssueContent() string

GetIssueContent returns the content of first issue associated with this action.

func (*Action) GetIssueInfos

func (a *Action) GetIssueInfos() []string

GetIssueInfos returns a list of issues associated with the action.

func (*Action) GetIssueTitle

func (a *Action) GetIssueTitle() string

GetIssueTitle returns the title of first issue associated with the action.

func (*Action) GetOpType

func (a *Action) GetOpType() ActionType

GetOpType gets the ActionType of this action.

func (a *Action) GetRefLink() string

GetRefLink returns the action's ref link.

func (a *Action) GetRepoAbsoluteLink() string

GetRepoAbsoluteLink returns the absolute link to action repository.

func (a *Action) GetRepoLink() string

GetRepoLink returns relative link to action repository.

func (*Action) GetRepoName

func (a *Action) GetRepoName() string

GetRepoName returns the name of the action repository.

func (*Action) GetRepoPath

func (a *Action) GetRepoPath() string

GetRepoPath returns the virtual path to the action repository.

func (*Action) GetRepoUserName

func (a *Action) GetRepoUserName() string

GetRepoUserName returns the name of the action repository owner.

func (*Action) GetTag

func (a *Action) GetTag() string

GetTag returns the action's repository tag.

func (*Action) LoadActUser

func (a *Action) LoadActUser(ctx context.Context)

LoadActUser loads a.ActUser

func (*Action) ShortActUserName

func (a *Action) ShortActUserName() string

ShortActUserName gets the action's user name trimmed to max 20 chars.

func (*Action) ShortRepoName

func (a *Action) ShortRepoName() string

ShortRepoName returns the name of the action repository trimmed to max 33 chars.

func (*Action) ShortRepoPath

func (a *Action) ShortRepoPath() string

ShortRepoPath returns the virtual path to the action repository trimmed to max 20 + 1 + 33 chars.

func (*Action) ShortRepoUserName

func (a *Action) ShortRepoUserName() string

ShortRepoUserName returns the name of the action repository owner trimmed to max 20 chars.

func (*Action) TableIndices

func (a *Action) TableIndices() []*schemas.Index

TableIndices implements xorm's TableIndices interface

type ActionList

type ActionList []*Action

ActionList defines a list of actions

func GetFeeds

func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, error)

GetFeeds returns actions according to the provided options

type ActionType

type ActionType int

ActionType represents the type of an action.

const (
	ActionCreateRepo                ActionType = iota + 1 // 1
	ActionRenameRepo                                      // 2
	ActionStarRepo                                        // 3
	ActionWatchRepo                                       // 4
	ActionCommitRepo                                      // 5
	ActionCreateIssue                                     // 6
	ActionCreatePullRequest                               // 7
	ActionTransferRepo                                    // 8
	ActionPushTag                                         // 9
	ActionCommentIssue                                    // 10
	ActionMergePullRequest                                // 11
	ActionCloseIssue                                      // 12
	ActionReopenIssue                                     // 13
	ActionClosePullRequest                                // 14
	ActionReopenPullRequest                               // 15
	ActionDeleteTag                                       // 16
	ActionDeleteBranch                                    // 17
	ActionMirrorSyncPush                                  // 18
	ActionMirrorSyncCreate                                // 19
	ActionMirrorSyncDelete                                // 20
	ActionApprovePullRequest                              // 21
	ActionRejectPullRequest                               // 22
	ActionCommentPull                                     // 23
	ActionPublishRelease                                  // 24
	ActionPullReviewDismissed                             // 25
	ActionPullRequestReadyForReview                       // 26
	ActionAutoMergePullRequest                            // 27
)

Possible action types.

type ActivityAuthorData

type ActivityAuthorData struct {
	Name       string `json:"name"`
	Login      string `json:"login"`
	AvatarLink string `json:"avatar_link"`
	HomeLink   string `json:"home_link"`
	Commits    int64  `json:"commits"`
}

ActivityAuthorData represents statistical git commit count data

func GetActivityStatsTopAuthors

func GetActivityStatsTopAuthors(ctx context.Context, repo *repo_model.Repository, timeFrom time.Time, count int) ([]*ActivityAuthorData, error)

GetActivityStatsTopAuthors returns top author stats for git commits for all branches

type ActivityStats

type ActivityStats struct {
	OpenedPRs                   issues_model.PullRequestList
	OpenedPRAuthorCount         int64
	MergedPRs                   issues_model.PullRequestList
	MergedPRAuthorCount         int64
	OpenedIssues                issues_model.IssueList
	OpenedIssueAuthorCount      int64
	ClosedIssues                issues_model.IssueList
	ClosedIssueAuthorCount      int64
	UnresolvedIssues            issues_model.IssueList
	PublishedReleases           []*repo_model.Release
	PublishedReleaseAuthorCount int64
	Code                        *git.CodeActivityStats
}

ActivityStats represents issue and pull request information.

func GetActivityStats

func GetActivityStats(ctx context.Context, repo *repo_model.Repository, timeFrom time.Time, releases, issues, prs, code bool) (*ActivityStats, error)

GetActivityStats return stats for repository at given time range

func (*ActivityStats) ActiveIssueCount

func (stats *ActivityStats) ActiveIssueCount() int

ActiveIssueCount returns total active issue count

func (*ActivityStats) ActivePRCount

func (stats *ActivityStats) ActivePRCount() int

ActivePRCount returns total active pull request count

func (*ActivityStats) ClosedIssueCount

func (stats *ActivityStats) ClosedIssueCount() int

ClosedIssueCount returns closed issue count

func (*ActivityStats) ClosedIssuePerc

func (stats *ActivityStats) ClosedIssuePerc() int

ClosedIssuePerc returns closed issue count percent from total active

func (*ActivityStats) FillIssues

func (stats *ActivityStats) FillIssues(repoID int64, fromTime time.Time) error

FillIssues returns issue information for activity page

func (*ActivityStats) FillPullRequests

func (stats *ActivityStats) FillPullRequests(repoID int64, fromTime time.Time) error

FillPullRequests returns pull request information for activity page

func (*ActivityStats) FillReleases

func (stats *ActivityStats) FillReleases(repoID int64, fromTime time.Time) error

FillReleases returns release information for activity page

func (*ActivityStats) FillUnresolvedIssues

func (stats *ActivityStats) FillUnresolvedIssues(repoID int64, fromTime time.Time, issues, prs bool) error

FillUnresolvedIssues returns unresolved issue and pull request information for activity page

func (*ActivityStats) MergedPRCount

func (stats *ActivityStats) MergedPRCount() int

MergedPRCount returns merged pull request count

func (*ActivityStats) MergedPRPerc

func (stats *ActivityStats) MergedPRPerc() int

MergedPRPerc returns merged pull request percent from total active

func (*ActivityStats) OpenedIssueCount

func (stats *ActivityStats) OpenedIssueCount() int

OpenedIssueCount returns open issue count

func (*ActivityStats) OpenedIssuePerc

func (stats *ActivityStats) OpenedIssuePerc() int

OpenedIssuePerc returns open issue count percent from total active

func (*ActivityStats) OpenedPRCount

func (stats *ActivityStats) OpenedPRCount() int

OpenedPRCount returns opened pull request count

func (*ActivityStats) OpenedPRPerc

func (stats *ActivityStats) OpenedPRPerc() int

OpenedPRPerc returns opened pull request percents from total active

func (*ActivityStats) PublishedReleaseCount

func (stats *ActivityStats) PublishedReleaseCount() int

PublishedReleaseCount returns published release count

func (*ActivityStats) UnresolvedIssueCount

func (stats *ActivityStats) UnresolvedIssueCount() int

UnresolvedIssueCount returns unresolved issue and pull request count

type FindNotificationOptions

type FindNotificationOptions struct {
	db.ListOptions
	UserID            int64
	RepoID            int64
	IssueID           int64
	Status            []NotificationStatus
	Source            []NotificationSource
	UpdatedAfterUnix  int64
	UpdatedBeforeUnix int64
}

FindNotificationOptions represent the filters for notifications. If an ID is 0 it will be ignored.

func (*FindNotificationOptions) ToCond

func (opts *FindNotificationOptions) ToCond() builder.Cond

ToCond will convert each condition into a xorm-Cond

func (*FindNotificationOptions) ToSession

func (opts *FindNotificationOptions) ToSession(ctx context.Context) *xorm.Session

ToSession will convert the given options to a xorm Session by using the conditions from ToCond and joining with issue table if required

type GetFeedsOptions

type GetFeedsOptions struct {
	db.ListOptions
	RequestedUser   *user_model.User       // the user we want activity for
	RequestedTeam   *organization.Team     // the team we want activity for
	RequestedRepo   *repo_model.Repository // the repo we want activity for
	Actor           *user_model.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
}

GetFeedsOptions options for retrieving feeds

type IssueByLabelCount

type IssueByLabelCount struct {
	Count int64
	Label string
}

IssueByLabelCount contains the number of issue group by label

type IssueByRepositoryCount

type IssueByRepositoryCount struct {
	Count      int64
	OwnerName  string
	Repository string
}

IssueByRepositoryCount contains the number of issue group by repository

type Notification

type Notification struct {
	ID     int64 `xorm:"pk autoincr"`
	UserID int64 `xorm:"INDEX NOT NULL"`
	RepoID int64 `xorm:"INDEX NOT NULL"`

	Status NotificationStatus `xorm:"SMALLINT INDEX NOT NULL"`
	Source NotificationSource `xorm:"SMALLINT INDEX NOT NULL"`

	IssueID   int64  `xorm:"INDEX NOT NULL"`
	CommitID  string `xorm:"INDEX"`
	CommentID int64

	UpdatedBy int64 `xorm:"INDEX NOT NULL"`

	Issue      *issues_model.Issue    `xorm:"-"`
	Repository *repo_model.Repository `xorm:"-"`
	Comment    *issues_model.Comment  `xorm:"-"`
	User       *user_model.User       `xorm:"-"`

	CreatedUnix timeutil.TimeStamp `xorm:"created INDEX NOT NULL"`
	UpdatedUnix timeutil.TimeStamp `xorm:"updated INDEX NOT NULL"`
}

Notification represents a notification

func GetNotificationByID

func GetNotificationByID(ctx context.Context, notificationID int64) (*Notification, error)

GetNotificationByID return notification by ID

func SetNotificationStatus

func SetNotificationStatus(ctx context.Context, notificationID int64, user *user_model.User, status NotificationStatus) (*Notification, error)

SetNotificationStatus change the notification status

func (*Notification) APIURL

func (n *Notification) APIURL() string

APIURL formats a URL-string to the notification

func (*Notification) GetIssue

func (n *Notification) GetIssue() (*issues_model.Issue, error)

GetIssue returns the issue of the notification

func (*Notification) GetRepo

func (n *Notification) GetRepo() (*repo_model.Repository, error)

GetRepo returns the repo of the notification

func (*Notification) HTMLURL

func (n *Notification) HTMLURL() string

HTMLURL formats a URL-string to the notification

func (*Notification) LoadAttributes

func (n *Notification) LoadAttributes(ctx context.Context) (err error)

LoadAttributes load Repo Issue User and Comment if not loaded

type NotificationList

type NotificationList []*Notification

NotificationList contains a list of notifications

func GetNotifications

func GetNotifications(ctx context.Context, options *FindNotificationOptions) (nl NotificationList, err error)

GetNotifications returns all notifications that fit to the given options.

func NotificationsForUser

func NotificationsForUser(ctx context.Context, user *user_model.User, statuses []NotificationStatus, page, perPage int) (notifications NotificationList, err error)

NotificationsForUser returns notifications for a given user and status

func (NotificationList) LoadAttributes

func (nl NotificationList) LoadAttributes(ctx context.Context) error

LoadAttributes load Repo Issue User and Comment if not loaded

func (NotificationList) LoadComments

func (nl NotificationList) LoadComments(ctx context.Context) ([]int, error)

LoadComments loads comments from database

func (NotificationList) LoadIssues

func (nl NotificationList) LoadIssues(ctx context.Context) ([]int, error)

LoadIssues loads issues from database

func (NotificationList) LoadRepos

LoadRepos loads repositories from database

func (NotificationList) Without

func (nl NotificationList) Without(failures []int) NotificationList

Without returns the notification list without the failures

type NotificationSource

type NotificationSource uint8

NotificationSource is the source of the notification (issue, PR, commit, etc)

const (
	// NotificationSourceIssue is a notification of an issue
	NotificationSourceIssue NotificationSource = iota + 1
	// NotificationSourcePullRequest is a notification of a pull request
	NotificationSourcePullRequest
	// NotificationSourceCommit is a notification of a commit
	NotificationSourceCommit
	// NotificationSourceRepository is a notification for a repository
	NotificationSourceRepository
)

type NotificationStatus

type NotificationStatus uint8

NotificationStatus is the status of the notification (read or unread)

const (
	// NotificationStatusUnread represents an unread notification
	NotificationStatusUnread NotificationStatus = iota + 1
	// NotificationStatusRead represents a read notification
	NotificationStatusRead
	// NotificationStatusPinned represents a pinned notification
	NotificationStatusPinned
)

type Statistic

type Statistic struct {
	Counter struct {
		User, Org, PublicKey,
		Repo, Watch, Star, Action, Access,
		Issue, IssueClosed, IssueOpen,
		Comment, Oauth, Follow,
		Mirror, Release, AuthSource, Webhook,
		Milestone, Label, HookTask,
		Team, UpdateTask, Project,
		ProjectBoard, Attachment int64
		IssueByLabel      []IssueByLabelCount
		IssueByRepository []IssueByRepositoryCount
	}
}

Statistic contains the database statistics

func GetStatistic

func GetStatistic() (stats Statistic)

GetStatistic returns the database statistics

type UserHeatmapData

type UserHeatmapData struct {
	Timestamp     timeutil.TimeStamp `json:"timestamp"`
	Contributions int64              `json:"contributions"`
}

UserHeatmapData represents the data needed to create a heatmap

func GetUserHeatmapDataByUser

func GetUserHeatmapDataByUser(user, doer *user_model.User) ([]*UserHeatmapData, error)

GetUserHeatmapDataByUser returns an array of UserHeatmapData

func GetUserHeatmapDataByUserTeam

func GetUserHeatmapDataByUserTeam(user *user_model.User, team *organization.Team, doer *user_model.User) ([]*UserHeatmapData, error)

GetUserHeatmapDataByUserTeam returns an array of UserHeatmapData

type UserIDCount

type UserIDCount struct {
	UserID int64
	Count  int64
}

UserIDCount is a simple coalition of UserID and Count

func GetUIDsAndNotificationCounts

func GetUIDsAndNotificationCounts(since, until timeutil.TimeStamp) ([]UserIDCount, error)

GetUIDsAndNotificationCounts between the two provided times

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL