Skip to content

Commit 68249e4

Browse files
author
Martin Hinz
committed
added filter functionality for cal dates, solves #331
1 parent 020c8a4 commit 68249e4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/models/data.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def everything
1919
# TODO: typos, dendros, etc.
2020
C14
2121
.left_outer_joins(:c14_lab)
22+
.joins("LEFT OUTER JOIN cals on (cals.c14_age = c14s.bp AND cals.c14_error = c14s.std)")
2223
.left_outer_joins(sample: [
2324
:material,
2425
:taxon,
@@ -76,7 +77,18 @@ def decode_range_filters(filters)
7677
if filters.dig(:c14s, :bp).present?
7778
filters.dig(:c14s, :bp).replace(slice_ranges(filters.dig(:c14s, :bp)))
7879
end
79-
80+
81+
if filters.dig(:cals).present?
82+
# Ensure the value for :tpq is replaced with the array
83+
tpq_value = filters.dig(:cals, :tpq)
84+
filters[:cals][:tpq] = slice_ranges([50000, tpq_value]) if tpq_value
85+
#filters[:cals][:tpq] = !nil
86+
87+
# Ensure the value for :taq is replaced with the array
88+
taq_value = filters.dig(:cals, :taq)
89+
filters[:cals][:taq] = slice_ranges([taq_value, 0]) if taq_value
90+
end
91+
8092
return filters
8193
end
8294

0 commit comments

Comments
 (0)