Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#9542): implement CouchDB Nouveau #9541

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft

feat(#9542): implement CouchDB Nouveau #9541

wants to merge 20 commits into from

Conversation

m5r
Copy link
Contributor

@m5r m5r commented Oct 14, 2024

Description

  • npm run local-images
  • COUCHDB_USER=admin COUCHDB_PASSWORD=pass docker compose -f ./local-build/cht-couchdb.yml -f ./local-build/cht-couchdb-override.yml up -d

Put this into ./local-build/cht-couchdb-override.yml:

services:
  couchdb:
    ports:
      - "5984:5984"
      - "5986:5986"

  nouveau:
    ports:
      - "5987:5987"
      - "5989:5989"

Query the indexes like so:

for contacts:

await fetch(
  'http://localhost:5984/medic/_design/medic-nouveau/_nouveau/contacts_by_freetext',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`,
    },
    body: JSON.stringify({
      q: 'name:asha', // 
      // possible 'sort' values are 'cht_sort_order' and '-cht_sort_order'. 'cht_sort_order' puts the dead and muted contacts last (current behavior of the contacts views), and '-cht_sort_order' puts them first
      sort: 'cht_sort_order',
      limit: 50,
      include_docs: true,
    }),
  },
);

for contacts by type:

await fetch(
  'http://localhost:5984/medic/_design/medic-nouveau/_nouveau/contacts_by_freetext',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`,
    },
    body: JSON.stringify({
      q: 'kianga AND cht_contact_type:district_hospital',
      sort: 'cht_sort_order',
      limit: 50,
      include_docs: true,
    }),
  },
);

for reports:

await fetch(
  'http://localhost:5984/medic/_design/medic-nouveau/_nouveau/reports_by_freetext',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`,
    },
    body: JSON.stringify({
      q: 'ali',
      limit: 50,
      include_docs: true,
    }),
  },
);

Code review checklist

  • Readable: Concise, well named, follows the style guide, documented if necessary.
  • Documented: Configuration and user documentation on cht-docs
  • Tested: Unit and/or e2e where appropriate
  • Internationalised: All user facing text
  • Backwards compatible: Works with existing data and configuration or includes a migration. Any breaking changes documented in the release notes.

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

@m5r m5r linked an issue Oct 15, 2024 that may be closed by this pull request
@m5r m5r changed the title dnm - CouchDB Nouveau feat(#9542): Research CouchDB Nouveau Oct 15, 2024
@m5r m5r force-pushed the couchdb-nouveau branch from 101c40e to b25ab70 Compare November 7, 2024 21:14
@m5r m5r changed the title feat(#9542): Research CouchDB Nouveau feat(#9542): research CouchDB Nouveau Dec 2, 2024
@m5r m5r linked an issue Dec 16, 2024 that may be closed by this pull request
@m5r m5r changed the title feat(#9542): research CouchDB Nouveau feat(#9542): implement CouchDB Nouveau Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce disk space with CouchDB Nouveau (TCO)
1 participant