Skip to content
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.

Commit

Permalink
Add word counter for PR and issues
Browse files Browse the repository at this point in the history
  • Loading branch information
carlogilmar committed Sep 22, 2019
1 parent 371bf3c commit 23de53a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/spawnfest/github/github_data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ defmodule GitHubData do
|> Enum.map(fn {builder, args} -> apply_execution(builder, args) end)
|> Enum.map(fn builder -> Task.async(builder) end)
|> Enum.map(fn task -> Task.await(task, 9000) end)

[repo, issues, prs, contributors] = res
issues_words = GitHubUtil.get_most_used_words(issues)
pr_words = GitHubUtil.get_most_used_words(prs)
[repo, issues, prs, contributors, issues_words, pr_words]
end

defp apply_execution(fun, args), do: fn -> fun.(args) end
Expand Down
7 changes: 7 additions & 0 deletions lib/spawnfest/utils/github_util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ defmodule GitHubUtil do
desc -> desc
end
end

def get_most_used_words(structs) do
titles = for struct <- structs, do: struct.title
words = for title <- titles, do: String.split(title, " ")
words = List.flatten(words)
Utils.get_words_counters(words)
end
end

0 comments on commit 23de53a

Please sign in to comment.