its-rigs / Trolly

A Python wrapper around the Trello API. Provides a group of Python classes to represent Trello Objects. All classes come with basic Trello API method calls and are easily extensible to suit your needs. See the README for more details.
MIT License
100 stars 29 forks source link

Quote or Bug? #5

Closed ColorfullyTyler closed 11 years ago

ColorfullyTyler commented 11 years ago

It seems that I can only pull 50 records, be they cards, lists, checklists, etc. I cant find confirmation from Trello that there is in fact a quota, and so I am throwing the ball into your court. Any idea why I would be unable to pull more than 50 records? This is great work btw. I prefer python and this is very helpful for the project I am undertaking. Thanks for the help

its-rigs commented 11 years ago

Glad you like the work :) I've had a look at the Trello API and it appears that some API calls do have a limit that defaults to 50. This only appears to be when pulling actions though. On the test I did for one of our boards, pulling all cards (archived and visible) I got a result of 988 cards. Do you have an example of the code you are using to pull the cards?

ColorfullyTyler commented 11 years ago

That makes sense because I extended Trolly to also have a class for Actions. I pretty much just cloned the Cards class and refactored it for actions, and I added the appropriate methods to Client and TrelloObjects and Boards. It works fine but I couldn't figure out why it was limiting me to only 50 actions. My Trello account doesn't have more than 50 lists or cards so I couldn't test that, I just assumed the problem was agnostic to item being pulled. But apparently you're saying there is a quota for actions specifically? Could you link me to that? I looked and looked through their api documentation site and couldn't find anything. 

I'm pulling actions because I want to keep my Trello board in sync with a legacy project management tool that my company uses. Actions have dates on them and cards don't, which is a problem for me.

Anyways, is there an easy way to set the default actions quota to something more like 1,000?

Colorfully, Tyler Greene

On Wed, Apr 10, 2013 at 4:33 AM, Luke Rigby notifications@github.com wrote:

Glad you like the work :)

I've had a look at the Trello API and it appears that some API calls do have a limit that defaults to 50. This only appears to be when pulling actions though. On the test I did for one of our boards, pulling all cards (archived and visible) I got a result of 988 cards. Do you have an example of the code you are using to pull the cards?

Reply to this email directly or view it on GitHub: https://github.com/plish/Trolly/issues/5#issuecomment-16168799

its-rigs commented 11 years ago

I see, glad it wasn't to difficult to extend! I have just noticed that on the get cards methods on Trello there does appear to be a limit of 1000. If you go to the API documentation and go to either Board, List or Card and search for limit you will find options to set the limit of actions and cards you pull. The actions appear to have a page option as well. The get cards methods limit has no default but does have the option to set 1-1000. I can only assume that this means that the limit is 1000... Like you said originally there is not specific document that states the max number of values returned. Although looking at some of the Google API's I've been using at work 1000 seems to be the standard limit. Though there is no page size for cards.

Hopefully all that makes sense?

To set the limit of pulling actions for a card: If you are using the URL /1/cards/[card id or shortlink]/actions Then you can pass the query parameters as { 'limit': 1000 } or { 'limit': 1000, 'page': 1 }

Is "colourfully" the way you sign of or your company?

L

ColorfullyTyler commented 11 years ago

I see that now. That does make sense. Although I don't see a limit appearing under Action (https://trello.com/docs/api/action/index.html). I will try passing that parameter in anyways though to see if it solves the problem. Where would I pass this query_param in? Currently I am instantiating Board, and then running actions_list = board.getActions(). Note that "getActions" is a method that I created, which follows the same conventions that youve put in place with Trolly. Running this delivers the JSON of actions for the board I want, but it doesn't look like getActions takes query_params as an input. Do you suggest a different way of going about this?

I guess my initial approach was to pull actions first, and then associate cards to those actions when I need information on the card, as opposed to pulling cards first and then looking up the actions associated with them. The latter approach seems like it would get around the 50 limit issue but it would mean that I need to look at the actions for every card and could be less efficient. Does that make sense?

"colorfully" is just a personal brand thing. My last name is Greene, so its kind of a play on that. Its both my signature as well as my website (which is not yet available publicly). Maybe it will be a company someday!

On Wed, Apr 10, 2013 at 1:02 PM, Luke Rigby notifications@github.comwrote:

I see, glad it wasn't to difficult to extend! I have just noticed that on the get cards methods on Trello there does appear to be a limit of 1000. If you go to the API documentation and go to either Board, List or Card and search for limit you will find options to set the limit of actions and cards you pull. The actions appear to have a page option as well. The get cards methods limit has no default but does have the option to set 1-1000. I can only assume that this means that the limit is 1000... Like you said originally there is not specific document that states the max number of values returned. Although looking at some of the Google API's I've been using at work 1000 seems to be the standard limit. Though there is no page size for cards.

Hopefully all that makes sense?

To set the limit of pulling actions for a card: If you are using the URL /1/cards/[card id or shortlink]/actions Then you can pass the query parameters as { 'limit': 1000 } or { 'limit': 1000, 'page': 1 }

Is "colourfully" the way you sign of or your company?

L

— Reply to this email directly or view it on GitHubhttps://github.com/plish/Trolly/issues/5#issuecomment-16198315 .

Colorfully, Tyler Greene

ColorfullyTyler commented 11 years ago

Actually I got it to work. In TrelloObject, I changed getActionsJson to read as follows:

def getActionsJson( self, base_uri ): return self.fetchJson( base_uri + '/actions' , query_params = {'limit': 1000})

and it totally works. Thanks for you help. This is really great work and super helpful for me. I dont have a lot of coding experience, but your API wrapper was very clear and organized which made it easier for me. In fact before this I didn't really know much about classes and methods, so this was a great learning experience. Sorry for flagging this as a bug. I didnt how else to get your attention! haha.

On Wed, Apr 10, 2013 at 2:24 PM, Tyler Greene colorfullytyler@gmail.comwrote:

I see that now. That does make sense. Although I don't see a limit appearing under Action (https://trello.com/docs/api/action/index.html). I will try passing that parameter in anyways though to see if it solves the problem. Where would I pass this query_param in? Currently I am instantiating Board, and then running actions_list = board.getActions(). Note that "getActions" is a method that I created, which follows the same conventions that youve put in place with Trolly. Running this delivers the JSON of actions for the board I want, but it doesn't look like getActions takes query_params as an input. Do you suggest a different way of going about this?

I guess my initial approach was to pull actions first, and then associate cards to those actions when I need information on the card, as opposed to pulling cards first and then looking up the actions associated with them. The latter approach seems like it would get around the 50 limit issue but it would mean that I need to look at the actions for every card and could be less efficient. Does that make sense?

"colorfully" is just a personal brand thing. My last name is Greene, so its kind of a play on that. Its both my signature as well as my website (which is not yet available publicly). Maybe it will be a company someday!

On Wed, Apr 10, 2013 at 1:02 PM, Luke Rigby notifications@github.comwrote:

I see, glad it wasn't to difficult to extend! I have just noticed that on the get cards methods on Trello there does appear to be a limit of 1000. If you go to the API documentation and go to either Board, List or Card and search for limit you will find options to set the limit of actions and cards you pull. The actions appear to have a page option as well. The get cards methods limit has no default but does have the option to set 1-1000. I can only assume that this means that the limit is 1000... Like you said originally there is not specific document that states the max number of values returned. Although looking at some of the Google API's I've been using at work 1000 seems to be the standard limit. Though there is no page size for cards.

Hopefully all that makes sense?

To set the limit of pulling actions for a card: If you are using the URL /1/cards/[card id or shortlink]/actions Then you can pass the query parameters as { 'limit': 1000 } or { 'limit': 1000, 'page': 1 }

Is "colourfully" the way you sign of or your company?

L

— Reply to this email directly or view it on GitHubhttps://github.com/plish/Trolly/issues/5#issuecomment-16198315 .

Colorfully, Tyler Greene

Colorfully, Tyler Greene

its-rigs commented 11 years ago

Yeah that is pretty much how I'd do it. Depending on whether you need to be messing about with each action I would be tempted to create and Action class similar to the others and cast each JSON object to that, but that depends on what you are trying to do. Also I would be inclined to pass limit as a variable, defaulted to 1000, you never know when you may want to change it:

def getActionsJson( self, base_uri, limit = 1000 ): return self.fetchJson( base_uri + '/actions' , query_params = {'limit': limit})

Also if you check out https://trello.com/docs/api/board/index.html#get-1-boards-board-id-actions, there is an option to pass "filter" as a parameter. This would probably be helpful to cut the actions down to what you actually need as oppose to pulling everything:

def getActionsJson( self, base_uri, limit = 1000 ): return self.fetchJson( base_uri + '/actions' , query_params = {'limit': limit, 'filter': 'commentCard, copyCommentCard, ...'})

Regarding the speed of pulling cards or actions first I couldn't really say. I would say just try it out for both and see how it goes.

Glad it helped, like things to be clear and organised! Should probably see someone about that :) Always good when someone finds it useful though!

I'm going to close this but if you have anymore questions etc just post on here again.

L