Skip to content

Commit cbf4085

Browse files
authored
Merge pull request #7 from ArielMAJ/fix/concurrency
Fix/concurrency
2 parents 4395f62 + dec8dbe commit cbf4085

4 files changed

Lines changed: 9 additions & 14 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.2.0"
3+
version = "0.2.1"
44
description = ""
55
authors = ["ArielMAJ <ariel.maj@hotmail.com>"]
66
readme = "README.md"

api/src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def data(username: str):
3737
"hole": ".4",
3838
}
3939
]
40-
await asyncio.sleep(3)
40+
await asyncio.sleep(random() * 7)
4141
return {"forks": forks}
4242

4343

vue-front/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "docs",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"private": true,
55
"scripts": {
66
"serve": "vue-cli-service serve",

vue-front/src/App.vue

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,20 @@ export default {
4545
},
4646
async mounted() {
4747
try {
48-
const [data1, data2, data3] = await Promise.all([
49-
this.fetchData(),
50-
this.fetchData(),
51-
this.fetchData(),
52-
]);
48+
this.fetchData('a').then((data) => data.json()).then(json => this.plotInfo1.data = json.forks)
49+
this.fetchData('b').then((data) => data.json()).then(json => this.plotInfo2.data = json.forks)
50+
this.fetchData('c').then((data) => data.json()).then(json => this.plotInfo3.data = json.forks)
5351
54-
this.plotInfo1.data = (await data1.json()).forks;
55-
this.plotInfo2.data = (await data2.json()).forks;
56-
this.plotInfo3.data = (await data3.json()).forks;
5752
} catch (error) {
5853
console.error("Error fetching data:", error);
5954
}
6055
},
6156
methods: {
62-
async fetchData() {
57+
async fetchData(username) {
6358
try {
64-
console.log("Fetching data...");
59+
console.log("Fetching data...", process.env.VUE_APP_BACKEND_ROOT_ENDPOINT + `${username}/repos` );
6560
return fetch(
66-
process.env.VUE_APP_BACKEND_ROOT_ENDPOINT + "ArielMAJ/repos"
61+
process.env.VUE_APP_BACKEND_ROOT_ENDPOINT + `${username}/repos`
6762
);
6863
} catch (error) {
6964
console.error("Error fetching data:", error);

0 commit comments

Comments
 (0)