Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
204 commits
Select commit Hold shift + click to select a range
ddebbfd
add refy_lkup
zander-prinsloo May 27, 2025
2a60af2
use unique version of refy df for refy
zander-prinsloo May 27, 2025
1eeaa0f
rm print
zander-prinsloo Jun 11, 2025
78ff6a5
testing fg_pip pipload additions
zander-prinsloo Jun 11, 2025
ae78a3b
Merge branch 'DEV' into refy_lineups
zander-prinsloo Jun 11, 2025
0ee3477
add more error messages
zander-prinsloo Jun 11, 2025
33134eb
temp store metadata
zander-prinsloo Jun 17, 2025
105859b
fix joining of metadata
zander-prinsloo Jun 18, 2025
928606e
add mean and med to compute_fgt_dt
zander-prinsloo Jun 18, 2025
74e4093
comment out env checks
zander-prinsloo Jun 18, 2025
4574c8f
fix full_list for file ingestion
zander-prinsloo Jun 23, 2025
e92e3b8
allow processing to return mean, med, country, year
zander-prinsloo Jun 23, 2025
67b1d8c
create old funcs
zander-prinsloo Aug 5, 2025
dd4a8b7
master_file tryCatch for duckdb con error
zander-prinsloo Aug 6, 2025
633fc8b
make the NA of survey_comparability if fg type double for consistency
zander-prinsloo Aug 6, 2025
a0357c1
add interpolation id for df_refy
zander-prinsloo Aug 6, 2025
3fb45a2
rm _refy from lineup columns
zander-prinsloo Aug 6, 2025
85ba924
standardize format of country and year selection as vector
zander-prinsloo Aug 7, 2025
3694501
replace pipload with pipdata
zander-prinsloo Aug 7, 2025
a7da907
add valid lineup years to lkup
zander-prinsloo Aug 7, 2025
5466131
only fg lineup years that are valid
zander-prinsloo Aug 7, 2025
b29cc6b
load dist stats in lkups
zander-prinsloo Aug 11, 2025
b1484a0
use dist stats in fg
zander-prinsloo Aug 11, 2025
f0e0fff
don't show joyn message
zander-prinsloo Aug 11, 2025
b081b44
change full join to left join - this removes nowcast years - i.e. yea…
zander-prinsloo Aug 11, 2025
d0bd7bf
fix cache different columns
zander-prinsloo Aug 12, 2025
7cc0295
add to lkup whether to use new lineups
zander-prinsloo Aug 12, 2025
9a9546a
standardise ref and refy in lkup
zander-prinsloo Aug 12, 2025
cda895f
rm nowcast years from refy
zander-prinsloo Aug 12, 2025
3aa5535
add explanation comments
zander-prinsloo Aug 13, 2025
e57bada
rm NA dist stats for FG
zander-prinsloo Aug 13, 2025
842d57f
fg_pip_old in pip_old
zander-prinsloo Aug 13, 2025
1d0d445
dist_stats_old fn for old pip
zander-prinsloo Aug 13, 2025
b6b9442
add estimate type to fg
zander-prinsloo Aug 14, 2025
fe4dc95
fix non-numeric surveyid_year for fg
zander-prinsloo Aug 14, 2025
81e4816
add pip wrapper for new and old lineups
zander-prinsloo Aug 14, 2025
1081c77
document lineups functions
zander-prinsloo Aug 14, 2025
68a4684
document
zander-prinsloo Aug 14, 2025
b69b1c6
Increment version number to 1.3.19.9000
zander-prinsloo Aug 14, 2025
d325cec
rm setting use_new_lneups to TRUE
zander-prinsloo Aug 14, 2025
f17a5cc
rm ref_lkup from new fg
zander-prinsloo Aug 14, 2025
ed57649
fix lkups for old fn
zander-prinsloo Aug 14, 2025
f561be8
full list function, incl rm cache country-year
zander-prinsloo Aug 18, 2025
5394ac4
comment out env save checks
zander-prinsloo Aug 18, 2025
7a1ae75
Increment version number to 1.3.19.9001
zander-prinsloo Aug 18, 2025
129aa41
make dist stats NA for fg pip
zander-prinsloo Aug 20, 2025
fa602a0
new attr to cols functions
zander-prinsloo Aug 22, 2025
1ca018f
rm comments & print checks
zander-prinsloo Aug 22, 2025
7da94f6
change checks to cli
zander-prinsloo Aug 22, 2025
bf68fcc
Increment version number to 1.3.19.9002
zander-prinsloo Aug 22, 2025
4a25d5b
documnet and add pipdata functions into utils-pipdata
Aug 22, 2025
3521a14
send pip_new_lineups to new file
Aug 22, 2025
d6105fe
organize functions
Aug 22, 2025
d4dea9f
improve efficiency a little
Aug 22, 2025
9b688bb
more optimization
Aug 22, 2025
b194914
remove rep.int for efficiency
Aug 22, 2025
ed78664
slight optimization
Aug 22, 2025
563cc34
more optimization
Aug 22, 2025
95e9f21
init reformat
Aug 22, 2025
d5b3370
new optimization
Aug 23, 2025
0040957
optimize how to estimate FGT by reporting level
Aug 23, 2025
f8b718c
merge dist stats
Aug 23, 2025
4b564d0
update
Aug 23, 2025
e362307
create pipenv enviroment
Aug 23, 2025
6d637b4
remove mean and median from dickdb
Aug 23, 2025
0315985
add just mean and median
Aug 23, 2025
f6bb8e4
super efficient code now
Aug 23, 2025
bf9f87f
remove idea of the pipenv
Aug 23, 2025
aea71b7
make sure it saves mean and median depending on the type of data.
Aug 23, 2025
84ab37f
update
Aug 23, 2025
851b83c
init new strcuture for aggregates
Aug 23, 2025
eb796c1
small progress.
Aug 23, 2025
1f6ea65
init function to subset country codes
Aug 25, 2025
0ed1bf4
document new get_country_code_subset function
Aug 25, 2025
72de2ca
add list_code_column_values
Aug 25, 2025
e9bfeb3
document
Aug 25, 2025
55feea8
add pip_agg instead of pip_grp_logic
Aug 25, 2025
8ef8492
format
Aug 25, 2025
61170c4
add pipapienv
Aug 26, 2025
e4f0883
add functions to manage pipapienv
Aug 26, 2025
01accd6
implement loading of qs using multiple cores
Aug 26, 2025
22679d1
updates on pov_from_DT
Aug 26, 2025
b3a7c05
change aggregation to collapse
Aug 27, 2025
83ed0ff
add validate_country_codes function
Aug 30, 2025
c0b5da3
temporal fix to include CMD info
Sep 2, 2025
cb756d3
improve efficiency
Sep 2, 2025
11c5e44
tempooral fix complete
Sep 2, 2025
6cfcca9
update population
Sep 2, 2025
ea094e1
make sure we don't have factors in years of population
Sep 3, 2025
9ad8a6d
fix bug in country_list
Sep 4, 2025
772de99
preliminary results... working but ugly
Sep 5, 2025
bac2abf
fix issue with missclassified CMDs
Sep 5, 2025
264e62b
fix small issue
Sep 5, 2025
1c7d054
set default for data_dir in get_aux_table()
Sep 5, 2025
9397c8e
this is the most recent
Sep 5, 2025
0c6b838
fix create_countries_vctr addint lkup
Sep 6, 2025
f3bd966
fix test
Sep 6, 2025
6d15ac1
remporal fix in number of aggregates to include
Sep 6, 2025
6435d70
include region and regionpcn in old way
Sep 6, 2025
b6d24cf
aggregation working for old, new, and previous... not pretty but works
Sep 6, 2025
8280414
first version of cumsum instead of mean
Sep 8, 2025
8d736fc
small update
Sep 10, 2025
fadce92
replace load_list_refy to read from fst files
Sep 10, 2025
968bbf3
remove first attempt of cumcum method
Sep 10, 2025
fd0dc36
new file for new method of FGT using cumsum
Sep 10, 2025
30c50b9
document helpers for fgt_cumcum
Sep 10, 2025
01c52cc
improve helpers
Sep 10, 2025
76c6610
first attempt of new cumcum functions
Sep 10, 2025
a182f08
improve speed in get_mean_median
Sep 10, 2025
72f96e2
add join rather than joyn
Sep 10, 2025
85aaf04
improve documentation
Sep 10, 2025
37a86ba
change lkup to read from fst
Sep 11, 2025
b02fbef
pip(fill_gaps = TRUE) fully working
Sep 11, 2025
4743424
Increment version number to 1.3.19.9003
Sep 11, 2025
f35bfed
fix issue with censoring
Sep 11, 2025
cebe90c
fix bug
Sep 11, 2025
a010a8c
update ui_hp_stacked to account for use_new
Sep 11, 2025
48cf146
improve ui_hp_countries
Sep 11, 2025
ae6818c
improve ui_pc_charts and ui_pc_regional
Sep 11, 2025
5be1cdc
fix get_mean_median to account for welfare_type in survey years
Sep 11, 2025
02c2ca0
improve country_profile
Sep 11, 2025
391c781
Increment version number to 1.3.19.9004
Sep 14, 2025
79ff742
add popshare to subset_lkup
Sep 15, 2025
3d49935
update round to 2 decimals
Sep 15, 2025
ec93225
In case of error, make sure you log the endpoint closes #432
Sep 15, 2025
2b40da8
include povline in aggregates list
Sep 15, 2025
33b685d
add gc() each time it disconnects
Sep 15, 2025
6ae5003
set pov line to NULL if popshare is defined in fg
Sep 15, 2025
0a24c57
check pip_grp_logic with changes made to old_DEV branch last commit
Sep 15, 2025
3dc0dc3
limit set of poverty lines to store
Sep 15, 2025
a099a38
store vars in env defined in zzz
Sep 15, 2025
64eedb5
update data documentation
Sep 15, 2025
d057467
first attempt of infer_poverty_line
Sep 16, 2025
819caaa
document
Sep 16, 2025
bd23ba1
multiple popshare for svy years.
Sep 16, 2025
90deb51
add prosperity gapto ui_cp_charts
Sep 16, 2025
4bf15af
allow to select regions from any variable.
Sep 16, 2025
916780c
fix bug
Sep 16, 2025
bd65c2e
fix some tests
Sep 16, 2025
449cf15
add documentation
Sep 16, 2025
ed575a6
Increment version number to 1.3.24.9000
Sep 16, 2025
549152b
remove filter_Lkup from fg_pip()
Sep 16, 2025
a0b8eb3
add multiple popshare for fillgaps
Sep 16, 2025
57c642d
update empty data
Sep 16, 2025
3c153cf
document
Sep 16, 2025
27deea4
fix bug
Sep 16, 2025
81691c6
Increment version number to 1.3.24.9001
Sep 16, 2025
0f59379
sort for surveys with more than 1 reporting_level
Sep 17, 2025
c3da472
Increment version number to 1.3.24.9002
Sep 17, 2025
3985f5a
remove verbose in join
Sep 17, 2025
2503a93
Increment version number to 1.3.24.9003
Sep 17, 2025
247caa5
make use of missing data file instead of recreate i
Sep 17, 2025
7e3cdb8
Increment version number to 1.3.24.9004
Sep 18, 2025
f04612b
remove heavy objects and apply gc()
Sep 18, 2025
1b5447b
filter properly proverty lines to update master (inter cache) file
Sep 18, 2025
c76bbd3
Increment version number to 1.3.24.9005
Sep 18, 2025
84ecf28
remove gc()
Sep 19, 2025
db6fcd8
Increment version number to 1.3.24.9006
Sep 19, 2025
847fb20
fix bug req$args to req$argsQuery
Sep 19, 2025
3b433c5
Increment version number to 1.3.24.9007
Sep 19, 2025
5afa3d5
handle errors
Sep 19, 2025
86a66da
add some tryCatch in some endpoints
Sep 19, 2025
71afe00
Add a tiny request-ID + timings filter
Sep 19, 2025
fd91f92
add Request timed out to pip and pip-grp endpoints
Sep 19, 2025
c495e07
implement timeout wrapper to more endpoint
Sep 19, 2025
6fa1450
revamp plumber
Sep 19, 2025
912a0a7
new plumber setup.
Sep 19, 2025
d9a10a6
remove the preroute as it is in endpoints.R
Sep 19, 2025
7efee79
Increment version number to 1.3.24.9008
Sep 19, 2025
baa6be8
fix bugs
Sep 19, 2025
0c16445
Increment version number to 1.3.24.9009
Sep 19, 2025
980f47f
add R.utils package
Sep 22, 2025
011f4d3
Increment version number to 1.3.24.9010
Sep 22, 2025
28fca6c
add function safe_endpoint
Sep 22, 2025
d9e9420
impore with_req_timeout
Sep 23, 2025
8c8151d
test safe_endpoint with cp-charts
Sep 23, 2025
46373a4
Increment version number to 1.3.24.9011
Sep 23, 2025
219167e
document with_req_timeout
Sep 23, 2025
57b2548
update news
Sep 24, 2025
6b6643d
Increment version number to 1.4.0
Sep 24, 2025
a01a71e
remove old regions from pc_charts
Sep 24, 2025
48b1a2c
Increment version number to 1.4.0.9000
Sep 24, 2025
243ef1d
fix descriptions
Sep 24, 2025
ff3fd8a
remove MDG censoring
Sep 27, 2025
74b77ab
excliude regions that should not go in UI
Sep 27, 2025
2555f1a
document
Sep 27, 2025
fa46399
update news
Sep 27, 2025
54e64bf
Increment version number to 1.4.0.9001
Sep 27, 2025
1235870
add hashed to all UI endpoint
Sep 27, 2025
ecaff99
Increment version number to 1.4.0.9002
Sep 27, 2025
368462d
temp fix with indicators file
Sep 27, 2025
38de1fe
Increment version number to 1.4.0.9003
Sep 27, 2025
a66f362
fiw distribution_type in fg gaps and lkups
Sep 28, 2025
88d1df8
formatting
Sep 28, 2025
a40eb05
Increment version number to 1.4.0.9004
Sep 28, 2025
4a7d196
add cache_data_id to pip_grp_new
Sep 28, 2025
6306466
Increment version number to 1.4.0.9005
Sep 28, 2025
4bd5a61
remove patch in indicators files
Sep 29, 2025
81498da
Increment version number to 1.4.0.9006
Sep 29, 2025
8ff8c4b
fix issue with regions table in the UI
Sep 29, 2025
53aadbd
Increment version number to 1.4.0.9007
Sep 29, 2025
6e20c18
fix bug
Sep 29, 2025
c2d0a33
Increment version number to 1.4.0.9008
Sep 29, 2025
a521953
Increment version number to 1.4.1
Sep 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: pipapi
Title: API for the Poverty and Inequality Platform
Version: 1.3.19
Version: 1.4.1
Authors@R:
c(person(given = "Tony",
family = "Fujs",
Expand Down Expand Up @@ -70,7 +70,9 @@ Imports:
DBI,
duckdb,
jsonlite,
digest
digest,
parallel,
R.utils
Remotes:
PIP-Technical-Team/wbpip@DEV
Depends:
Expand Down
14 changes: 14 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Generated by roxygen2: do not edit by hand

export(add_attributes_as_columns_multi)
export(add_attributes_as_columns_vectorized)
export(add_dist_stats)
export(add_dist_stats_old)
export(assign_serializer)
export(assign_stat)
export(change_grouped_stats_to_csv)
export(citation_from_version)
export(create_etag_header)
Expand All @@ -12,27 +16,34 @@ export(get_aux_table)
export(get_aux_table_ui)
export(get_caller_names)
export(get_ctr_alt_agg)
export(get_from_pipapienv)
export(get_grp_to_compute)
export(get_impl_ctrs)
export(get_md_vars)
export(get_param_values)
export(get_pip_version)
export(get_pipapienv)
export(get_user_alt_gt)
export(get_user_x_code)
export(get_valid_aux_long_format_tables)
export(is_empty)
export(is_forked)
export(load_inter_cache)
export(pip)
export(pip_agg)
export(pip_grp)
export(pip_grp_logic)
export(pip_new_lineups)
export(pip_old)
export(pip_old_lineups)
export(pipgd_lorenz_curve)
export(return_correct_version)
export(return_if_exists)
export(safe_endpoint)
export(select_off_alt_agg)
export(select_reporting_level)
export(select_user_aggs)
export(set_in_pipapienv)
export(start_api)
export(ui_cp_charts)
export(ui_cp_download)
Expand All @@ -44,11 +55,14 @@ export(ui_pc_regional)
export(ui_svy_meta)
export(unnest_dt_longer)
export(update_master_file)
export(use_new_lineup_version)
export(valid_years)
export(validate_input_grouped_stats)
export(version_dataframe)
export(with_req_timeout)
export(wld_lineup_year)
import(collapse, except = fdroplevels)
import(data.table)
import(data.table, except = fdroplevels)
importFrom(glue,glue)
importFrom(glue,glue_collapse)
Expand Down
57 changes: 57 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
# pipapi 1.4.1
* Removed old regions aggregate from `pc_chart`.
* Removed old regions aggregate from `get_aux_table_ui`.
* Bring back MDG.
* Add hash to all UI enpdoints
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Correct typo in release notes.

“enpdoints” should be “endpoints” so the 1.4.1 entry reads clean in NEWS.

🤖 Prompt for AI Agents
In NEWS.md around line 5, the release note contains a typo ("enpdoints"); update
the word to the correct spelling "endpoints" so the line reads "* Add hash to
all UI endpoints" ensuring the 1.4.1 entry is spelled correctly.


# pipapi 1.4.0
* Added `safe_endpoint` function for safer endpoint handling.
* Removed `preroute` as it is now managed in `endpoints.R`.
* Introduced a new and improved Plumber setup.
* Refactored Plumber configuration for better maintainability.
* Implemented a timeout wrapper for more endpoints.
* Added "Request timed out" responses to `pip` and `pip-grp` endpoints.
* Introduced a lightweight request ID and timing filter for better request tracking.
* Added `tryCatch` blocks to improve error handling in several endpoints.
* Enhanced error handling throughout the API.
* Fixed bug by changing `req$args` to `req$argsQuery`.
* Removed unnecessary calls to `gc()`.
* Improved filtering of poverty lines when updating the master (intermediate cache) file.
* Utilized the missing data file instead of recreating it.
* Removed verbose output in join operations.
* Ensured correct sorting for surveys with multiple `reporting_level` values.
* Updated handling of empty data responses.
* Enabled support for multiple `popshare` values in fill gaps operations.
* Removed `filter_Lkup` from `fg_pip()`.
* Allowed region selection from any variable (to be revised when supporting more aggregations).
* Added prosperity gap metric to `ui_cp_charts`.
* Enabled multiple `popshare` values for survey years.
* Improved the `infer_poverty_line()` function.
* Updated data documentation for clarity and completeness.
* Stored variables in the environment defined in `zzz`.
* Fixed several bugs across the codebase.


# pipapi 1.3.24
* Incorporate Lineup distribution and Countries with Missing Data (CMD) distributions
* New way to estimate poverty using cumulative sums
* allow multiple `popshare`


# pipapi 1.3.23
* Add Venn diagram information to Country profiles
* Add prosperity gap to country profiles chart.


# pipapi 1.3.22

* Fix issue with popshare in fill gaps calls.

# pipapi 1.3.21
* Fix issue with popshare in survey year calls
* Fix problem with alternative aggregates like AFW and AFE
* Make sure all tests pass
* add logs in docker container

# pipapi 1.3.20

# pipapi 1.3.19
* fix issue with comparability

Expand Down
1 change: 1 addition & 0 deletions R/aaa.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.pipapienv <- new.env(parent = emptyenv())
3 changes: 2 additions & 1 deletion R/add_agg_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ add_agg_stats <- function(df,
aggregated_list <- split(aggregated,
interaction(
aggregated$country_code,
aggregated$reporting_year
aggregated$reporting_year,
aggregated$poverty_line
),
drop = TRUE
)
Comment on lines 16 to 23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Grouping key change looks right; verify no duplicate national rows per povline.

Including poverty_line in the split key should prevent cross-povline blending. Please confirm downstream expects one national row per (country_code, reporting_year, welfare_type, poverty_line).


🏁 Script executed:

#!/bin/bash
# Optional: sanity-check any agg outputs (if artifacts exist) for duplicates by the new key
rg -nP --type=r 'add_agg_stats\('

Length of output: 1269


🏁 Script executed:

#!/bin/bash
sed -n '1,200p' tests/testthat/test-add_agg_stats.R

Length of output: 3462


Ensure unique national rows per (country_code, reporting_year, welfare_type, poverty_line)
Add a unit test in tests/testthat/test-add_agg_stats.R that checks the number of rows equals the number of unique combinations of country_code, reporting_year, welfare_type and poverty_line after calling add_agg_stats().

🤖 Prompt for AI Agents
In R/add_agg_stats.R around lines 16 to 23 the aggregation splits only by
country_code, reporting_year and poverty_line which can produce multiple
national rows per (country_code, reporting_year, welfare_type, poverty_line);
update the split (or grouping) to include welfare_type so the aggregated_list is
unique per country_code, reporting_year, welfare_type and poverty_line, and add
a unit test at tests/testthat/test-add_agg_stats.R that calls add_agg_stats()
and asserts nrow(result) ==
nrow(unique(result[c("country_code","reporting_year","welfare_type","poverty_line")])),
failing the test if not equal.

Expand Down
Loading