-
Notifications
You must be signed in to change notification settings - Fork 48
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
#Refocus get /subjects filtering by tag working #68
Conversation
in: query | ||
items: | ||
type: string | ||
maxLength: 60 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 60 here? (Might need to allow for longer since you could build up a list of includes or excludes.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each tag length is max 60 char long, as restricted by model.
Also, the changes in this PR only handles includes at sql level like v1/subjects?tags=mytag
.
Do we need excludes here as well? I assumed the story was about includes only to get trust data working. I can create another PR if we need excludes as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok we can get this through as is, but i think we want to follow up with story to allow v1/subjects?tags=tag1,tag2,tag3
or v1/subjects?tags=-tag10,tag11
for parity with the analogous functionality on the /hierarchy endpoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, let me create a story then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the /hierarchy endpoint filters are case insensitive too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shriramshankar Just checked, we can add different case tags to a subject, like I can have
tags = [
"mytag",
"Cali",
"mytaG",
"MYTAG"
]
Is this expected behavior?
Also, if we need to filter case insensitive, there are 2 ways:
- Filter on API layer instead of query level, like hierarchy endpoint. Disadvantage: get all subjects first and then extra processing to filter.
- store tags in lowercase in db. This is more efficient way to do, if we agree.
I can add this feature to the new story to filter by excludes as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes you can have mixed cases for tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, if we can have mixed tags, then option 2 won't work and we will have to do filtering on API layer? What is the use case of having mixed tags?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since filtering for the hierarchy end point was done in the API layer, it made sense to store the tags the way it was created by the user.
@@ -19,6 +19,7 @@ const u = require('./utils'); | |||
const Subject = tu.db.Subject; | |||
const path = '/v1/subjects'; | |||
const expect = require('chai').expect; | |||
const filterSubjByTags = require('../../../../config').filterSubjByTags; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will always be false unless we explicitly set env var when we call the test (see examples in package.json)
4d25141
to
f3d4ae4
Compare
f3d4ae4
to
30cf7ae
Compare
0e3cd1d
to
8d6489b
Compare
pushing additional work into separate story
uh oh coverage decreased! :( |
@iamigo @shriramshankar updated the PR |
@iamigo So, I looked into it because I have tests for the new code. I think the test coverage does not cover the tests written for specific environment. So, coverage identifies the new code as not covered. @harshkothari410 can you confirm this? |
Yes, that's right--Harsh is going to add all those in this week I hope. |
Yes environment test are remaining. It covers API and DB test only right now. I will add those because that requires some research because we need to compile some stuff for view test or change environment for env related test. @pallavi2209 @iamigo |
Using env var for new changes.
When env var us enables, subjects are filtered by tags, like GET /v1/subjects?tags=tag1,tag2
Added tests behind config var.