Skip to content

Commit 8f119e7

Browse files
authored
Merge pull request #42 from ArielMAJ/feat/#40/user-card
Feat/#40/user card
2 parents 34bd98f + 13574b0 commit 8f119e7

8 files changed

Lines changed: 328 additions & 22 deletions

File tree

api/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "api"
3-
version = "0.4.4"
3+
version = "0.5.0"
44
description = ""
55
authors = ["ArielMAJ <ariel.maj@hotmail.com>"]
66
readme = "README.md"

api/src/constants.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4958,3 +4958,38 @@
49584958
"web_commit_signoff_required": False,
49594959
},
49604960
]
4961+
4962+
USER_DATA = {
4963+
"login": "ArielMAJ",
4964+
"id": 69123486,
4965+
"node_id": "MDQ6VXNlcjY5MTIzNDg2",
4966+
"avatar_url": "https://avatars.githubusercontent.com/u/69123486?v=4",
4967+
"gravatar_id": "",
4968+
"url": "https://api.github.com/users/ArielMAJ",
4969+
"html_url": "https://github.com/ArielMAJ",
4970+
"followers_url": "https://api.github.com/users/ArielMAJ/followers",
4971+
"following_url": "https://api.github.com/users/ArielMAJ/following{/other_user}",
4972+
"gists_url": "https://api.github.com/users/ArielMAJ/gists{/gist_id}",
4973+
"starred_url": "https://api.github.com/users/ArielMAJ/starred{/owner}{/repo}",
4974+
"subscriptions_url": "https://api.github.com/users/ArielMAJ/subscriptions",
4975+
"organizations_url": "https://api.github.com/users/ArielMAJ/orgs",
4976+
"repos_url": "https://api.github.com/users/ArielMAJ/repos",
4977+
"events_url": "https://api.github.com/users/ArielMAJ/events{/privacy}",
4978+
"received_events_url": "https://api.github.com/users/ArielMAJ/received_events",
4979+
"type": "User",
4980+
"site_admin": False,
4981+
"name": "Ariel Menezes",
4982+
"company": "@ARTAdevs",
4983+
"blog": "https://ariel.artadevs.tech/",
4984+
"location": "Brazil",
4985+
"email": None,
4986+
"hireable": True,
4987+
"bio": "Computer Science graduate student, Full Stack Software Engineer, Data Scientist and Machine Learning researcher.",
4988+
"twitter_username": None,
4989+
"public_repos": 47,
4990+
"public_gists": 2,
4991+
"followers": 55,
4992+
"following": 108,
4993+
"created_at": "2020-08-02T20:32:35Z",
4994+
"updated_at": "2023-12-20T21:44:05Z",
4995+
}

api/src/main.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from fastapi.middleware.cors import CORSMiddleware
99
from loguru import logger
1010
from src.config import get_settings
11-
from src.constants import GH_REPOSITORIES
11+
from src.constants import GH_REPOSITORIES, USER_DATA
1212

1313
app = FastAPI()
1414
app.add_middleware(
@@ -20,9 +20,29 @@
2020
)
2121

2222

23-
@app.get("/{username}/{information}")
24-
async def data(username: str, information: str):
25-
gh_repositories = await get_paginated_data(username)
23+
@app.get("/{username}")
24+
async def user_data(username: str):
25+
if get_settings().ENVIRONMENT == "DEV":
26+
logger.debug("DEV MODE")
27+
await asyncio.sleep(random() * 5)
28+
return USER_DATA
29+
return requests.get(
30+
f"https://api.github.com/users/{username}",
31+
headers={
32+
"Accept": "application/vnd.github+json",
33+
"X-GitHub-Api-Version": "2022-11-28",
34+
},
35+
).json()
36+
37+
38+
@app.get("/{username}/repos/{amount}")
39+
async def repository_data(username: str, amount: int):
40+
return (await get_paginated_repository_data(username))[:amount]
41+
42+
43+
@app.get("/{username}/repos/plot/{information}")
44+
async def repository_plot_data(username: str, information: str):
45+
gh_repositories = await get_paginated_repository_data(username)
2646
return calc_repo_info_for_plotly(gh_repositories, information)
2747

2848

@@ -47,7 +67,7 @@ def calc_repo_info_for_plotly(gh_repositories, information: str):
4767
]
4868

4969

50-
async def get_paginated_data(username: str):
70+
async def get_paginated_repository_data(username: str):
5171
def parse_data(data):
5272
if data is None:
5373
return []
@@ -58,7 +78,7 @@ def parse_data(data):
5878
await asyncio.sleep(random() * 5)
5979
return GH_REPOSITORIES
6080

61-
url = f"https://api.github.com/users/{username}/repos"
81+
url = f"https://api.github.com/users/{username}/repos?sort=updated"
6282
next_pattern = re.compile(r'<([^>]+)>; rel="next"')
6383
pages_remaining = True
6484
data = []

vue-front/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "GitHub_Viz",
3-
"version": "0.4.4",
3+
"version": "0.5.0",
44
"private": true,
55
"scripts": {
66
"serve": "vue-cli-service serve",
@@ -9,6 +9,7 @@
99
},
1010
"dependencies": {
1111
"core-js": "^3.8.3",
12+
"moment": "^2.29.4",
1213
"plotly.js": "^1.44.4",
1314
"vue": "^3.2.13",
1415
"vuetify": "^3.4.8"

vue-front/src/App.vue

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,33 @@
1818
<!-- <v-btn
1919
class="white--text"
2020
color="primary"
21-
@click="pieChartModalOpen = !pieChartModalOpen"
21+
@click="cardOpen = !cardOpen"
2222
>Open Repository Visualization
2323
</v-btn> -->
24-
<PieChartModal
25-
v-if="pieChartModalOpen"
24+
<!-- <PieChartModal
25+
v-if="cardOpen"
2626
:username="this.username"
2727
:reload-watcher="this.reloadCount"
28+
/> -->
29+
<UserCard
30+
:username="this.username"
31+
:reload-watcher="this.reloadCount"
32+
v-if="cardOpen"
2833
/>
2934
</div>
3035
</template>
3136
<script>
32-
import PieChartModal from "./modals/PieChartModal.vue";
37+
import UserCard from "./components/UserCard.vue";
3338
import _ from "lodash";
3439
3540
export default {
3641
name: "app",
3742
components: {
38-
PieChartModal,
43+
UserCard,
3944
},
4045
data: function () {
4146
return {
42-
pieChartModalOpen: false,
47+
cardOpen: false,
4348
rules: {
4449
required: (value) => !!value || "Field is required",
4550
},
@@ -51,26 +56,21 @@ export default {
5156
search() {
5257
if (this.username !== "") {
5358
this.reloadCount++;
54-
this.pieChartModalOpen = true;
59+
this.cardOpen = true;
5560
}
5661
},
5762
},
5863
watch: {
5964
username: _.debounce(function () {
6065
if (this.username === "" || this.username === null) {
61-
this.pieChartModalOpen = false;
66+
this.cardOpen = false;
6267
}
6368
}, 2000),
6469
},
6570
};
6671
</script>
6772

6873
<style>
69-
* {
70-
margin: 0;
71-
padding: 0;
72-
}
73-
7474
.app {
7575
font-family: "Avenir", Helvetica, Arial, sans-serif;
7676
-webkit-font-smoothing: antialiased;
@@ -90,6 +90,9 @@ body {
9090
overflow-x: hidden;
9191
min-width: 100vw;
9292
max-width: 100vw;
93+
94+
margin: 0;
95+
padding: 0;
9396
}
9497
9598
.justify-center {

0 commit comments

Comments
 (0)