Skip to content
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

Remove the channel Iterator method from ActiavePipelines #175

Merged
merged 3 commits into from
Mar 1, 2019

Conversation

Skarlso
Copy link
Member

@Skarlso Skarlso commented Feb 27, 2019

Closes #163

@Skarlso Skarlso added the Needs Work The PR still requires some work from the submitter. label Feb 27, 2019
@codecov-io
Copy link

codecov-io commented Feb 27, 2019

Codecov Report

Merging #175 into master will increase coverage by 0.03%.
The diff coverage is 76.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #175      +/-   ##
==========================================
+ Coverage   66.78%   66.82%   +0.03%     
==========================================
  Files          33       33              
  Lines        2628     2607      -21     
==========================================
- Hits         1755     1742      -13     
+ Misses        650      642       -8     
  Partials      223      223
Impacted Files Coverage Δ
handlers/pipeline_run.go 0% <0%> (ø) ⬆️
workers/pipeline/create_pipeline.go 45.55% <0%> (+1.46%) ⬆️
handlers/hook.go 63.15% <100%> (+0.65%) ⬆️
workers/pipeline/git.go 72.13% <100%> (-0.31%) ⬇️
handlers/pipeline.go 56.25% <71.42%> (+2.3%) ⬆️
workers/pipeline/pipeline.go 93.96% <94.11%> (-1.42%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d37e5f8...2f26ee2. Read the comment docs.

@Skarlso Skarlso requested a review from michelvocks February 27, 2019 20:15
@Skarlso Skarlso added needs review and removed Needs Work The PR still requires some work from the submitter. labels Feb 27, 2019
@@ -97,7 +97,7 @@ func PipelineGetAll(c echo.Context) error {
var pipelines []gaia.Pipeline

// Get all active pipelines
for pipeline := range pipeline.GlobalActivePipelines.Iter() {
for _, pipeline := range pipeline.GlobalActivePipelines.Iter() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We get the full list of pipelines already. No need to copy that. Just return it.

@@ -438,7 +434,7 @@ func PipelineGetAllWithLatestRun(c echo.Context) error {
// Get all active pipelines
storeService, _ := services.StorageService()
var pipelines []gaia.Pipeline
for pipeline := range pipeline.GlobalActivePipelines.Iter() {
for _, pipeline := range pipeline.GlobalActivePipelines.Iter() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have the list of pipelines. I think there is no need to copy that.

@@ -178,7 +178,7 @@ func ValidatePipelineName(pName string) error {

// Check if pipeline name is already in use.
alreadyInUse := false
for activePipeline := range GlobalActivePipelines.Iter() {
for _, activePipeline := range GlobalActivePipelines.Iter() {
if strings.ToLower(s) == strings.ToLower(activePipeline.Name) {
alreadyInUse = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we found it we can break here

@@ -190,7 +190,7 @@ func updateAllCurrentPipelines() {
var allPipelines []gaia.Pipeline
var wg sync.WaitGroup
sem := make(chan int, 4)
for pipeline := range GlobalActivePipelines.Iter() {
for _, pipeline := range GlobalActivePipelines.Iter() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to copy the list again

close(c)
}()

func (ap *ActivePipelines) Iter() []gaia.Pipeline {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iter sounds like you get an iterator back. Maybe GetAll or ToSlice is better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michelvocks I didn't wanted to change the whole thing at once... I thought I'll keep the name for now, to see if anything breaks.

But something I didn't realise is that I'm already giving back a list. Why am I going over it again in some situations. :D Made no sense. thanks for spotting that.

I'll rename it. :)

@Skarlso Skarlso requested a review from michelvocks February 28, 2019 20:13
Copy link
Member

@michelvocks michelvocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ❤️

@michelvocks michelvocks merged commit 519a2be into gaia-pipeline:master Mar 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants