Skip to content

Commit

Permalink
feat: update mapping so that view_indexes is an array
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuester committed Sep 13, 2024
1 parent c2fbbd8 commit 85e231d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 45 deletions.
34 changes: 17 additions & 17 deletions development/fake-cht/initial-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,50 @@
"file": 0,
"active": 0
},
"view_index": {
"medic": {
"view_indexes": [
{
"name": "medic",
"sizes": {
"file": 0,
"active": 0
}
},
"medic-admin": {
{
"name": "medic-admin",
"sizes": {
"file": 0,
"active": 0
}
},
"medic-client": {
{
"name": "medic-client",
"sizes": {
"file": 0,
"active": 0
}
},
"medic-conflicts": {
{
"name": "medic-conflicts",
"sizes": {
"file": 0,
"active": 0
}
},
"medic-scripts": {
{
"name": "medic-scripts",
"sizes": {
"file": 0,
"active": 0
}
},
"medic-sms": {
{
"name": "medic-sms",
"sizes": {
"file": 0,
"active": 0
}
}
}
]
},
"sentinel": {
"name": "medic-sentinel",
Expand All @@ -70,15 +70,15 @@
"file": 0,
"active": 0
},
"view_index": {
"sentinel": {
"view_indexes": [
{
"name": "sentinel",
"sizes": {
"file": 0,
"active": 0
}
}
}
]
},
"usersmeta": {
"name": "medic-users-meta",
Expand All @@ -90,15 +90,15 @@
"file": 0,
"active": 0
},
"view_index": {
"users-meta": {
"view_indexes": [
{
"name": "users-meta",
"sizes": {
"file": 0,
"active": 0
}
}
}
]
},
"users": {
"name": "_users",
Expand All @@ -110,15 +110,15 @@
"file": 0,
"active": 0
},
"view_index": {
"users": {
"view_indexes": [
{
"name": "users",
"sizes": {
"file": 0,
"active": 0
}
}
}
]
}
},
"date": {
Expand Down
13 changes: 3 additions & 10 deletions development/fake-cht/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,15 @@ const getViewIndex = ({ name, sizes }) => ({
sizes: getSizes(sizes),
});

const getViewIndexes = (dbName, viewIndexes) => {
const result = {};
VIEW_INDEXES_BY_DB[dbName].forEach(viewIndex => {
result[viewIndex] = getViewIndex(viewIndexes[viewIndex]);
});
return result;
};

const getCouchDb = ({ name, update_sequence, doc_count, doc_del_count, fragmentation, sizes, view_index }) => ({
const getCouchDb = ({ name, update_sequence, doc_count, doc_del_count, fragmentation, sizes, view_indexes }) => ({
name,
update_sequence: randomCounter(update_sequence, 100),
doc_count: randomCounter(doc_count, 100),
doc_del_count: randomCounter(doc_del_count, 1),
fragmentation: randomGauge(1, 10, fragmentation, 1) + Math.random(),
sizes: getSizes(sizes),
view_index: getViewIndexes(name, view_index),
view_indexes: VIEW_INDEXES_BY_DB[name]
.map(viewIndexName => getViewIndex(view_indexes.find(viewIndex => viewIndex.name === viewIndexName))),
});

const getAllCouchDbs = ({ medic, sentinel, usersmeta, users }) => ({
Expand Down
36 changes: 18 additions & 18 deletions exporters/json/config/cht.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,109 +166,109 @@ modules:
db: '_users'

- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.medic.view_index.medic.sizes.active}'
path: '{.couchdb.medic.view_indexes[?(@.name=="medic")].sizes.active}'
labels:
db: 'medic'
view_index: 'medic'
type: 'active'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.medic.view_index.medic.sizes.file}'
path: '{.couchdb.medic.view_indexes[?(@.name=="medic")].sizes.file}'
labels:
db: 'medic'
view_index: 'medic'
type: 'file'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.medic.view_index.medic-admin.sizes.active}'
path: '{.couchdb.medic.view_indexes[?(@.name=="medic-admin")].sizes.active}'
labels:
db: 'medic'
view_index: 'medic-admin'
type: 'active'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.medic.view_index.medic-admin.sizes.file}'
path: '{.couchdb.medic.view_indexes[?(@.name=="medic-admin")].sizes.file}'
labels:
db: 'medic'
view_index: 'medic-admin'
type: 'file'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.medic.view_index.medic-client.sizes.active}'
path: '{.couchdb.medic.view_indexes[?(@.name=="medic-client")].sizes.active}'
labels:
db: 'medic'
view_index: 'medic-client'
type: 'active'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.medic.view_index.medic-client.sizes.file}'
path: '{.couchdb.medic.view_indexes[?(@.name=="medic-client")].sizes.file}'
labels:
db: 'medic'
view_index: 'medic-client'
type: 'file'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.medic.view_index.medic-conflicts.sizes.active}'
path: '{.couchdb.medic.view_indexes[?(@.name=="medic-conflicts")].sizes.active}'
labels:
db: 'medic'
view_index: 'medic-conflicts'
type: 'active'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.medic.view_index.medic-conflicts.sizes.file}'
path: '{.couchdb.medic.view_indexes[?(@.name=="medic-conflicts")].sizes.file}'
labels:
db: 'medic'
view_index: 'medic-conflicts'
type: 'file'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.medic.view_index.medic-scripts.sizes.active}'
path: '{.couchdb.medic.view_indexes[?(@.name=="medic-scripts")].sizes.active}'
labels:
db: 'medic'
view_index: 'medic-scripts'
type: 'active'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.medic.view_index.medic-scripts.sizes.file}'
path: '{.couchdb.medic.view_indexes[?(@.name=="medic-scripts")].sizes.file}'
labels:
db: 'medic'
view_index: 'medic-scripts'
type: 'file'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.medic.view_index.medic-sms.sizes.active}'
path: '{.couchdb.medic.view_indexes[?(@.name=="medic-sms")].sizes.active}'
labels:
db: 'medic'
view_index: 'medic-sms'
type: 'active'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.medic.view_index.medic-sms.sizes.file}'
path: '{.couchdb.medic.view_indexes[?(@.name=="medic-sms")].sizes.file}'
labels:
db: 'medic'
view_index: 'medic-sms'
type: 'file'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.sentinel.view_index.sentinel.sizes.active}'
path: '{.couchdb.sentinel.view_indexes[?(@.name=="sentinel")].sizes.active}'
labels:
db: 'sentinel'
view_index: 'sentinel'
type: 'active'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.sentinel.view_index.sentinel.sizes.file}'
path: '{.couchdb.sentinel.view_indexes[?(@.name=="sentinel")].sizes.file}'
labels:
db: 'sentinel'
view_index: 'sentinel'
type: 'file'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.usersmeta.view_index.users-meta.sizes.active}'
path: '{.couchdb.usersmeta.view_indexes[?(@.name=="users-meta")].sizes.active}'
labels:
db: 'medic-users-meta'
view_index: 'users-meta'
type: 'active'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.usersmeta.view_index.users-meta.sizes.file}'
path: '{.couchdb.usersmeta.view_indexes[?(@.name=="users-meta")].sizes.file}'
labels:
db: 'medic-users-meta'
view_index: 'users-meta'
type: 'file'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.users.view_index.users.sizes.active}'
path: '{.couchdb.users.view_indexes[?(@.name=="users")].sizes.active}'
labels:
db: '_users'
view_index: 'users'
type: 'active'
- <<: *cht_couchdb_view_index_size_bytes
path: '{.couchdb.users.view_index.users.sizes.file}'
path: '{.couchdb.users.view_indexes[?(@.name=="users")].sizes.file}'
labels:
db: '_users'
view_index: 'users'
Expand Down

0 comments on commit 85e231d

Please sign in to comment.