-
Notifications
You must be signed in to change notification settings - Fork 61
Conversation
b523542
to
f117cbc
Compare
TODO: fix tests :x |
Changes Unknown when pulling 223d493 on rogeriochaves:issue-122 into ** on datasciencebr:master**. |
223d493
to
f596cf9
Compare
Changes Unknown when pulling f596cf9 on rogeriochaves:issue-122 into ** on datasciencebr:master**. |
Done, I haven't add any new tests, but at least I believe I haven't reduced coverage either |
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.
Wow! This is way better than what we had. Many many thanks!
I added two minor inline comments, once we can rule them out this is good to merge!
label | ||
|
||
|
||
getLabelTranslation : Language -> Field -> String |
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.
Do we really need to move translations out of the Internationalization
module? I know Internationalization.elm
is a long file that we could break down, but somehow having all translations in the same module is a good thing (even if we break this module down in submodules).
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.
I agree, I scratched my head with the same point, but decided to give it a try to see how it looked. I too I like having them centralized, I'll move back.
>>> toUrl [ ( "year", "2016" ), ( "foo", "bar" ) ] | ||
"#/year/2016" | ||
|
||
>>> toUrl [ ( "foo", "bar" ) ] |
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.
This comments were here because they are tests (elm-doc-test). Any special reason not to test the function with invalid query parameters?
Is there an implicit assumption that they mean no harm so I shouldn't be worried? That could be true, this might be just my OCD hahaha…
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.
as fair as I remember, there was no way in the code that this function would have been called with an invalid value, or that wouldn't be a problem, I don't remember now. In fact, maybe we couldn't guarantee that just by looking at this function, maybe the ideal would be having an integration test.
But I'll look again and get back here.
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, I've changed the code to reduce confusion - or maybe cause more :x
I noticed that the toUrl
function was only getting called when we had full control of the variables that were being passed to it, therefore we didn't need that isSearchable check. But that wasn't obvious neither guaranteed without an integration test, cause maybe another function could end up using this one, without passing the right params.
I also noted that toUrl
was always getting called together with toQuery
, we had to call one to then pass as argument to the other.
So what I did was moving the toUrl
function to Search/Update.elm
, since it is only used to build search urls, and now it take the fields as arguments, not query, and return a clean url, so it is no longer possible to pass weird params to it and get a malformed url.
And the page
case is just a string appending
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.
69b91c0 🍾 ✨ Awesome ; )
The coverage just targets Python backend. I see little usage for coverage in Elm as a lot can be taken for granted just by the fact it compiled ; ) |
@cuducos yeah, I meant, the imaginary coverage for Elm hahahaha |
f596cf9
to
80c3fb4
Compare
Changes Unknown when pulling 80c3fb4 on rogeriochaves:issue-122 into ** on datasciencebr:master**. |
Changes Unknown when pulling aa75264 on rogeriochaves:issue-122 into ** on datasciencebr:master**. |
a869836
to
203f210
Compare
Changes Unknown when pulling 203f210 on rogeriochaves:issue-122 into ** on datasciencebr:master**. |
Changes Unknown when pulling 203f210 on rogeriochaves:issue-122 into ** on datasciencebr:master**. |
203f210
to
70be535
Compare
70be535
to
6d9e509
Compare
Changes Unknown when pulling 6d9e509 on rogeriochaves:issue-122 into ** on datasciencebr:master**. |
Changes Unknown when pulling 6d9e509 on rogeriochaves:issue-122 into ** on datasciencebr:master**. |
Changes Unknown when pulling 69b91c0 on rogeriochaves:issue-122 into ** on datasciencebr:master**. |
I think that after 69b91c0 we're LGTM… or are you planning to refactor something else? |
@cuducos yes, I am, but not in this branch, refactors are good to be done in pieces to avoid conflicts (: merge it away! |
This is part of #122
I believe it was really a good idea to take this approach, things are simpler now imo. Some problems I've found:
What I did:
So, for me, it looks like the code is simpler now, as Search doesn't have to manage translation and mdl, translation is only done at rendering time.
It is easier to understand, since we have less primitives and more types, we can look at function signature and understand what values it takes and what it do as not everything is a String, also creating more safety to the programmer. Then I've figured that not every value need to map to a string key, only the ones that will get on the url, the searchable ones.
Also, Inputs is too technical of a name, Search clarifies better what this part of the code do imo.
A few lessons learned:
What you think? I believe if you look commit by commit it is easier to understand the changes, let me know if you don't agree on some of those refactorings.
Cheers