diff --git a/lib/app/user.ex b/lib/app/user.ex index c5b573e..a7c7d6d 100644 --- a/lib/app/user.ex +++ b/lib/app/user.ex @@ -48,7 +48,7 @@ defmodule App.User do client = Tentacat.Client.new(%{access_token: token}) {200, data, _res} = Tentacat.Organizations.Members.list(client, org_name) - dbg(data) + # dbg(data) Useful.atomize_map_keys(data) end @@ -56,7 +56,12 @@ defmodule App.User do token = Envar.get("GH_PERSONAL_ACCESS_TOKEN") client = Tentacat.Client.new(%{access_token: token}) {200, data, _res} = Tentacat.Users.find(client, username) - Useful.atomize_map_keys(data) + {:ok, entry} = Useful.atomize_map_keys(data) + |> dbg + |> map_github_user_fields_to_table() + |> create() + + entry end # Next: get list of org members @@ -64,9 +69,24 @@ defmodule App.User do # map data to our table # insert data - def map_github_user_fieldsre(entry) do + def map_github_user_fields_to_table(u) do %{ - + id: u.id, + avatar_url: String.split(u.avatar_url, "?") |> List.first, + bio: u.bio, + blog: u.blog, + company: String.replace(u.company, "@", ""), + created_at: u.created_at, + email: u.email, + followers: u.followers, + following: u.following, + hireable: u.hireable, + location: u.location, + login: u.login, + name: u.name, + public_repos: u.public_repos, + two_factor_authentication: false, + updated_at: u.updated_at } end diff --git a/test/app/user_test.exs b/test/app/user_test.exs index d9e485d..1d09539 100644 --- a/test/app/user_test.exs +++ b/test/app/user_test.exs @@ -27,7 +27,7 @@ defmodule App.UserTest do end test "get_org_members_from_api/1" do - App.User.get_org_members_from_api("dwyl") |> dbg + App.User.get_org_members_from_api("dwyl") # |> dbg assert true == true end @@ -36,3 +36,39 @@ defmodule App.UserTest do assert data.public_repos > 30 end end + +%{ + organizations_url: "https://api.github.com/users/iteles/orgs", + following: 80, + login: "iteles", + public_repos: 31, + received_events_url: "https://api.github.com/users/iteles/received_events", + bio: "Co-founder @dwyl \r\n", + user_view_type: "public", + company: "@dwyl", + gravatar_id: "", + twitter_username: nil, + following_url: "https://api.github.com/users/iteles/following{/other_user}", + created_at: "2013-04-17T21:10:06Z", + followers: 400, + site_admin: false, + blog: "http://www.twitter.com/iteles", + starred_url: "https://api.github.com/users/iteles/starred{/owner}{/repo}", + public_gists: 0, + hireable: true, + gists_url: "https://api.github.com/users/iteles/gists{/gist_id}", + events_url: "https://api.github.com/users/iteles/events{/privacy}", + followers_url: "https://api.github.com/users/iteles/followers", + node_id: "MDQ6VXNlcjQxODUzMjg=", + url: "https://api.github.com/users/iteles", + id: 4185328, + name: "Ines Teles Correia", + subscriptions_url: "https://api.github.com/users/iteles/subscriptions", + html_url: "https://github.com/iteles", + location: "London, UK", + type: "User", + avatar_url: "https://avatars.githubusercontent.com/u/4185328?v=4", + email: nil, + repos_url: "https://api.github.com/users/iteles/repos", + updated_at: "2024-08-05T22:59:09Z" +}