Skip to content

Commit

Permalink
Fix bug with fetching contributors twice for guides that do not have any
Browse files Browse the repository at this point in the history
- This bug increased our API usage because it requested the list of
  contributors twice instead of only once for guides that did not have any
  contributors.  The underlying Article object had no distinction between the
  two states, 'requested and found no contributors' and 'have not requested
  yet'.  So we would send 2 extra API requests for every guide that did not
  have contributors, which is most likely the majority of our guides at this
  point.
    - The reason it takes 2 requests to get the contributors is we have to look
      in the published and in-review directories since that's how the API
      tracks commits.  The github API doesn't support the --follow parameter of
      command-line git.
  • Loading branch information
durden committed Apr 27, 2016
1 parent cffd8b0 commit e848a87
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pskb_website/models/article.py
Expand Up @@ -897,7 +897,7 @@ def __init__(self, title, author_name, filename=ARTICLE_FILENAME,

# List of User objects representing any 'author' i.e user who has
# contributed at least 1 line of text to this article.
self._contributors = []
self._contributors = None

@property
def path(self):
Expand Down Expand Up @@ -945,7 +945,7 @@ def contributors(self):
# NOTE: This could result in some data out of data if we have new
# contributors after this is called but contributor information isn't
# super important so should be ok.
if self._contributors:
if self._contributors is not None:
return self._contributors

self._read_contributors_from_api()
Expand Down

0 comments on commit e848a87

Please sign in to comment.