[gitea] week 2025-11 cherry pick (gitea/main -> forgejo) (#7176)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7176 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
168b0ea9d4
|
@ -45,15 +45,12 @@ func init() {
|
|||
// GetSchedulesMapByIDs returns the schedules by given id slice.
|
||||
func GetSchedulesMapByIDs(ctx context.Context, ids []int64) (map[int64]*ActionSchedule, error) {
|
||||
schedules := make(map[int64]*ActionSchedule, len(ids))
|
||||
if len(ids) == 0 {
|
||||
return schedules, nil
|
||||
}
|
||||
return schedules, db.GetEngine(ctx).In("id", ids).Find(&schedules)
|
||||
}
|
||||
|
||||
// GetReposMapByIDs returns the repos by given id slice.
|
||||
func GetReposMapByIDs(ctx context.Context, ids []int64) (map[int64]*repo_model.Repository, error) {
|
||||
repos := make(map[int64]*repo_model.Repository, len(ids))
|
||||
return repos, db.GetEngine(ctx).In("id", ids).Find(&repos)
|
||||
}
|
||||
|
||||
// CreateScheduleTask creates new schedule task.
|
||||
func CreateScheduleTask(ctx context.Context, rows []*ActionSchedule) error {
|
||||
// Return early if there are no rows to insert
|
||||
|
|
|
@ -36,7 +36,7 @@ func (specs SpecList) LoadSchedules(ctx context.Context) error {
|
|||
}
|
||||
|
||||
repoIDs := specs.GetRepoIDs()
|
||||
repos, err := GetReposMapByIDs(ctx, repoIDs)
|
||||
repos, err := repo_model.GetRepositoriesMapByIDs(ctx, repoIDs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -269,6 +269,9 @@ func FindIDs(ctx context.Context, tableName, idCol string, cond builder.Cond) ([
|
|||
// DecrByIDs decreases the given column for entities of the "bean" type with one of the given ids by one
|
||||
// Timestamps of the entities won't be updated
|
||||
func DecrByIDs(ctx context.Context, ids []int64, decrCol string, bean any) error {
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
_, err := GetEngine(ctx).Decr(decrCol).In("id", ids).NoAutoCondition().NoAutoTime().Update(bean)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -546,6 +546,9 @@ func GetIssueByID(ctx context.Context, id int64) (*Issue, error) {
|
|||
// If keepOrder is true, the order of the returned issues will be the same as the given IDs.
|
||||
func GetIssuesByIDs(ctx context.Context, issueIDs []int64, keepOrder ...bool) (IssueList, error) {
|
||||
issues := make([]*Issue, 0, len(issueIDs))
|
||||
if len(issueIDs) == 0 {
|
||||
return issues, nil
|
||||
}
|
||||
|
||||
if err := db.GetEngine(ctx).In("id", issueIDs).Find(&issues); err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -303,6 +303,9 @@ func GetLabelByID(ctx context.Context, labelID int64) (*Label, error) {
|
|||
// GetLabelsByIDs returns a list of labels by IDs
|
||||
func GetLabelsByIDs(ctx context.Context, labelIDs []int64, cols ...string) ([]*Label, error) {
|
||||
labels := make([]*Label, 0, len(labelIDs))
|
||||
if len(labelIDs) == 0 {
|
||||
return labels, nil
|
||||
}
|
||||
return labels, db.GetEngine(ctx).Table("label").
|
||||
In("id", labelIDs).
|
||||
Asc("name").
|
||||
|
@ -379,6 +382,9 @@ func BuildLabelNamesIssueIDsCondition(labelNames []string) *builder.Builder {
|
|||
// it silently ignores label IDs that do not belong to the repository.
|
||||
func GetLabelsInRepoByIDs(ctx context.Context, repoID int64, labelIDs []int64) ([]*Label, error) {
|
||||
labels := make([]*Label, 0, len(labelIDs))
|
||||
if len(labelIDs) == 0 {
|
||||
return labels, nil
|
||||
}
|
||||
return labels, db.GetEngine(ctx).
|
||||
Where("repo_id = ?", repoID).
|
||||
In("id", labelIDs).
|
||||
|
@ -451,6 +457,9 @@ func GetLabelInOrgByID(ctx context.Context, orgID, labelID int64) (*Label, error
|
|||
// it silently ignores label IDs that do not belong to the organization.
|
||||
func GetLabelsInOrgByIDs(ctx context.Context, orgID int64, labelIDs []int64) ([]*Label, error) {
|
||||
labels := make([]*Label, 0, len(labelIDs))
|
||||
if len(labelIDs) == 0 {
|
||||
return labels, nil
|
||||
}
|
||||
return labels, db.GetEngine(ctx).
|
||||
Where("org_id = ?", orgID).
|
||||
In("id", labelIDs).
|
||||
|
|
|
@ -293,6 +293,9 @@ func SetDefaultColumn(ctx context.Context, projectID, columnID int64) error {
|
|||
|
||||
func GetColumnsByIDs(ctx context.Context, projectID int64, columnsIDs []int64) (ColumnList, error) {
|
||||
columns := make([]*Column, 0, 5)
|
||||
if len(columnsIDs) == 0 {
|
||||
return columns, nil
|
||||
}
|
||||
if err := db.GetEngine(ctx).
|
||||
Where("project_id =?", projectID).
|
||||
In("id", columnsIDs).
|
||||
|
|
Loading…
Reference in New Issue