Ash FrameworkAF
Ash Framework3y ago
19 replies
rohan

Composing filter expressions

I'm trying to figure out how to reuse/compose (eg. apply a not) a complex expression that I use in filters.

I have a complex filter expression that looks like this:
    read :get_processed_for_visit do

      filter expr(
               not is_nil(visit.processing_started_at) and
                 summary_processed_at(is_nil(false)) and
                 summary_processed_at > visit.processing_started_at
             )
    end

and then another one that is:
    read :get_unprocessed do
      filter expr(
               not (not is_nil(visit.processing_started_at) and
                      summary_processed_at(is_nil(false)) and
                      summary_processed_at > visit.processing_started_at)
             )
    end

(ie. it's just the not of the previous one)

Is there a way to extract out the expression so I can do something like:
filter expr(processed)
and filter expr(not processed)

I don't think I can use a calculation because it's using visit which is a relationship
Was this page helpful?