Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

[WIP] Only denormalize a build if it's the most recent #318

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Aaron1011
Copy link
Contributor

Don't merge this yet.

@@ -34,6 +35,15 @@ module States
# end
end

def most_recent_build?
Build.order(created_at: :desc).first.id == id
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@henrikhodne: Will this only find builds for the current repository? Is there a way to make this more efficient?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, this is a global query. Something like repository.builds.last would probably be better, although I'm not 100% sure if that's the most efficient query or correct.

@Aaron1011
Copy link
Contributor Author

@henrikhodne: Does this look good?

@sarahhodne
Copy link
Contributor

I think this is correct and makes sense, but I'd like for someone else to look over this as well.

@Aaron1011
Copy link
Contributor Author

@henrikhodne: Actually, I need to fix PR #319 first.

@Aaron1011
Copy link
Contributor Author

@henrikhodne: I've fixed the other PR now. I think it's ready to merge.

@@ -194,6 +194,10 @@ def pull_request?
event_type == 'pull_request'
end

def most_recent_build?
repository.builds.last.id == id
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this is right. This is the most recently created build, but it could be a PR build, it could be a branch build, etc. If we are to use this as some query for when to set the repository status, I think it should find the "latest build that is on the default branch and isn't a pull request build. Then it would look something like this, I think:

repository.builds.where(branch: repository.default_branch, event_type: "push").last.id

In that case, the method should probably be renamed too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@henrikhodne: I agree. I've updated the commit.

@@ -194,6 +194,10 @@ def pull_request?
event_type == 'pull_request'
end

def last_created_build?
repository.builds.where(branch: repository.default_branch, event_type: "push").last.id
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be a comparison instead, right now it just fetches the last build's ID.

Also, I feel like this method is doing a bit much right now and that some of this should probably go in the repository model instead. Maybe Repository#last_build_on_default_branch and then check if this build is the same as that build?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@henrikhodne: Good catch. I've changed it.

@sarahhodne
Copy link
Contributor

@Aaron1011 Awesome, thank you. I fixed the specs and merged this in 68c1088.

@@ -22,7 +22,7 @@ def denormalize(event, *args)
}

def denormalize?(event)
DENORMALIZE.key?(event)
DENORMALIZE.key?(event) && last_build_on_default_branch?
Copy link
Contributor

Choose a reason for hiding this comment

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

@henrikhodne does this mean we only denormalize builds on the default branch? This is going to be confusing in the UI as a pusher event will come through for a PR build and update the side bar, but then if you refresh you won't see that update as the build was not denormalized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joshk: Where does travis-web update the sidebar? Looking at the receive method, it doesn't seem to do much when a build:started event comes in.

@BanzaiMan
Copy link
Contributor

I reverted this commit. See 183d8f1.

@BanzaiMan BanzaiMan reopened this Jan 29, 2014
@sarahhodne
Copy link
Contributor

So the denormalization logic is in travis-web as well?

@joshk
Copy link
Contributor

joshk commented Jan 29, 2014

no, but it is partially tied to the UI. This has been the issue with our UI for a long time, and why we looked at changes which then became labs.

@roidrage
Copy link
Contributor

How could we proceed here? There'd be changes required in travis-web as well?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants