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

#Refocus get /subjects filtering by tag working #68

Merged
merged 3 commits into from
Oct 24, 2016

Conversation

pallavi2209
Copy link
Contributor

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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 83.173% when pulling 4d25141 on subject-filter-by-tag into a402180 on master.

iamigo
iamigo previously requested changes Oct 21, 2016
in: query
items:
type: string
maxLength: 60
Copy link
Contributor

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.)

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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:

  1. Filter on API layer instead of query level, like hierarchy endpoint. Disadvantage: get all subjects first and then extra processing to filter.
  2. 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.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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;
Copy link
Contributor

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)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 83.173% when pulling f3d4ae4 on subject-filter-by-tag into 897cc42 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 83.173% when pulling 30cf7ae on subject-filter-by-tag into 897cc42 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 83.173% when pulling 47c49ac on subject-filter-by-tag into 5026e15 on master.

@pallavi2209 pallavi2209 force-pushed the subject-filter-by-tag branch 2 times, most recently from 0e3cd1d to 8d6489b Compare October 24, 2016 18:09
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 83.173% when pulling 8d6489b on subject-filter-by-tag into 5026e15 on master.

@iamigo iamigo dismissed their stale review October 24, 2016 18:19

pushing additional work into separate story

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 83.173% when pulling 2af7b2a on subject-filter-by-tag into eb5ae26 on master.

@iamigo
Copy link
Contributor

iamigo commented Oct 24, 2016

uh oh coverage decreased! :(

@pallavi2209
Copy link
Contributor Author

@iamigo @shriramshankar updated the PR

@pallavi2209
Copy link
Contributor Author

@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?

@iamigo
Copy link
Contributor

iamigo commented Oct 24, 2016

Yes, that's right--Harsh is going to add all those in this week I hope.

@harshkothari410
Copy link
Contributor

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

@shriramshankar shriramshankar merged commit 85e8e2e into master Oct 24, 2016
@iamigo iamigo deleted the subject-filter-by-tag branch October 24, 2016 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants