What does /api/v1/users-doc-count represent?

The documentation for this endpoint says that it returns the “quantity of documents replicated by the given user”.

The sample JSON looks like this:

{
    "limit": 10000,
    "users": {
        "_id": "replication-count-mary",
        "_rev": "5-cd3252e852ae075da216c3c3fe461291",
        "user": "mary",
        "date": 1595328973273,
        "count": 58
    }
}

I have a few questions about this:

  1. I often use the words “replication” and “sync” interchangeably, is there actually a difference?
  2. Does the date property represent the most recent date that this user replicated or is it the date that the API call was made?
  3. Does the 58 in the example above represent total doc count for the user (as the name users-doc-count suggests) or just changes?
  4. If it represents just changes, is it the sum total of local (device) and remote (server) changes?
  5. If it represents total doc count, is there a reason we describe it as “documents replicated” (my assumption is that we do not replicate 100% of a user’s documents every time they sync)?
  6. I’m assuming this is stored as a document in a database (as opposed to being calculated on the fly), if so, which database is it in?

cc: @binod

1 Like

Hi @michael

Thanks for the question!

  1. Replication and sync are the same thing.
    However, I’ve seen the term replication used when referring to initial-replication, and the term sync when referring to the replication that happens after first login.
  2. The date is when the entry was created. It is not necessarily the most recent replication date. (there are some criteria for updating this doc).
  3. 58 is the total doc count
  4. I think that documents replicated can be ambiguous. This number represents a “payload” that the server needs to support for this user to get the necessary changes.
  5. These docs are stored in medic-logs database.
3 Likes

Thanks! Another follow-up question…

I assume this represents the number “on the device”… so if a user has 10,000 total docs, and 2,500 have already been purged (so only 7,500 are on the device), the count will be 7,500. Is that correct?

This is correct. purged docs are not part of this number.

2 Likes