Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Graphe des assos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timothé Bailly-Barthez
Graphe des assos
Commits
0ad02275
Commit
0ad02275
authored
5 years ago
by
Timothé Bailly-Barthez
Browse files
Options
Downloads
Patches
Plain Diff
job's done
parent
fecf753e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
routes/index.js
+22
-4
22 additions, 4 deletions
routes/index.js
views/index.ejs
+20
-42
20 additions, 42 deletions
views/index.ejs
with
42 additions
and
46 deletions
routes/index.js
+
22
−
4
View file @
0ad02275
...
@@ -83,7 +83,21 @@ async function request_promotion(access_token, promotion, offset) {
...
@@ -83,7 +83,21 @@ async function request_promotion(access_token, promotion, offset) {
}
}
async
function
fetch_data
(
access_token
,
promotion
)
{
async
function
fetch_data
(
access_token
,
promotion_min
,
promotion_max
)
{
let
total_users
=
[]
let
changed
=
false
;
for
(
let
i
=
promotion_min
;
i
<=
promotion_max
;
i
++
)
{
let
result
=
await
fetch_data_promotion
(
access_token
,
i
)
total_users
=
total_users
.
concat
(
result
.
users
)
changed
=
changed
||
result
.
changed
}
return
{
users
:
total_users
,
changed
:
changed
};
}
async
function
fetch_data_promotion
(
access_token
,
promotion
)
{
// const token = await get_token()
// const token = await get_token()
let
offset
=
0
;
let
offset
=
0
;
...
@@ -167,10 +181,14 @@ function create_graph(users) {
...
@@ -167,10 +181,14 @@ function create_graph(users) {
/* GET the fetched data. */
/* GET the fetched data. */
router
.
post
(
'
/
'
,
function
(
req
,
res
,
next
)
{
router
.
post
(
'
/
'
,
function
(
req
,
res
,
next
)
{
const
promotion
=
req
.
body
.
promotion
||
2021
;
const
promotion_min
=
req
.
body
.
promotion_min
||
2021
;
fetch_data
(
req
.
session
.
access_token
,
promotion
)
const
promotion_max
=
req
.
body
.
promotion_max
||
2021
;
fetch_data
(
req
.
session
.
access_token
,
promotion_min
,
promotion_max
)
.
then
(
result
=>
{
.
then
(
result
=>
{
let
key
=
"
__express__graph_
"
+
promotion
;
let
key
=
"
__express__graph_
"
+
promotion_min
+
"
_
"
+
promotion_max
+
(
accepted_types
.
ASSOCIATION
?
"
_1
"
:
"
_0
"
)
+
(
accepted_types
.
CLUB
?
"
_1
"
:
"
_0
"
)
+
(
accepted_types
.
GROUPE
?
"
_1
"
:
"
_0
"
);
let
cached_graph
=
myCache
.
get
(
key
);
let
cached_graph
=
myCache
.
get
(
key
);
let
all_edges
;
let
all_edges
;
let
all_nodes
;
let
all_nodes
;
...
...
This diff is collapsed.
Click to expand it.
views/index.ejs
+
20
−
42
View file @
0ad02275
...
@@ -29,10 +29,12 @@
...
@@ -29,10 +29,12 @@
const
[
allNodes
,
setAllNodes
]
=
React
.
useState
([]);
const
[
allNodes
,
setAllNodes
]
=
React
.
useState
([]);
const
[
allEdges
,
setAllEdges
]
=
React
.
useState
([]);
const
[
allEdges
,
setAllEdges
]
=
React
.
useState
([]);
const
[
promotionMin
,
setPromotionMin
]
=
React
.
useState
(
2021
);
const
[
promotionMax
,
setPromotionMax
]
=
React
.
useState
(
2021
);
const
[
nodeMin
,
setNodeMin
]
=
React
.
useState
(
10
);
const
[
nodeMin
,
setNodeMin
]
=
React
.
useState
(
10
);
const
[
edgeMin
,
setEdgeMin
]
=
React
.
useState
(
5
);
const
[
edgeMin
,
setEdgeMin
]
=
React
.
useState
(
5
);
const
[
promotion
,
setPromotion
]
=
React
.
useState
(
2021
);
const
[
submitted
,
setSubmitted
]
=
React
.
useState
(
true
);
const
[
submitted
,
setSubmitted
]
=
React
.
useState
(
true
);
const
[
ready
,
setReady
]
=
React
.
useState
(
false
);
const
[
ready
,
setReady
]
=
React
.
useState
(
false
);
...
@@ -44,14 +46,17 @@
...
@@ -44,14 +46,17 @@
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
setReady
(
false
);
setReady
(
false
);
setError
(
false
);
setError
(
false
);
axios
.
post
(
'
/
'
,
{
promotion
:
promotion
})
axios
.
post
(
'
/
'
,
{
promotion_min
:
promotionMin
,
promotion_max
:
promotionMax
})
.
then
(
result
=>
{
.
then
(
result
=>
{
setAllEdges
(
result
.
data
.
all_edges
);
setAllEdges
(
result
.
data
.
all_edges
);
setAllNodes
(
result
.
data
.
all_nodes
);
setAllNodes
(
result
.
data
.
all_nodes
);
setReady
(
true
);
setReady
(
true
);
})
})
.
catch
(
err
=>
setError
(
true
))
.
catch
(
err
=>
setError
(
true
))
},
[
promotion
])
},
[
promotion
Min
,
promotionMax
])
function
handleSubmit
(
event
)
{
function
handleSubmit
(
event
)
{
...
@@ -85,8 +90,12 @@
...
@@ -85,8 +90,12 @@
return
(
return
(
<
form
onSubmit
=
{
handleSubmit
}
>
<
form
onSubmit
=
{
handleSubmit
}
>
<
div
>
<
div
>
<
label
htmlFor
=
"
promotion
"
>
Promotion
:
<
/label
>
<
label
htmlFor
=
"
promotionMin
"
>
Promotion
minimale
:
<
/label
>
<
input
type
=
"
number
"
id
=
"
promotion
"
value
=
{
promotion
}
onChange
=
{
e
=>
setPromotion
(
e
.
target
.
value
)}
/
>
<
input
type
=
"
number
"
id
=
"
promotionMin
"
value
=
{
promotionMin
}
onChange
=
{
e
=>
setPromotionMin
(
e
.
target
.
value
)}
/
>
<
/div
>
<
div
>
<
label
htmlFor
=
"
promotionMax
"
>
Promotion
maximale
:
<
/label
>
<
input
type
=
"
number
"
id
=
"
promotionMax
"
value
=
{
promotionMax
}
onChange
=
{
e
=>
setPromotionMax
(
e
.
target
.
value
)}
/
>
<
/div
>
<
/div
>
<
div
>
<
div
>
<
label
htmlFor
=
"
nodeMin
"
>
Taille
minimale
:
<
/label
>
<
label
htmlFor
=
"
nodeMin
"
>
Taille
minimale
:
<
/label
>
...
@@ -96,6 +105,7 @@
...
@@ -96,6 +105,7 @@
<
label
htmlFor
=
"
edgeMin
"
>
Consanguinité
:
<
/label
>
<
label
htmlFor
=
"
edgeMin
"
>
Consanguinité
:
<
/label
>
<
input
type
=
"
number
"
id
=
"
edgeMin
"
value
=
{
edgeMin
}
onChange
=
{
e
=>
setEdgeMin
(
e
.
target
.
value
)}
/
>
<
input
type
=
"
number
"
id
=
"
edgeMin
"
value
=
{
edgeMin
}
onChange
=
{
e
=>
setEdgeMin
(
e
.
target
.
value
)}
/
>
<
/div
>
<
/div
>
<
button
type
=
"
submit
"
>
Générer
<
/button
>
<
button
type
=
"
submit
"
>
Générer
<
/button
>
{
error
{
error
?
<
p
style
=
{{
color
:
"
red
"
}}
>
Erreur
<
/p
>
?
<
p
style
=
{{
color
:
"
red
"
}}
>
Erreur
<
/p
>
...
@@ -109,39 +119,6 @@
...
@@ -109,39 +119,6 @@
ReactDOM
.
render
(
React
.
createElement
(
FormComponent
),
document
.
getElementById
(
'
form
'
));
ReactDOM
.
render
(
React
.
createElement
(
FormComponent
),
document
.
getElementById
(
'
form
'
));
function
draw
()
{
var
container
=
document
.
getElementById
(
'
mynetwork
'
);
axios
.
post
(
'
/
'
,
{
promotion
:
2022
})
.
then
(
result
=>
{
all_nodes
=
result
.
data
.
all_nodes
;
all_edges
=
result
.
data
.
all_edges
;
let
nodes
=
[];
all_nodes
.
forEach
(
node
=>
{
if
(
node
.
value
>=
5
)
{
nodes
.
push
(
node
);
}
})
let
edges
=
[];
all_edges
.
forEach
(
edge
=>
{
if
(
edge
.
value
>=
3
)
{
edges
.
push
(
edge
);
}
})
var
data
=
{
nodes
:
nodes
,
edges
:
edges
};
var
options
=
{
nodes
:
{
shape
:
'
dot
'
,
}
};
let
network
=
new
vis
.
Network
(
container
,
data
,
options
);
})
.
catch
(
err
=>
console
.
log
(
err
))
}
</script>
</script>
</head>
</head>
...
@@ -149,10 +126,11 @@
...
@@ -149,10 +126,11 @@
<h1><
%=
title
%
></h1>
<h1><
%=
title
%
></h1>
<p>
<p>
<b>
Comment ça marche ?
</b><br>
<b>
Comment ça marche ?
</b><br>
Lorsqu'on arrive sur le site ou que l'on change la promotion, le site charge les données liées à la promotion.
<br>
Lorsqu'on arrive sur le site ou que l'on change l'une des promotions, le site charge les données liées aux promotions.
<br>
Quand le champ de texte sous le menu des promotions indique prêt, vous pouvez générer le graphe en cliquant sur le bouton Générer ci-dessous.
<br>
Quand le champ de texte sous le menu indique prêt, vous pouvez générer le graphe en cliquant sur le bouton Générer ci-dessous.
<br>
Vous pouvez modifier la taille des assos ainsi que la consanguinité minimales, puis générer le graphe à nouveau.
</br>
Les promotions prises en compte seront les promotions situées entre la promotion minimale et la promotion maximale (inclusion large)
<br>
Tu peux déplacer le graphe ou zoomer dessus pour voir les détails.
Vous pouvez modifier la taille des assos ainsi que la consanguinité minimales, puis générer le graphe à nouveau.
<br>
Vous pouvez déplacer le graphe ou zoomer dessus pour voir les détails.
</p>
</p>
<div
id=
"form"
></div>
<div
id=
"form"
></div>
<div
id=
"mynetwork"
></div>
<div
id=
"mynetwork"
></div>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment