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

CDSK-583 - add every sourcestamps to link in MyBuilds. CDSK-812 - add revision column #335

Merged
merged 7 commits into from
Mar 14, 2018

Conversation

warcholprzemo
Copy link

For now, I added next join into getLastBuildsOwnedBy.
I need to join to sourcestamps_tbl, because there are branch and codebase for a build.

Maybe we will change table to build_user and remove my join, but we need to add 2 extra columns there.
So this PR waits for #327 (new build_user table) and decision

@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 68.6% when pulling fe34ff7 on 1864-add-branch-into-MyBuilds into dda040b on staging.

@coveralls
Copy link

coveralls commented Mar 1, 2018

Coverage Status

Coverage increased (+0.003%) to 68.601% when pulling 81dc43c on 1864-add-branch-into-MyBuilds into e4ef439 on staging.

day_count = 7
example_data = [
fakedb.SourceStamp(id=1, branch="HEAD", sourcestampsetid=2, codebase="fmod"),
fakedb.SourceStamp(id=2, branch="trunk", sourcestampsetid=3, codebase="bar"),
Copy link
Member

Choose a reason for hiding this comment

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

Make sure to add a test for when there are multiple sourcestamps attached to a single sourcestampsetid

@warcholprzemo
Copy link
Author

One link with every sourcestamps <codebase>_branch=<branch> for every build

link_branch2

PS. Column with branch will be added in another PR.

@warcholprzemo warcholprzemo changed the title [WIP] CDS-1864 - add branch and codebase to link in MyBuilds CDSK-583 - add every sourcestamps (codebase, branch) to link in MyBuilds Mar 2, 2018
@@ -302,5 +302,6 @@ def _minimal_bdict(row, botmaster):
project=botmaster.getBuilderConfig(row.buildrequests_buildername).project,
slavename=row.builds_slavename,
submitted_at=mkdt(row.buildrequests_submitted_at),
complete_at=mkdt(row.buildrequests_complete_at)
complete_at=mkdt(row.buildrequests_complete_at),
sourcestampsetid=row.buildsets_sourcestampsetid,
Copy link

Choose a reason for hiding this comment

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

Are you sure we need it as minimal information?
I think the sourcestampsetid is required for only one method, so maybe we should add this information only there.

Copy link
Author

@warcholprzemo warcholprzemo Mar 2, 2018

Choose a reason for hiding this comment

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

_minimal_bdict is used only by getLastBuildsOwnedBy and I just added the line into existing code. I agree, that method is ugly because:

  • is staticmethod
  • is unnecessary

def thd(conn):
sourcestamps_tbl = self.db.model.sourcestamps

query = sa.select(columns=[sourcestamps_tbl.c.sourcestampsetid,
Copy link

Choose a reason for hiding this comment

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

A little problem with indention

Copy link
Author

Choose a reason for hiding this comment

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

Problem solved :-)

@@ -16,7 +17,21 @@ def content(self, req, cxt):
master.config.myBuildDaysCount,
)

cxt['builds'] = builds
builds_by_ssid = {}
Copy link

Choose a reason for hiding this comment

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

I am really not sure, that it is a correct place for this operation. As we can read from djangobook (https://djangobook.com/model-view-controller-design-pattern/), the controller should decide who can have access to the model and defer it to a template. This code, in my personal opinion, should be put in models.

Copy link
Author

Choose a reason for hiding this comment

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

In my opinion, the controller is a better place, because we can use DB functions again regardless final html code. In classical MVC (like Ruby on Rails) we can use more logic on view, but in Jinja this is ugly (we have to write dedicated tag / filter).

Maybe I should move this for-loop to another method and then I can test it.
@campos-ddc What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I don't really care, perhaps try to follow the same pattern that the rest of katana code uses (if there is any)

Copy link
Author

@warcholprzemo warcholprzemo left a comment

Choose a reason for hiding this comment

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

My answers :-)

def thd(conn):
sourcestamps_tbl = self.db.model.sourcestamps

query = sa.select(columns=[sourcestamps_tbl.c.sourcestampsetid,
Copy link
Author

Choose a reason for hiding this comment

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

Problem solved :-)

@@ -16,7 +17,21 @@ def content(self, req, cxt):
master.config.myBuildDaysCount,
)

cxt['builds'] = builds
builds_by_ssid = {}
Copy link
Author

Choose a reason for hiding this comment

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

In my opinion, the controller is a better place, because we can use DB functions again regardless final html code. In classical MVC (like Ruby on Rails) we can use more logic on view, but in Jinja this is ugly (we have to write dedicated tag / filter).

Maybe I should move this for-loop to another method and then I can test it.
@campos-ddc What do you think?

'branch': row.branch,
'codebase': row.codebase,
'revision': row.revision,
'short_revision': row.revision[:12],
Copy link

Choose a reason for hiding this comment

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

Why 12? Maybe we should move it to the configuration of the master? This twelve is a magic number.

Copy link
Member

Choose a reason for hiding this comment

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

That is what Katana is using right now (13 characters for "short" revision).

I do agree on the magic thing, so it should either be a constant somewhere (I bet that this magic 12 appears in other places), or configurable as Kamil said.

I don't see any benefit in changing the number, so if we did move it to some config, it would still be the same 12. That being the case, I think that a constant is probably enough.

@warcholprzemo warcholprzemo changed the title CDSK-583 - add every sourcestamps (codebase, branch) to link in MyBuilds CDSK-583 - add every sourcestamps to link in MyBuilds. CDSK-812 - add revision column Mar 12, 2018
@warcholprzemo
Copy link
Author

Revision column from merged PR:

revison-column

@warcholprzemo warcholprzemo merged commit 405c30b into staging Mar 14, 2018
@warcholprzemo warcholprzemo deleted the 1864-add-branch-into-MyBuilds branch March 14, 2018 09:07
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.

4 participants