Closed hupili closed 10 years ago
I suppose I have no strong preference one way or the other. The only thing was that the $http
service on the front end automatically encoded it like area=a01&area=a02
. It should be easy to send as comma separated.
If you think that comma separated (or pipe separated) is better, then we can go ahead and do that.
Yesterday when coding the sample app with @vincentlaucy and @2blam , we find that comma separated list is more intuitive. I prefer to use ,
to make it more compact.
Ok, let's do it then. On Feb 10, 2014 9:55 PM, "HU, Pili" notifications@github.com wrote:
Yesterday when coding the sample app with @vincentlaucyhttps://github.com/vincentlaucyand @2blam https://github.com/2blam , we find that comma separated list is more intuitive. I prefer to use , to make it more compact.
— Reply to this email directly or view it on GitHubhttps://github.com/hxu/hk_census_explorer/issues/33#issuecomment-34633308 .
closed by pull #34
Do you think it is more correct to url encode first, then join with commas, or join with commas first, then url encode (i.e. should the commas be escaped)? Of course it is more readable if we do not escape the commas, so I think that is preferable, unless there are some edge cases I am not thinking of?
I prefer non-encoded comma. As for content, I have checked that we don't have comma in identifiers, so the direct frontend join and backend split should be OK.
After making a test app, we find that current query string can be too long due to repeated occurrences of keys. Another issues is the string does not read semantically smooth.
table=18&area=a01
is clear. The two filtering conditions are logicallyand
-ed. (aka originally meaning of&
)When we write
table=18&area=a01&area=a02
, we actually meantable=18 & (area=a01 | area=a02)
.area=a01,a02
orarea=a01|a02
reads better. Same forreturn
.The glitch is more obvious when it comes to zero v.s. non-zero number of occurrences. Without
area
, it means to return data of all areas. With onearea
, it suddenly filters down to one area. The change from&
to&area=a01
to&area=a01&area=a02
is not so smooth. Using the,
style, the change from&area=
to&area=a01
to&area=a01,a02
... to&
(do not filter), is smooth.