# Current notes
```json=
db.getCollection("systemFunctions").insert([{
"systemApplicationId": 0,
"systemFunctionId": 591,
"function": "/api-credentials",
"description": "D",
"permissionLevel": "workspace",
"availablePermissionTypeIds": [
2, 3
],
"name": "/projects",
"paths": []
},
{
"systemApplicationId": 0,
"systemFunctionId": 592,
"function": "/api-credentials",
"description": "D",
parentId: 591,
"permissionLevel": "workspace",
"availablePermissionTypeIds": [
2, 3
],
"name": "/api-credentials",
"paths": [
{
id: 'patch', path: "/api-credentials/:apiCredentialId"
}]
},
{
"systemApplicationId": 0,
"systemFunctionId": 593,
"function": "/api-credentials/access-token",
"description": "D",
parentId: 591,
"permissionLevel": "workspace",
"availablePermissionTypeIds": [
2
],
"name": "/api-credentials/access-token",
"paths": []
}
])
```
1) Update mongo trigger for each workspace platfrom ( bacause of replace method)
2) Create a mongo trigggers for:
3) sessions ( workspace name +, entity information)
4) workspaces (count modules +)
3) Session duration
## Reports
- Do we want to sort session by duration ?
- if true => needs to be calculated
- active sessions ?
- By workspace name ? - problems
```json=
{
duration: expirationDateTime - startDateTime,
referenceValues: {
workpsace: {
name: ""
}
},
"entities" : [
{
"isInitiator" : true,
"originalEntityIds" : [ ],
"isMute" : false,
"isRemoved" : false,
"_id" : ObjectId("60eeea38d6d3ef000b4c2624"),
"entityId" : 145258,
"platformId" : 4,
referenceValues: {
platform: {
name: ""
},
entity: {
firstName: "",
lastName: "",
profile: {
imageUrl: "",
color: ""
}
}
}
"platformConnectorId" : null,
"chatId" : null
}
],
}
```
## Sessions
```json=
{
}
```
## new collection
**collections**
```json=
{
name: 'entities',
filterRules: [
{
field: "email"
}
],
sortRules: [
{
field: "email",
value: {
'sort.email': -1,
email: '{querySortValue}' }
},
{
field: "firstName",
value: { 'sort.firstName': -1, firstName:'{querySortValue}' }
}
{
field: "lastName",
value: { 'sort.lastName': -1, lastName:'{querySortValue}' }
}
]
}
```
## rake live chat "type"
{
rakeLiveChatConfigId: 1,
scope: { type: 'project', ids: [7,8]},
// type: "Workspace | Project" -- remove it
}
## Rake live chat config (isDefault)
- update system config
```json=
"scope": {
"type": "system",
"ids": []
},
"isDefault": true
```
- update all configs
```json=
```
- add/delete index
```json=
db.rakeLiveChat_Configurations.dropIndex("type_1")
```
## Script for updating entities collection with sore rules
```json=
db.entities.updateMany(
{ },
[
{
$set: {
'sortPriority.lastName': {
$cond: [
{
$regexMatch: {
"input": "$lastName",
"regex": /.+/
}
},
1,
0
]
}
}
},
{
$set: {
'sortPriority.firstName': {
$cond: [
{
$regexMatch: {
"input": "$firstName",
"regex": /.+/
}
},
1,
0
]
}
}
},
{
$set: {
'sortPriority.email': {
$cond: [
{
$regexMatch: {
"input": "$email",
"regex": /.+/
}
},
1,
0
]
}
}
}
]
);
```
### draft
```json=
let indexes = db.entities.aggregate([ { $indexStats: { } } ]).toArray()
const combinations = [];
for(let item of indexes){
combinations.push(Object.keys(item.key))
}
console.log(combinations)
if(combinations.find(item => JSON.stringify(item) == JSON.stringify(['firstName']))){
console.log(true)
}
```
# To dic/.
https://chatbots-studio.atlassian.net/browse/W5GOL-3341