Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add min and max date filters to lineage-mutations. #92

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

everaldorodrigo
Copy link
Collaborator

No description provided.

@mindoftea mindoftea self-requested a review July 11, 2023 17:44
@@ -66,7 +78,7 @@ async def _get(self):
query["query"] = create_nested_mutation_query(
lineages=query_pangolin_lineage, mutations=query_mutations
)
# print(query)
parse_time_window_to_query(date_range_filter, query["query"])
Copy link
Collaborator

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.

2 participants