-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTODO.txt
51 lines (46 loc) · 1.3 KB
/
TODO.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Firebase security
//tous le monde peux lire les config
//le reste, uniquement l'app de trigger
{
"rules": {
"websites":{
"$website": {
"config": {
".read": "true"
},
"users": {
".read": "$uid === auth.uid"
}
}
}
".read": "false",
".write": "true"
}
}
//Query
firebase().database().ref('/websites/kiloutou_fr/users').on('value', function (snapshot) {
var users = snapshot.val(),
baskets = 0,
values = 0,
nbUsers = 0,
nbSessions = 0;
for (var user in users){
if(users.hasOwnProperty(user)){
nbUsers = nbUsers++;
for(var session in user.sessions){
if(user.sessions.hasOwnProperty(session)){
nbSessions = nbSessions++;
if(session.basket && session.basket.total){
baskets = basket++;
values = values + session.basket.total;
}
}
}
}
}
console.log("Nb users: ", nbUsers);
console.log("Nb Sessions: ", nbSessions);
console.log("Nb Baskets: ", baskets);
console.log("Total Baskets Value: ", values);
console.log("Average basket value: ", values / baskets);
});