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

update filter search #396

Merged
merged 1 commit into from
Aug 7, 2020
Merged

update filter search #396

merged 1 commit into from
Aug 7, 2020

Conversation

mzfr
Copy link
Collaborator

@mzfr mzfr commented Aug 4, 2020

Now it's possible to search multiple values of the same type.

When I initially made change to the API it only supported filter search in the following way:

<url>?filters=attack_type:index

but failed to support something like:

<url>?filters=owners:tool owners:admin

This PR add that support

Now it's possible to search multiple values of the same type.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 1385

  • 42 of 44 (95.45%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 77.904%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tanner/api/api.py 31 33 93.94%
Totals Coverage Status
Change from base Build 1382: 0.1%
Covered Lines: 1576
Relevant Lines: 2023

💛 - Coveralls

@mzfr
Copy link
Collaborator Author

mzfr commented Aug 4, 2020

@afeena what should we do about 3.6 tests failing?

applied_filters['end_time'] = applied_filters['end_time']
key, value = filt.split(':', 1)
applied_filters[key].append(value)
print(applied_filters)
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove print

where = "S.sensor_id='%s'" % (filters["sensor_id"][0])

for parameter, values in filters.items():
if parameter == "attack_type":
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought a lot about this query building, can we rebuilt it in a way it looks more accurate and we use the power of sqlalchemy? like here https://aiopg.readthedocs.io/en/stable/examples.html#complex-sqlalchemy-queries

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually thought about it and I think almost everything would stay similar to the way it is.
The only thing that would differ is that instead of having raw queries we would be using the sqlalchemy objects

I mean all these conditions would have to stay so code might not become as clean as we think.

But I can definitely try to do it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could keep it in mind and make as a separate task :)

@afeena
Copy link
Collaborator

afeena commented Aug 6, 2020

@mzfr I think we should remove python 3.6 from travis config, what do you think?

@afeena afeena merged commit 05b3bc3 into mushorg:develop Aug 7, 2020
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