Comments (3)
User story: beneficiary demographics
We'd like to obtain the number of beneficiaries (fact) for all sets of gender, age(-bin), and creation date (dimensions).
BE implementation
Such data can be obtained by first querying beneficiary rows, then transforming it into a pivot table (e.g. using the pandas framework; id
as values, gender, created_on, age
as index, count
as aggfunc), and finally transforming this table into single data points again.
However due to the simplicity of the aggregation, the data can be obtained directly from the DB via
bin_width = 5
gender = fn.IF(Beneficiary.gender == "", "D", Beneficiary.gender)
created_on = db.database.truncate_date("day", Beneficiary.created_on)
age = fn.FLOOR((date.today().year - Beneficiary.date_of_birth.year) / bin_width)
demographics = (
Beneficiary.select(
gender.alias("gender"),
created_on.alias("created_on"),
age.alias("age"),
fn.COUNT(Beneficiary.id).alias("count"),
)
.where(Beneficiary.deleted.is_null()) # add base IDs
.group_by(SQL("gender"), SQL("age"), SQL("created_on"))
)
The final implemenation will contain a filter for base IDs, too.
Data format
The resulting data format is an object with a facts
attribute that contains a list of objects with keys age
, gender
, createdOn
, tagIds
, and count
; and with a dimensions
attribute that contains a tag
field.
GraphQL interface
To return the data via GraphQL the following extension is proposed:
type Query {
...
beneficiaryDemographics(baseIds: [Int]): BeneficiaryDemographicsData
}
type BeneficiaryDemographicsData {
facts: [BeneficiaryDemographicsResult]
dimensions: BeneficiaryDemographicsDimensions
}
type BeneficiaryDemographicsResult {
age: Int
gender: HumanGender
createdOn: Datetime
tagIds: [Int!]
count: Int
}
type BeneficiaryDemographicsDimensions {
tag: [ResultIdName]
}
type ResultIdName {
id: ID
name: String
}
from boxtribute.
@MaikNeubert @HaGuesto please see the above proposal. Experimental implementation lives in this branch
from boxtribute.
works from my side
from boxtribute.
Related Issues (20)
- [5th viz] Propose GraphQL interface
- [C] Implement routes (set the url address) and authorization in Boxtribute FE HOT 2
- [C] Update Menues in Boxtribute FE and dropapp to include links to visualizations HOT 1
- [C] create infra-structure to use shared components in both Boxtribute and Statviz
- [C] move visualizations over to be shared components
- [C] import shared components in Boxtribute v2
- [C] Add cross-organisational authorization
- [6th viz] Sunburst of Moved Boxes FE HOT 1
- [6th viz] create user story / spec for 6th viz HOT 1
- [6th viz] BE and GraphQL interface
- Implement Dashboard in V2
- Statviz Frontend Testing
- Error and loading State
- Erliest date in time range select should be 01.01.2023
- [C] Enable beta-access (back-end)
- [C] Finalize moved-boxes resolver
- Statviz 1st live test Bugs/Improvements HOT 4
- Programming challenge: sharing of public link/embed live data&viz's HOT 1
- 2nd iteration bugfixes/improvements HOT 5
- Sankey - "Negative Box Flow" Legend at the bottom of the graph should instead say "Red targets indicate an incoming/reverse flow, i.e. a removal of items/boxes from that location to instock storage."
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boxtribute.