equinor / septic-config-generator

SEPTIC config generator
MIT License
4 stars 0 forks source link

feat: add filter to unpack values from maps #216

Closed einarsi closed 8 months ago

einarsi commented 8 months ago

Can be used for a source (HashMap<String, HashMap<String, Value>>):

{% for col1, col2, col3, col4, col5, col6 in main | unpack("Col1", "Col2_str", "Col3_int", "Col4_float_whole", "Col5_float", "Col6_bool") %}
  {{ col1 }}, {{ col2 }}, {{ col3 }}, {{ col4 }}, {{ col5 }}, {{ col6 }}
{%- endfor %}
  one, 00, 1, 1.0, 1.234, TRUE
  two, 02, 2, 2.0, 2.3456, FALSE
  three, 030, 3, 3.0, 34.6, TRUE

Or a source row (HashMap<String, Value>):

{%- with (col1, col3, col6) = main["one"] | unpack("Col1", "Col3_int", "Col6_bool") %}
  {{ col1 }}, {{ col3 }}, {{ col6 }}
{%- endwith %}
  one, 1, TRUE

Or an array of source rows (Vec<HashMap<String, Value>>):

{% for (col1, col3, col5, col6) in main | values | selectattr("Col5_float", "gt", 2) | unpack("Col1", "Col3_int", "Col5_float", "Col6_bool") %}
  {{ col1 }}, {{ col3 }}, {{ col5 }}, {{ col6 }}
{%- endfor %}
  two, 2, 2.3456, FALSE
  three, 3, 34.6, TRUE
github-actions[bot] commented 8 months ago

Test Results

47 tests  +8   47 :white_check_mark: +8   0s :stopwatch: ±0s  1 suites ±0    0 :zzz: ±0   1 files   ±0    0 :x: ±0 

Results for commit 0095b2b0. ± Comparison against base commit b599c5a0.

:recycle: This comment has been updated with latest results.

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 76.50%. Comparing base (304b3aa) to head (0095b2b). Report is 4 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #216 +/- ## ========================================== + Coverage 74.46% 76.50% +2.03% ========================================== Files 10 10 Lines 1457 1583 +126 ========================================== + Hits 1085 1211 +126 Misses 372 372 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.