akvo / akvo-flow-api

Akvo Flow API
GNU Affero General Public License v3.0
6 stars 3 forks source link

Implement question option statistics #244

Closed iperdomo closed 1 year ago

iperdomo commented 1 year ago

Context

There is a need for getting accurate counts for option question answers. The Akvo Flow dashboard uses the SurveyQuestionSummary kind for generating the charts in the Data > Charts tab.

The code that handles those counts has not been touched in 6 years, the last commit was in 2017: 75424d1

We're not confident that this code handles form instance deletion properly, as we have found several entities in the Datastore with no matching form instance.

Alternatives

Unilog - Option 1

We know that reading data from the Datastore is expensive, we could try to leverage the sync'ed data in the unilog.

Unilog - Option 2

Instead of materializing the counts, we can try make the counts via SQL queries.

Remote API

Read the data (QuestionAnswerStore) directly via Remote API and make the counts in the server

iperdomo commented 1 year ago

We have added a new /stats endpoint.