QualiSystems / FluentTc

:ocean: :two_men_holding_hands: :office: Integrate with TeamCity fluently
https://www.nuget.org/packages/fluenttc
Apache License 2.0
44 stars 36 forks source link

Custom implementation of IBuildIncludeBuilder #81

Closed bezysoftware closed 8 years ago

bezysoftware commented 8 years ago

Hi,

I would like to have more fields fetched when getting a list of builds, but the API only allows me to add these 4:

  public interface IBuildIncludeBuilder
  {
    IBuildIncludeBuilder IncludeStartDate();

    IBuildIncludeBuilder IncludeFinishDate();

    IBuildIncludeBuilder IncludeStatusText();

    IBuildIncludeBuilder IncludeDefaults();
  }

I would like to, for example, modify the defaults (or even better, have a method which would have name of the field as input).

I thought about having custom implementation of IBuildIncludeBuilder but I don't know how I would give that to the ConnectedTc.

borismod commented 8 years ago

@bezysoftware what additional fields would you like to retrieve?

bezysoftware commented 8 years ago

I would like to have "revisions" fetched as well. I managed to use reflection and inject the "revisions" parameter into the BuildIncludeBuilder but the revisions aren't parsed properly, even though I see them in Fiddler (I hoped they would be parsed and stored in Changes property of IBuild

borismod commented 8 years ago

What do you mean by revisions? Changes?

There is a way to retrieve last build that satisfies a condition with changes:

var teamCitybuild = connectedTc.GetLastBuild(having => having.Id(build.Id),
                            with => with.IncludeChanges(and => and.IncludeComment()));

Does it satisfy your requirements?

bezysoftware commented 8 years ago

Yes, changes. And no, that is not enough for me - I need to get a list of builds, each one with the list of changes. I can see that GetLastBuild actually does 2 queries to achieve that, but there is way to do it with just 1:

/httpAuth/app/rest/builds?locator=status:SUCCESS,count:10,&fields=count,build(buildTypeId,href,id,number,state,status,webUrl,revisions)

By including "revisions" among the requested fields, you get similar results:

"build":[  
      {  
         "id":6615502,
         "buildTypeId":"xxxxxx",
         "number":"xxxxxx",
         "status":"SUCCESS",
         "state":"finished",
         "href":"/httpAuth/app/rest/builds/id:6615502",
         "webUrl":"http://xxxxx/viewLog.html?buildId=6615502&buildTypeId=xxxxxx",
         "revisions":{  
            "count":1,
            "revision":[  
               {  
                  "version":"10063450",
                  "vcs-root-instance":{  
                  }
               }
            ]
         }
      }
borismod commented 8 years ago

I see. It can be impemented by adding IncludeRevisions() method in IBuildIncludeBuilder interface and implementing it as you described. There is no need to implement custom implementation of the IBuildIncludeBuilder as interfaces are used in this project for a little bit different purposes. Having a method that receive a name of the field is not a good idea. We at @QualiSystems/fluenttc try to have easy to learn and fluent syntax, that should auto-complete with the names of the fields and entities. Let's try to keep it fluent as it is.

Can you please submit a PR with your suggested changes?

bezysoftware commented 8 years ago

I submitted the PR

borismod commented 8 years ago

I accepted it. I've just noticed that the coverage is lightly lower. Not something critical

Boris Modylevsky

Agile Developer & Coach

Mobile: +972-526-377-300

Email: borismod@gmail.com

Blog: www.borismod.net

Twitter: https://twitter.com/bormod

Github: https://github.com/borismod

On Tue, Nov 15, 2016 at 12:18 PM, Tomas Bezouska notifications@github.com wrote:

I submitted the PR

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/QualiSystems/FluentTc/issues/81#issuecomment-260602667, or mute the thread https://github.com/notifications/unsubscribe-auth/AAM0M4r5zQeZp89vJ-m29PQzrU6toU56ks5q-YbzgaJpZM4KQAV6 .