activities

package
v0.0.0-...-d559fe2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivityQueryCondition

func ActivityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder.Cond, error)

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 CreateOrUpdateIssueNotifications

func CreateOrUpdateIssueNotifications(ctx context.Context, 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, issueIndex int64) error

DeleteIssueActions delete all actions related with issueID

func DeleteOldActions

func DeleteOldActions(ctx context.Context, 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 GetTotalContributionsInHeatmap

func GetTotalContributionsInHeatmap(hdata []*UserHeatmapData) int64

GetTotalContributionsInHeatmap returns the total number of contributions in a heatmap

func NotifyWatchers

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

NotifyWatchers creates batch of actions for every watcher. It could insert duplicate actions for a repository action, like this: * Original action: UserID=1 (the real actor), ActUserID=1 * Organization action: UserID=100 (the repo's org), ActUserID=1 * Watcher action: UserID=20 (a user who is watching a repo), ActUserID=1

func NotifyWatchersActions

func NotifyWatchersActions(ctx context.Context, 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 `xorm:"INDEX"` // 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:"-"`
	Issue       *issues_model.Issue    `xorm:"-"` // get the issue id from content
	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) GetActDisplayName

func (a *Action) GetActDisplayName(ctx context.Context) string

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

func (*Action) GetActDisplayNameTitle

func (a *Action) GetActDisplayNameTitle(ctx context.Context) string

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

func (*Action) GetActFullName

func (a *Action) GetActFullName(ctx context.Context) string

GetActFullName gets the action's user full name.

func (*Action) GetActUserName

func (a *Action) GetActUserName(ctx context.Context) string

GetActUserName gets the action's user name.

func (*Action) GetBranch

func (a *Action) GetBranch() string

GetBranch returns the action's repository branch.

func (*Action) GetCommentHTMLURL

func (a *Action) GetCommentHTMLURL(ctx context.Context) string

GetCommentHTMLURL returns link to action comment.

func (a *Action) GetCommentLink(ctx context.Context) 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) GetIssueContent

func (a *Action) GetIssueContent(ctx context.Context) 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 associated information with the action.

func (*Action) GetIssueTitle

func (a *Action) GetIssueTitle(ctx context.Context) 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(ctx context.Context) string

GetRefLink returns the action's ref link.

func (a *Action) GetRepoAbsoluteLink(ctx context.Context) string

GetRepoAbsoluteLink returns the absolute link to action repository.

func (a *Action) GetRepoLink(ctx context.Context) string

GetRepoLink returns relative link to action repository.

func (*Action) GetRepoName

func (a *Action) GetRepoName(ctx context.Context) string

GetRepoName returns the name of the action repository.

func (*Action) GetRepoPath

func (a *Action) GetRepoPath(ctx context.Context) string

GetRepoPath returns the virtual path to the action repository.

func (*Action) GetRepoUserName

func (a *Action) GetRepoUserName(ctx context.Context) 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) IsIssueEvent

func (a *Action) IsIssueEvent() bool

func (*Action) LoadActUser

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

LoadActUser loads a.ActUser

func (*Action) LoadIssue

func (a *Action) LoadIssue(ctx context.Context) error

func (*Action) LoadRepo

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

func (*Action) ShortActUserName

func (a *Action) ShortActUserName(ctx context.Context) string

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

func (*Action) ShortRepoName

func (a *Action) ShortRepoName(ctx context.Context) string

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

func (*Action) ShortRepoPath

func (a *Action) ShortRepoPath(ctx context.Context) string

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

func (*Action) ShortRepoUserName

func (a *Action) ShortRepoUserName(ctx context.Context) 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, int64, error)

GetFeeds returns actions according to the provided options

func (ActionList) LoadActUsers

func (actions ActionList) LoadActUsers(ctx context.Context) (map[int64]*user_model.User, error)

func (ActionList) LoadAttributes

func (actions ActionList) LoadAttributes(ctx context.Context) error

LoadAttributes loads all attributes

func (ActionList) LoadComments

func (actions ActionList) LoadComments(ctx context.Context) error

func (ActionList) LoadIssues

func (actions ActionList) LoadIssues(ctx context.Context) error

func (ActionList) LoadRepositories

func (actions ActionList) LoadRepositories(ctx context.Context) error

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.

func (ActionType) InActions

func (at ActionType) InActions(actions ...string) bool

func (ActionType) String

func (at ActionType) String() string

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
	ActiveIssues                issues_model.IssueList
	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(ctx context.Context, repoID int64, fromTime time.Time) error

FillIssues returns issue information for activity page

func (*ActivityStats) FillPullRequests

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

FillPullRequests returns pull request information for activity page

func (*ActivityStats) FillReleases

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

FillReleases returns release information for activity page

func (*ActivityStats) FillUnresolvedIssues

func (stats *ActivityStats) FillUnresolvedIssues(ctx context.Context, 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) ToConds

func (opts FindNotificationOptions) ToConds() builder.Cond

ToCond will convert each condition into a xorm-Cond

func (FindNotificationOptions) ToOrders

func (opts FindNotificationOptions) ToOrders() string

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:"NOT NULL"`
	RepoID int64 `xorm:"NOT NULL"`

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

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

	UpdatedBy int64 `xorm:"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 NOT NULL"`
	UpdatedUnix timeutil.TimeStamp `xorm:"updated NOT NULL"`
}

Notification represents a notification

func GetIssueNotification

func GetIssueNotification(ctx context.Context, userID, issueID int64) (*Notification, error)

GetIssueNotification return the notification about an issue

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(ctx context.Context) (*issues_model.Issue, error)

GetIssue returns the issue of the notification

func (*Notification) GetRepo

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

GetRepo returns the repo of the notification

func (*Notification) HTMLURL

func (n *Notification) HTMLURL(ctx context.Context) string

HTMLURL formats a URL-string to the notification

func (n *Notification) Link(ctx context.Context) string

Link formats a relative 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

func (*Notification) TableIndices

func (n *Notification) TableIndices() []*schemas.Index

TableIndices implements xorm's TableIndices interface

type NotificationList

type NotificationList []*Notification

NotificationList contains a list of notifications

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) LoadIssuePullRequests

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

LoadIssuePullRequests loads all issues' pull requests if possible

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) LoadUsers

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

LoadUsers loads users 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, Access,
		Issue, IssueClosed, IssueOpen,
		Comment, Oauth, Follow,
		Mirror, Release, AuthSource, Webhook,
		Milestone, Label, HookTask,
		Team, UpdateTask, Project,
		ProjectColumn, Attachment,
		Branches, Tags, CommitStatus int64
		IssueByLabel      []IssueByLabelCount
		IssueByRepository []IssueByRepositoryCount
	}
}

Statistic contains the database statistics

func GetStatistic

func GetStatistic(ctx context.Context) (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(ctx context.Context, user, doer *user_model.User) ([]*UserHeatmapData, error)

GetUserHeatmapDataByUser returns an array of UserHeatmapData

func GetUserHeatmapDataByUserTeam

func GetUserHeatmapDataByUserTeam(ctx context.Context, 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(ctx context.Context, since, until timeutil.TimeStamp) ([]UserIDCount, error)

GetUIDsAndNotificationCounts returns the unread counts for every user between the two provided times. It must return all user IDs which appear during the period, including count=0 for users who have read all.

Jump to

Keyboard shortcuts

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