Skip to content

Commit

Permalink
fixed issue where not all gists returned (upto 100,000 supported now)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielecook committed Jul 21, 2015
1 parent 61a36c9 commit 26ed32f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion gist.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ def main(wf):
else:
# Perform search
search = term + " " + search
results = gists[0:10]
results = gists

if show_results == True:
if search != "":
results = wf.filter(search, results, lambda x: x["description"] + ' '.join(x["tags"]) + ' '.join(x["files"].keys()))
for gist in results:
#print gists
for filename, f in gist["files"].items():
if lang == "" or f["language"] == lang:
wf.add_item(gist["description"],
Expand Down
8 changes: 5 additions & 3 deletions update_gists.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ def get_gist():
'Authorization': 'token %s' % token}

# Get Starred Gists
starred = web.post(url="https://api.github.com/gists/starred",headers=headers).json()
starred = web.post(url="https://api.github.com/gists/starred?per_page=100000",headers=headers).json()
starred_ids = [x["id"] for x in starred]

gists = web.post(url="https://api.github.com/users/{u}/gists".format(u=username),headers=headers).json()
gists = web.post(url="https://api.github.com/users/{u}/gists?per_page=100000".format(u=username),headers=headers).json()
gist_ids = [x["id"] for x in gists]

all_gists = list(set(starred_ids + gist_ids))
# Load gists:
gists = [web.post(url="https://api.github.com/gists/" + i,headers=headers).json() for i in all_gists]
#for i in gists:
# print i
# Check if starred
for gist in gists:
if gist["id"] in starred_ids:
Expand All @@ -34,6 +35,7 @@ def get_gist():
# gist["forked"] = True
#else:
# gist["forked"] = False

return gists


Expand Down

0 comments on commit 26ed32f

Please sign in to comment.