Merge branch 'jobatzil/misc/fixcount' of _OKE5H2PQKOUfzFFDuD4FA/default/CODE/gitness (#347)

This commit is contained in:
Johannes Batzill 2023-08-23 00:13:29 +00:00 committed by Harness
commit 9cd7677efa
5 changed files with 12 additions and 4 deletions

View File

@ -239,7 +239,7 @@ func (s *pipelineStore) Count(ctx context.Context, parentID int64, filter types.
Where("pipeline_space_id = ?", parentID)
if filter.Query != "" {
stmt = stmt.Where("pipeline_uid LIKE ?", fmt.Sprintf("%%%s%%", filter.Query))
stmt = stmt.Where("LOWER(pipeline_uid) LIKE ?", fmt.Sprintf("%%%s%%", strings.ToLower(filter.Query)))
}
sql, args, err := stmt.ToSql()

View File

@ -407,6 +407,10 @@ func (s *PullReqStore) Count(ctx context.Context, opts *types.PullReqFilter) (in
stmt = stmt.Where("pullreq_target_branch = ?", opts.TargetBranch)
}
if opts.Query != "" {
stmt = stmt.Where("LOWER(pullreq_title) LIKE ?", fmt.Sprintf("%%%s%%", strings.ToLower(opts.Query)))
}
if opts.CreatedBy != 0 {
stmt = stmt.Where("pullreq_created_by = ?", opts.CreatedBy)
}
@ -459,7 +463,7 @@ func (s *PullReqStore) List(ctx context.Context, opts *types.PullReqFilter) ([]*
stmt = stmt.Where("LOWER(pullreq_title) LIKE ?", fmt.Sprintf("%%%s%%", strings.ToLower(opts.Query)))
}
if opts.CreatedBy > 0 {
if opts.CreatedBy != 0 {
stmt = stmt.Where("pullreq_created_by = ?", opts.CreatedBy)
}

View File

@ -257,7 +257,7 @@ func (s *RepoStore) Count(ctx context.Context, parentID int64, opts *types.RepoF
Where("repo_parent_id = ?", parentID)
if opts.Query != "" {
stmt = stmt.Where("repo_uid LIKE ?", fmt.Sprintf("%%%s%%", opts.Query))
stmt = stmt.Where("LOWER(repo_uid) LIKE ?", fmt.Sprintf("%%%s%%", strings.ToLower(opts.Query)))
}
sql, args, err := stmt.ToSql()

View File

@ -247,7 +247,7 @@ func (s *secretStore) Count(ctx context.Context, parentID int64, filter types.Li
Where("secret_space_id = ?", parentID)
if filter.Query != "" {
stmt = stmt.Where("secret_uid LIKE ?", fmt.Sprintf("%%%s%%", filter.Query))
stmt = stmt.Where("LOWER(secret_uid) LIKE ?", fmt.Sprintf("%%%s%%", strings.ToLower(filter.Query)))
}
sql, args, err := stmt.ToSql()

View File

@ -264,6 +264,10 @@ func (s *WebhookStore) Count(ctx context.Context, parentType enum.WebhookParent,
return 0, fmt.Errorf("webhook parent type '%s' is not supported", parentType)
}
if opts.Query != "" {
stmt = stmt.Where("LOWER(webhook_display_name) LIKE ?", fmt.Sprintf("%%%s%%", strings.ToLower(opts.Query)))
}
sql, args, err := stmt.ToSql()
if err != nil {
return 0, fmt.Errorf("failed to convert query to sql: %w", err)