statistique register

This commit is contained in:
2024-04-03 17:32:37 +02:00
parent f30595ebec
commit 487c1435b4
2 changed files with 62 additions and 0 deletions

View File

@@ -27,7 +27,28 @@ Notifications.get = (alias, tribeId) => {
data: { notif: [{ tribeId, msg }] },
};
};
/**
* Get statistic of registering email phone
*/
Notifications.statmaillist=(tribe)=>{
const statinfo={}
const src=`../../${tribe}/objects/maillinglists/*.json`
console.log(path.resolve(src))
glob.sync(src).forEach(f=>{
const name=path.basename(f,".json");
const mlst=fs.readJSONSync(f)
Object.keys(mlst).forEach(c=>{
mlst[c].srckeys.forEach(s=>{
if (!statinfo[s]) statinfo[s]={}
if (!statinfo[s][name]) statinfo[s][name]=0
statinfo[s][name]++
})
//console.log(c) recupere les contact tel ou email
})
})
return {status:200,ref:"Notifications",msg:"statistics",data:statinfo}
}
/**
* Register an typekey(email) or (phone) key into mailinglist for a tribe