Skip to content

Commit

Permalink
[4.3] KZOO-163: change users and vmboxes cb_listing to emit id as key (
Browse files Browse the repository at this point in the history
…#6707)

* change user cb_lists view key to id to avoid repeat

Emitting last/first name as key in view is just unique enough to avoid crossbar
pagination problem with repeating key. Change this to use DocId as view's key

* change vmbox cb_list to emit id as key
  • Loading branch information
icehess authored Mar 12, 2021
1 parent 99917cd commit 2786bf0
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion applications/acdc/src/cb_agents.erl
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ publish_restart(Context, AgentId) ->
read(Id, Context) ->
crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(kzd_user:type())).

-define(CB_AGENTS_LIST, <<"users/crossbar_listing">>).
-spec fetch_all_agent_statuses(cb_context:context()) -> cb_context:context().
fetch_all_agent_statuses(Context) ->
fetch_all_current_statuses(Context
Expand Down
2 changes: 1 addition & 1 deletion core/kazoo_apps/priv/couchdb/account/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"map": "function(doc) { if(!doc.pvt_sha1_auth || (doc.pvt_type != 'user' || doc.pvt_deleted || !doc.enabled)) return; emit( doc.pvt_sha1_auth, {'owner_id': doc._id, 'account_id': doc.pvt_account_id} ); }"
},
"crossbar_listing": {
"map": "function(doc) { if (doc.pvt_type != 'user' || doc.pvt_deleted) return; var features = []; if(doc.smartpbx) {for(var feature in doc.smartpbx) {if(doc.smartpbx[feature].enabled) { features.push(feature); }}} if(doc.hotdesk && doc.hotdesk.enabled) { features.push('hotdesk'); }if (doc.call_forward && doc.call_forward.enabled) {features.push('call_forward');} if (doc.call_forward && doc.call_forward.failover && !doc.call_forward.enabled) {features.push('call_forward_failover');} if (doc.caller_id && doc.caller_id.external && doc.caller_id.external.number) {features.push('caller_id');} if (doc.vm_to_email_enabled) {features.push('vm_to_email');} if (doc.music_on_hold && doc.music_on_hold.media_id) {features.push('music_on_hold');} if (doc.do_not_disturb && doc.do_not_disturb.enabled) {features.push('do_not_disturb');} if (doc.ctu && doc.ctu.enabled) {features.push('ctu');} if (doc.desktop && doc.desktop.enabled) {features.push('desktop');} emit(doc.last_name + \" \" + doc.first_name, {'id': doc._id,'features': features,'username': doc.username,'email': doc.email,'first_name': doc.first_name,'last_name': doc.last_name,'priv_level': doc.priv_level,'feature_level': doc.feature_level, 'presence_id': doc.presence_id,'timezone': doc.timezone, 'call_recording': doc.call_recording, 'service': doc.service, 'flags': doc.flags || []});}"
"map": "function(doc) { if (doc.pvt_type != 'user' || doc.pvt_deleted) return; var features = []; if(doc.smartpbx) {for(var feature in doc.smartpbx) {if(doc.smartpbx[feature].enabled) { features.push(feature); }}} if(doc.hotdesk && doc.hotdesk.enabled) { features.push('hotdesk'); }if (doc.call_forward && doc.call_forward.enabled) {features.push('call_forward');} if (doc.call_forward && doc.call_forward.failover && !doc.call_forward.enabled) {features.push('call_forward_failover');} if (doc.caller_id && doc.caller_id.external && doc.caller_id.external.number) {features.push('caller_id');} if (doc.vm_to_email_enabled) {features.push('vm_to_email');} if (doc.music_on_hold && doc.music_on_hold.media_id) {features.push('music_on_hold');} if (doc.do_not_disturb && doc.do_not_disturb.enabled) {features.push('do_not_disturb');} if (doc.ctu && doc.ctu.enabled) {features.push('ctu');} if (doc.desktop && doc.desktop.enabled) {features.push('desktop');} emit(doc._id, {'id': doc._id,'features': features,'username': doc.username,'email': doc.email,'first_name': doc.first_name,'last_name': doc.last_name,'priv_level': doc.priv_level,'feature_level': doc.feature_level, 'presence_id': doc.presence_id,'timezone': doc.timezone, 'call_recording': doc.call_recording, 'service': doc.service, 'flags': doc.flags || []});}"
},
"list_by_email": {
"map": "function(doc) { if( doc.pvt_type != 'user' || doc.pvt_deleted) return; if( !doc.email || doc.email == '' ) return ;emit( doc.email.toLowerCase(), null ); }"
Expand Down
2 changes: 1 addition & 1 deletion core/kazoo_apps/priv/couchdb/account/vmboxes.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"function(doc) {",
" if (doc.pvt_type != 'vmbox' || doc.pvt_deleted) return;",
" var messges_count = doc.messages ? doc.messages.length || 0 : 0;",
" emit(doc.name, {",
" emit(doc._id, {",
" id: doc._id,",
" name: doc.name,",
" mailbox: doc.mailbox,",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"id": "user0000000000000000000000000001",
"key": "User One",
"key": "user0000000000000000000000000001",
"value": {
"email": "[email protected]",
"features": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"id": "user0000000000000000000000000002",
"key": "User Two",
"key": "user0000000000000000000000000002",
"value": {
"email": "[email protected]",
"features": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"id": "user0000000000000000000000000003",
"key": "User Three",
"key": "user0000000000000000000000000003",
"value": {
"email": "[email protected]",
"features": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"id": "user0000000000000000000000000004",
"key": "User Three",
"key": "user0000000000000000000000000004",
"value": {
"email": "[email protected]",
"features": [
Expand Down

0 comments on commit 2786bf0

Please sign in to comment.