Skip to content

fix: ci-cd count per day in telemetry data #4931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
72a18a0
fix: ci-cd count
komalreddy3 Apr 12, 2024
cffd27d
Merge branch 'main' into fix-ci-cd-count
komalreddy3 Apr 12, 2024
4686c48
Merge branch 'main' into fix-ci-cd-count
komalreddy3 Apr 12, 2024
d115038
Merge branch 'fix-ci-cd-count' of https://github.com/devtron-labs/dev…
komalreddy3 Apr 12, 2024
917e220
update queries
komalreddy3 Apr 12, 2024
9c7257b
Merge branch 'main' into fix-ci-cd-count
komalreddy3 Apr 12, 2024
660fba5
update queries to go-pg instead of raw
komalreddy3 Apr 12, 2024
ee71147
remove omit empty
komalreddy3 Apr 15, 2024
c6f9555
summarycron expr change
komalreddy3 Apr 16, 2024
ade898b
refactor
komalreddy3 Apr 18, 2024
0d4e8db
Merge branch 'main' into fix-ci-cd-count
komalreddy3 Apr 18, 2024
4dde447
type fix
komalreddy3 Apr 18, 2024
398c78d
remove comments
komalreddy3 Apr 18, 2024
8c05e67
Merge branch 'fix-ci-cd-count' of https://github.com/devtron-labs/dev…
komalreddy3 Apr 18, 2024
58f99e2
Merge branch 'main' into fix-ci-cd-count
komalreddy3 Apr 18, 2024
21fedc6
refactor query
komalreddy3 Apr 19, 2024
19b9503
typo
komalreddy3 Apr 19, 2024
7098b15
Merge branch 'fix-ci-cd-count' of https://github.com/devtron-labs/dev…
komalreddy3 Apr 19, 2024
abf8262
docker query
komalreddy3 Apr 19, 2024
55e5120
refactor
komalreddy3 Apr 19, 2024
a3dddcf
Merge branch 'main' into fix-ci-cd-count
komalreddy3 Apr 19, 2024
9279efa
fetching to retrieving
komalreddy3 Apr 19, 2024
a762f30
Merge branch 'fix-ci-cd-count' of https://github.com/devtron-labs/dev…
komalreddy3 Apr 19, 2024
ea6224c
remove unnecessary column
komalreddy3 Apr 19, 2024
1cfa504
Merge branch 'main' into fix-ci-cd-count
komalreddy3 Apr 22, 2024
f849e06
Merge branch 'main' into fix-ci-cd-count
komalreddy3 Apr 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 63 additions & 37 deletions client/telemetry/TelemetryEventClientExtended.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ type TelemetryEventDto struct {
UserCount int `json:"userCount,omitempty"`
EnvironmentCount int `json:"environmentCount,omitempty"`
ClusterCount int `json:"clusterCount,omitempty"`
CiCountPerDay int `json:"ciCountPerDay,omitempty"`
CdCountPerDay int `json:"cdCountPerDay,omitempty"`
CiCreatedPerDay int `json:"ciCreatedPerDay"`
CdCreatedPerDay int `json:"cdCreatedPerDay"`
CiDeletedPerDay int `json:"ciDeletedPerDay"`
CdDeletedPerDay int `json:"cdDeletedPerDay"`
CiTriggeredPerDay int `json:"ciTriggeredPerDay"`
CdTriggeredPerDay int `json:"cdTriggeredPerDay"`
HelmChartCount int `json:"helmChartCount,omitempty"`
SecurityScanCountPerDay int `json:"securityScanCountPerDay,omitempty"`
GitAccountsCount int `json:"gitAccountsCount,omitempty"`
Expand Down Expand Up @@ -187,7 +191,7 @@ func (impl *TelemetryEventClientImplExtended) SendSummaryEvent(eventType string)
impl.logger.Infow("sending summary event", "eventType", eventType)
ucid, err := impl.getUCID()
if err != nil {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
impl.logger.Errorw("exception caught inside telemetry summary event while retrieving ucid", "err", err)
return err
}

Expand All @@ -200,58 +204,77 @@ func (impl *TelemetryEventClientImplExtended) SendSummaryEvent(eventType string)
payload := &TelemetryEventDto{UCID: ucid, Timestamp: time.Now(), EventType: TelemetryEventType(eventType), DevtronVersion: "v1"}
payload.ServerVersion = k8sServerVersion.String()

environments, err := impl.environmentService.GetAllActive()
environmentCount, err := impl.environmentService.GetAllActiveEnvironmentCount()
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
return err
impl.logger.Errorw("exception caught inside telemetry summary event while retrieving environmentCount, setting its value to -1", "err", err)
environmentCount = -1
}

prodApps, err := impl.appListingRepository.FindAppCount(true)
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
return err
impl.logger.Errorw("exception caught inside telemetry summary event, while retrieving prodApps, setting its value to -1", "err", err)
prodApps = -1
}

nonProdApps, err := impl.appListingRepository.FindAppCount(false)
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
return err
impl.logger.Errorw("exception caught inside telemetry summary event,while retrieving nonProdApps, setting its value to -1", "err", err)
nonProdApps = -1
}

ciPipeline, err := impl.ciPipelineRepository.FindAllPipelineInLast24Hour()
ciPipelineCount, err := impl.ciPipelineRepository.FindAllPipelineCreatedCountInLast24Hour()
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
return err
impl.logger.Errorw("exception caught inside telemetry summary event, while retrieving ciPipelineCount, setting its value to -1", "err", err)
ciPipelineCount = -1
}

cdPipeline, err := impl.pipelineRepository.FindAllPipelineInLast24Hour()
ciPipelineDeletedCount, err := impl.ciPipelineRepository.FindAllDeletedPipelineCountInLast24Hour()
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
return err
impl.logger.Errorw("exception caught inside telemetry summary event, while retrieving ciPipelineDeletedCount, setting its value to -1", "err", err)
ciPipelineDeletedCount = -1
}
ciPipelineTriggeredCount, err := impl.ciWorkflowRepository.FindAllTriggeredWorkflowCountInLast24Hour()
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("exception caught inside telemetry summary event, while retrieving ciPipelineTriggeredCount, setting its value to -1", "err", err)
ciPipelineTriggeredCount = -1
}

gitAccounts, err := impl.gitProviderRepository.FindAll()
cdPipelineCount, err := impl.pipelineRepository.FindAllPipelineCreatedCountInLast24Hour()
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
return err
impl.logger.Errorw("exception caught inside telemetry summary event, while retrieving cdPipelineCount, setting its value to -1", "err", err)
cdPipelineCount = -1
}
cdPipelineDeletedCount, err := impl.pipelineRepository.FindAllDeletedPipelineCountInLast24Hour()
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("exception caught inside telemetry summary event, while retrieving cdPipelineDeletedCount, setting its value to -1", "err", err)
cdPipelineDeletedCount = -1
}
cdPipelineTriggeredCount, err := impl.cdWorkflowRepository.FindAllTriggeredWorkflowCountInLast24Hour()
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("exception caught inside telemetry summary event, while retrieving cdPipelineTriggeredCount, setting its value to -1", "err", err)
cdPipelineTriggeredCount = -1
}
gitAccounts, err := impl.gitProviderRepository.FindAllGitProviderCount()
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("exception caught inside telemetry summary event, while retrieving gitAccounts, setting its value to -1", "err", err)
gitAccounts = -1
}

gitOpsCount, err := impl.gitOpsConfigReadService.GetConfiguredGitOpsCount()
if err != nil {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
return err
impl.logger.Errorw("exception caught inside telemetry summary event,while retrieving gitOpsCount, setting its value to -1", "err", err)
gitOpsCount = -1
}

containerRegistry, err := impl.dockerArtifactStoreRepository.FindAll()
containerRegistryCount, err := impl.dockerArtifactStoreRepository.FindAllDockerArtifactCount()
if err != nil && err != pg.ErrNoRows {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
return err
impl.logger.Errorw("exception caught inside telemetry summary event,while retrieving containerRegistryCount, setting its value to -1", "err", err)
containerRegistryCount = -1
}

//appSetup := false
apps, err := impl.appRepository.FindAll()
if err != nil {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
impl.logger.Errorw("exception caught inside telemetry summary event,while retrieving apps", "err", err)
return err
}

Expand All @@ -264,24 +287,24 @@ func (impl *TelemetryEventClientImplExtended) SendSummaryEvent(eventType string)
if len(appIds) < AppsCount {
payload.AppsWithGitRepoConfigured, err = impl.materialRepository.FindNumberOfAppsWithGitRepo(appIds)
if err != nil {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
impl.logger.Errorw("exception caught inside telemetry summary event,while retrieving AppsWithGitRepoConfigured", "err", err)
}
payload.AppsWithDockerConfigured, err = impl.ciTemplateRepository.FindNumberOfAppsWithDockerConfigured(appIds)
if err != nil {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
impl.logger.Errorw("exception caught inside telemetry summary event,while retrieving AppsWithDockerConfigured", "err", err)
}
payload.AppsWithDeploymentTemplateConfigured, err = impl.chartRepository.FindNumberOfAppsWithDeploymentTemplate(appIds)
if err != nil {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
impl.logger.Errorw("exception caught inside telemetry summary event,while retrieving AppsWithDeploymentTemplateConfigured", "err", err)
}
payload.AppsWithCiPipelineConfigured, err = impl.ciPipelineRepository.FindNumberOfAppsWithCiPipeline(appIds)
if err != nil {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
impl.logger.Errorw("exception caught inside telemetry summary event,while retrieving AppsWithCiPipelineConfigured", "err", err)
}

payload.AppsWithCdPipelineConfigured, err = impl.pipelineRepository.FindNumberOfAppsWithCdPipeline(appIds)
if err != nil {
impl.logger.Errorw("exception caught inside telemetry summary event", "err", err)
impl.logger.Errorw("exception caught inside telemetry summary event,while retrieving AppsWithCdPipelineConfigured", "err", err)
}
}

Expand All @@ -302,15 +325,18 @@ func (impl *TelemetryEventClientImplExtended) SendSummaryEvent(eventType string)
devtronVersion := util.GetDevtronVersion()
payload.ProdAppCount = prodApps
payload.NonProdAppCount = nonProdApps
payload.RegistryCount = len(containerRegistry)
payload.RegistryCount = containerRegistryCount
payload.SSOLogin = ssoSetup
payload.UserCount = len(users)
payload.EnvironmentCount = len(environments)
payload.EnvironmentCount = environmentCount
payload.ClusterCount = len(clusters)
payload.CiCountPerDay = len(ciPipeline)

payload.CdCountPerDay = len(cdPipeline)
payload.GitAccountsCount = len(gitAccounts)
payload.CiCreatedPerDay = ciPipelineCount
payload.CiDeletedPerDay = ciPipelineDeletedCount
payload.CiTriggeredPerDay = ciPipelineTriggeredCount
payload.CdCreatedPerDay = cdPipelineCount
payload.CdDeletedPerDay = cdPipelineDeletedCount
payload.CdTriggeredPerDay = cdPipelineTriggeredCount
payload.GitAccountsCount = gitAccounts
payload.GitOpsCount = gitOpsCount
payload.HostURL = hostURL
payload.DevtronGitVersion = devtronVersion.GitCommit
Expand Down
2 changes: 1 addition & 1 deletion cmd/external-app/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions internal/sql/repository/GitOpsConfigRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type GitOpsConfigRepository interface {
UpdateGitOpsConfig(model *GitOpsConfig, tx *pg.Tx) error
GetGitOpsConfigById(id int) (*GitOpsConfig, error)
GetAllGitOpsConfig() ([]*GitOpsConfig, error)
GetAllGitOpsConfigCount() (int, error)
GetGitOpsConfigByProvider(provider string) (*GitOpsConfig, error)
GetGitOpsConfigActive() (*GitOpsConfig, error)
GetConnection() *pg.DB
Expand Down Expand Up @@ -91,6 +92,10 @@ func (impl *GitOpsConfigRepositoryImpl) GetAllGitOpsConfig() ([]*GitOpsConfig, e
err := impl.dbConnection.Model(&userModel).Order("updated_on desc").Select()
return userModel, err
}
func (impl *GitOpsConfigRepositoryImpl) GetAllGitOpsConfigCount() (int, error) {
cnt, err := impl.dbConnection.Model(&GitOpsConfig{}).Count()
return cnt, err
}
func (impl *GitOpsConfigRepositoryImpl) GetGitOpsConfigByProvider(provider string) (*GitOpsConfig, error) {
var model GitOpsConfig
err := impl.dbConnection.Model(&model).Where("provider = ?", provider).Select()
Expand Down
6 changes: 6 additions & 0 deletions internal/sql/repository/GitProviderRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type GitProviderRepository interface {
ProviderExists(url string) (bool, error)
FindAllActiveForAutocomplete() ([]GitProvider, error)
FindAll() ([]GitProvider, error)
FindAllGitProviderCount() (int, error)
FindOne(providerId string) (GitProvider, error)
FindByUrl(providerUrl string) (GitProvider, error)
Update(gitProvider *GitProvider) error
Expand Down Expand Up @@ -95,6 +96,11 @@ func (impl GitProviderRepositoryImpl) FindAll() ([]GitProvider, error) {
Where("deleted = ?", false).Select()
return providers, err
}
func (impl GitProviderRepositoryImpl) FindAllGitProviderCount() (int, error) {
gitProviderCount, err := impl.dbConnection.Model(&GitProvider{}).
Where("deleted = ?", false).Count()
return gitProviderCount, err
}

func (impl GitProviderRepositoryImpl) FindOne(providerId string) (GitProvider, error) {
var provider GitProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ type DockerArtifactStoreRepository interface {
FindActiveDefaultStore() (*DockerArtifactStore, error)
FindAllActiveForAutocomplete() ([]DockerArtifactStore, error)
FindAll() ([]DockerArtifactStore, error)
FindAllDockerArtifactCount() (int, error)
FindAllChartProviders() ([]DockerArtifactStore, error)
FindOne(storeId string) (*DockerArtifactStore, error)
FindOneWithDeploymentCount(storeId string) (*DockerArtifactStoreExt, error)
Expand Down Expand Up @@ -169,7 +170,12 @@ func (impl DockerArtifactStoreRepositoryImpl) FindAll() ([]DockerArtifactStore,
Select()
return providers, err
}

func (impl DockerArtifactStoreRepositoryImpl) FindAllDockerArtifactCount() (int, error) {
dockerArtifactCount, err := impl.dbConnection.Model(&DockerArtifactStore{}).
Where("docker_artifact_store.active = ?", true).
Count()
return dockerArtifactCount, err
}
func (impl DockerArtifactStoreRepositoryImpl) FindAllChartProviders() ([]DockerArtifactStore, error) {
var providers []DockerArtifactStore
err := impl.dbConnection.Model(&providers).
Expand Down
16 changes: 14 additions & 2 deletions internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type CdWorkflowRepository interface {
FindLatestWfrByAppIdAndEnvironmentId(appId int, environmentId int) (*CdWorkflowRunner, error)
IsLatestCDWfr(pipelineId, wfrId int) (bool, error)
FindLatestCdWorkflowRunnerByEnvironmentIdAndRunnerType(appId int, environmentId int, runnerType bean.WorkflowType) (CdWorkflowRunner, error)

FindAllTriggeredWorkflowCountInLast24Hour() (cdWorkflowCount int, err error)
GetConnection() *pg.DB

FindLastPreOrPostTriggeredByPipelineId(pipelineId int) (CdWorkflowRunner, error)
Expand Down Expand Up @@ -357,7 +357,19 @@ func (impl *CdWorkflowRepositoryImpl) FindLatestCdWorkflowByPipelineIdV2(pipelin
// TODO - Group By Environment And Pipeline will get latest pipeline from top
return cdWorkflow, err
}

func (impl *CdWorkflowRepositoryImpl) FindAllTriggeredWorkflowCountInLast24Hour() (cdWorkflowCount int, err error) {
cnt, err := impl.dbConnection.
Model(&CdWorkflow{}).
ColumnExpr("DISTINCT pipeline_id").
Join("JOIN cd_workflow_runner ON cd_workflow.id = cd_workflow_runner.cd_workflow_id").
Where("cd_workflow_runner.workflow_type = ? AND cd_workflow_runner.started_on > ?", bean.CD_WORKFLOW_TYPE_DEPLOY, time.Now().AddDate(0, 0, -1)).
Group("cd_workflow.pipeline_id").
Count()
if err != nil {
impl.logger.Errorw("error occurred while fetching cd workflow", "err", err)
}
return cnt, err
}
func (impl *CdWorkflowRepositoryImpl) FindCdWorkflowMetaByEnvironmentId(appId int, environmentId int, offset int, limit int) ([]CdWorkflowRunner, error) {
var wfrList []CdWorkflowRunner
err := impl.dbConnection.
Expand Down
18 changes: 12 additions & 6 deletions internal/sql/repository/pipelineConfig/CiPipelineRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ type CiPipelineRepository interface {
FetchParentCiPipelinesForDG() ([]*bean.CiPipelinesMap, error)
FetchCiPipelinesForDG(parentId int, childCiPipelineIds []int) (*CiPipeline, int, error)
FinDByParentCiPipelineAndAppId(parentCiPipeline int, appIds []int) ([]*CiPipeline, error)
FindAllPipelineInLast24Hour() (pipelines []*CiPipeline, err error)
FindAllPipelineCreatedCountInLast24Hour() (pipelineCount int, err error)
FindAllDeletedPipelineCountInLast24Hour() (pipelineCount int, err error)
FindNumberOfAppsWithCiPipeline(appIds []int) (count int, err error)
FindAppAndProjectByCiPipelineIds(ciPipelineIds []int) ([]*CiPipeline, error)
FindCiPipelineConfigsByIds(ids []int) ([]*CiPipeline, error)
Expand Down Expand Up @@ -502,12 +503,17 @@ func (impl *CiPipelineRepositoryImpl) FinDByParentCiPipelineAndAppId(parentCiPip
return ciPipelines, err
}

func (impl *CiPipelineRepositoryImpl) FindAllPipelineInLast24Hour() (pipelines []*CiPipeline, err error) {
err = impl.dbConnection.Model(&pipelines).
Column("ci_pipeline.*").
func (impl *CiPipelineRepositoryImpl) FindAllPipelineCreatedCountInLast24Hour() (pipelineCount int, err error) {
pipelineCount, err = impl.dbConnection.Model(&CiPipeline{}).
Where("created_on > ?", time.Now().AddDate(0, 0, -1)).
Select()
return pipelines, err
Count()
return pipelineCount, err
}
func (impl *CiPipelineRepositoryImpl) FindAllDeletedPipelineCountInLast24Hour() (pipelineCount int, err error) {
pipelineCount, err = impl.dbConnection.Model(&CiPipeline{}).
Where("created_on > ? and deleted=?", time.Now().AddDate(0, 0, -1), true).
Count()
return pipelineCount, err
}

func (impl *CiPipelineRepositoryImpl) FindNumberOfAppsWithCiPipeline(appIds []int) (count int, err error) {
Expand Down
12 changes: 11 additions & 1 deletion internal/sql/repository/pipelineConfig/CiWorkflowRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type CiWorkflowRepository interface {
FindLastTriggeredWorkflowByCiIds(pipelineId []int) (ciWorkflow []*CiWorkflow, err error)
FindLastTriggeredWorkflowByArtifactId(ciArtifactId int) (ciWorkflow *CiWorkflow, err error)
FindAllLastTriggeredWorkflowByArtifactId(ciArtifactId []int) (ciWorkflow []*CiWorkflow, err error)
FindAllTriggeredWorkflowCountInLast24Hour() (ciWorkflowCount int, err error)
FindLastTriggeredWorkflowGitTriggersByArtifactId(ciArtifactId int) (ciWorkflow *CiWorkflow, err error)
FindLastTriggeredWorkflowGitTriggersByArtifactIds(ciArtifactIds []int) ([]*WorkflowWithArtifact, error)
ExistsByStatus(status string) (bool, error)
Expand Down Expand Up @@ -286,7 +287,16 @@ func (impl *CiWorkflowRepositoryImpl) FindLastTriggeredWorkflowByArtifactId(ciAr
Select()
return workflow, err
}

func (impl *CiWorkflowRepositoryImpl) FindAllTriggeredWorkflowCountInLast24Hour() (ciWorkflowCount int, err error) {
cnt, err := impl.dbConnection.Model(&CiWorkflow{}).
ColumnExpr("DISTINCT ci_pipeline_id").
Where("started_on > ? ", time.Now().AddDate(0, 0, -1)).
Count()
if err != nil {
impl.logger.Errorw("error occurred while fetching ci workflow", "err", err)
}
return cnt, err
}
func (impl *CiWorkflowRepositoryImpl) FindAllLastTriggeredWorkflowByArtifactId(ciArtifactIds []int) (ciWorkflows []*CiWorkflow, err error) {
err = impl.dbConnection.Model(&ciWorkflows).
Column("ci_workflow.git_triggers", "ci_workflow.ci_pipeline_id", "CiPipeline", "cia.id").
Expand Down
18 changes: 12 additions & 6 deletions internal/sql/repository/pipelineConfig/PipelineRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ type PipelineRepository interface {
FindByIdsInAndEnvironment(ids []int, environmentId int) ([]*Pipeline, error)
FindActiveByAppIdAndEnvironmentIdV2() (pipelines []*Pipeline, err error)
GetConnection() *pg.DB
FindAllPipelineInLast24Hour() (pipelines []*Pipeline, err error)
FindAllPipelineCreatedCountInLast24Hour() (pipelineCount int, err error)
FindAllDeletedPipelineCountInLast24Hour() (pipelineCount int, err error)
FindActiveByEnvId(envId int) (pipelines []*Pipeline, err error)
FindActivePipelineByEnvId(envId int) (pipelines []*Pipeline, err error)
FindActiveByEnvIds(envId []int) (pipelines []*Pipeline, err error)
Expand Down Expand Up @@ -447,12 +448,17 @@ func (impl PipelineRepositoryImpl) FindByPipelineTriggerGitHash(gitHash string)
return pipelines, err
}

func (impl PipelineRepositoryImpl) FindAllPipelineInLast24Hour() (pipelines []*Pipeline, err error) {
err = impl.dbConnection.Model(&pipelines).
Column("pipeline.*").
func (impl PipelineRepositoryImpl) FindAllPipelineCreatedCountInLast24Hour() (pipelineCount int, err error) {
pipelineCount, err = impl.dbConnection.Model(&Pipeline{}).
Where("created_on > ?", time.Now().AddDate(0, 0, -1)).
Select()
return pipelines, err
Count()
return pipelineCount, err
}
func (impl PipelineRepositoryImpl) FindAllDeletedPipelineCountInLast24Hour() (pipelineCount int, err error) {
pipelineCount, err = impl.dbConnection.Model(&Pipeline{}).
Where("created_on > ? and deleted=?", time.Now().AddDate(0, 0, -1), true).
Count()
return pipelineCount, err
}
func (impl PipelineRepositoryImpl) FindActiveByEnvId(envId int) (pipelines []*Pipeline, err error) {
err = impl.dbConnection.Model(&pipelines).Column("pipeline.*", "App", "Environment").
Expand Down
Loading
Loading