Skip to content

Conversation

@everaldorodrigo
Copy link
Collaborator

No description provided.

@mindoftea mindoftea self-requested a review July 11, 2023 17:44
lineages=query_pangolin_lineage, mutations=query_mutations
)
# print(query)
parse_time_window_to_query(date_range_filter, query["query"])

Choose a reason for hiding this comment

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

The current behavior looks like the date range filter isn't operating. I think the problem might be that we need to change this line to update the query with the new time window being calculated -- something like query["query"] = parse_time_window... maybe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looking into the range filter created here:

When making the request to the endpoint below for test purposes:

  • /genomics/lineage-mutations?pangolin_lineage=BA.2&frequency=0&gene=ORF1a,ORF1b,S,ORF7b&min_date=2022-01-12&max_date=2022-10-22

The query created is below. The date range was added date_collected.

{
    "size": 0,
    "query": {
        "bool": {
            "should": [
                {
                    "bool": {
                        "must": [
                            {
                                "term": {
                                    "pangolin_lineage": "BA.2"
                                }
                            },
                            {
                                "range": {
                                    "date_collected": {
                                        "lte": "2022-10-22",
                                        "gte": "2022-01-12"
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    },
    "aggs": {
        "mutations": {
            "nested": {
                "path": "mutations"
            },
            "aggs": {
                "mutations": {
                    "terms": {
                        "field": "mutations.mutation",
                        "size": 10000
                    },
                    "aggs": {
                        "genomes": {
                            "reverse_nested": {}
                        }
                    }
                }
            }
        }
    }
}

The query dict is mutable and passed by reference when calling the function below:

parse_time_window_to_query(date_range_filter, query["query"])

Does it make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants