ajones05 / seearound.me-ionic

0 stars 0 forks source link

Adding categories #172

Closed ajones05 closed 7 years ago

ajones05 commented 7 years ago

Based on feedback, I finally decided to add five categories for posts. Here are the changes that will be involved. Let me know what you think and if you have any questions. I'll work with @yuriyua to make APIs. https://www.dropbox.com/sh/4n44h6h9nz6hv2u/AAAr3ljEIalWuFaMtb_F7twRa?dl=0

yuriyua commented 7 years ago

@abdulhafeez I think we can assign IDs to categories

id title
1 Food
2 Safety
3 Events
4 Development
5 Other
yuriyua commented 7 years ago

And add field category_id to api gateways

mobile/addimobinews mobile/myposts mobile/request-nearest

Are you agree?

ajones05 commented 7 years ago

@abdulhafeez does this work?

abdulhafeez commented 7 years ago

Yes, absolutely. That will be perfect.

yuriyua commented 7 years ago

@abdulhafeez done https://github.com/ajones05/seearound.me/issues/167#issuecomment-278293892

abdulhafeez commented 7 years ago

OK, I am almost done with UI. Once complete, I'll hookup with APIs and report here in case of issues.

abdulhafeez commented 7 years ago

@ajones05 What should be the default category? In case no category_id is present (for example in old posts).

ajones05 commented 7 years ago

For now we can add "Other" to all, but I will work with @yuriyua so I can update the categories of old posts.

abdulhafeez commented 7 years ago

I have done it. The APIs seem to be working fine.

ajones05 commented 7 years ago

@yuriyua I think @abdulhafeez will need your help for ability to toggle filters on/off. For example, here is how it would look if the Safety category is off (only posts that are "on" should be visible. Posts in categories that are toggled off should not be visible). map - with category icons and filter

abdulhafeez commented 7 years ago

I think it can be done on front end only. So, @yuriyua may not be required to do anything. One question: How would you cancel the filter? May be on hiding the filter panel?

yuriyua commented 7 years ago

ok, let me know if I can any help you. I added category id filter to mobile/myposts api.

https://github.com/ajones05/seearound.me/wiki/Mobile-Api-Reference/_compare/a6fe1f936df3606ac326044ba7170142163bf051...154a656a5c4bbb121d527623f0f3ba33a64c3be3

http://www.seearound.me/admin/mobile-api/myposts/token/N3VYMC4B594L53HSMY5Y3V5VVQ9AGND7RA6ENARTIVFPZZHLXMK1IQXFG6Q1V68M/latitude/37.81193351641144/longitude/-122.2842006693827/category_id/1/submit

http://www.seearound.me/admin/mobile-api/myposts/token/N3VYMC4B594L53HSMY5Y3V5VVQ9AGND7RA6ENARTIVFPZZHLXMK1IQXFG6Q1V68M/latitude/37.81193351641144/longitude/-122.2842006693827/category_id/2/submit

http://www.seearound.me/admin/mobile-api/myposts/token/N3VYMC4B594L53HSMY5Y3V5VVQ9AGND7RA6ENARTIVFPZZHLXMK1IQXFG6Q1V68M/latitude/37.81193351641144/longitude/-122.2842006693827/category_id/3/submit

http://www.seearound.me/admin/mobile-api/myposts/token/N3VYMC4B594L53HSMY5Y3V5VVQ9AGND7RA6ENARTIVFPZZHLXMK1IQXFG6Q1V68M/latitude/37.81193351641144/longitude/-122.2842006693827/category_id/4/submit

http://www.seearound.me/admin/mobile-api/myposts/token/N3VYMC4B594L53HSMY5Y3V5VVQ9AGND7RA6ENARTIVFPZZHLXMK1IQXFG6Q1V68M/latitude/37.81193351641144/longitude/-122.2842006693827/category_id/5/submit

ajones05 commented 7 years ago

How would you cancel the filter?

So nothing else should be needed to cancel the category filter.

abdulhafeez commented 7 years ago

Done. Looks to be working great. I am filtering on front end only i.e. only hiding and showing markers.

ajones05 commented 7 years ago

Great, thanks! I think front end only will not be enough, though. If I am understanding correctly, the front end only approach means that, for example: if all posts are in two categories and they are filtered out, then nothing will appear (on the map, at least), right?

I think this implementation is good, which will let the user see quickly how it's working. However, additionally, when the user hits "Filter" again to close the category options, the posts are refreshed from only the relevant categories. That will require help from @yuriyua but he will be doing the same for the desktop version, anyway.

yuriyua commented 7 years ago

Done. I updated category filter to multiple values: https://github.com/ajones05/seearound.me/wiki/Mobile-Api-Reference/_compare/154a656a5c4bbb121d527623f0f3ba33a64c3be3...adcd9c9d4aac8eb70e930e4e13de5e68fe4cdfd9

http://www.seearound.me/admin/mobile-api/myposts/token/N3VYMC4B594L53HSMY5Y3V5VVQ9AGND7RA6ENARTIVFPZZHLXMK1IQXFG6Q1V68M/latitude/37.81193351641144/longitude/-122.2842006693827/category_id/1/category_id/3/category_id/5/submit

@abdulhafeez you should send category id parameter name in multiple format:

...
&category_id[]=1
&category_id[]=3
&category_id[]=5
...
abdulhafeez commented 7 years ago

@ajones05 By "when posts are refreshed" do you mean when the user dismisses filter panel after filtering out and then goes to some other screen and later comes back to map?

abdulhafeez commented 7 years ago

If that is the case, we may need to add the filter (category_id[]=1 etc) to mobile/request-nearest api too.

abdulhafeez commented 7 years ago

BTW, I still think it can be done without any change on server side.

ajones05 commented 7 years ago

By "when posts are refreshed" do you mean when the user dismisses filter panel after filtering out and then goes to some other screen and later comes back to map?

No, I mean just when the user dismisses the filter panel. If changes have been made to the current categories, then the posts are refreshed with only posts from those categories, and this change would appear immediately on the map after the filter panel is dismissed (it would also remain in effect if user switches to list view).

abdulhafeez commented 7 years ago

Thanks! I think I can maintain a list of filters locally and filter out posts on any view. With this approach we can filter all posts from whichever API call they are coming. I don't see any advantage in doing it on server side. The disadvantage is that it becomes complex to manage filtered responses from different APIs. Or am I mistaken @yuriyua ?

abdulhafeez commented 7 years ago

@ajones05 It seems what I have already done is quicker than you expect. It hides the pins as soon as you touch a category. So, I am making an ios build before going further so you can see how it works and also other fixed issues.

ajones05 commented 7 years ago

OK sounds good. I thought it would only apply to the currently loaded posts (which would mean after filtering some categories out, the map could end up with only a few or even no pins on it if certain categories had few or no posts from those currently loaded), but from what you describe that sounds perfect. Either way it's probably best to see the current build so we are on the same page. Thanks!

yuriyua commented 7 years ago

I will do it from the server side. Should I save other search parameters?

ajones05 commented 7 years ago

I think it requires back-end implementation, because if I have filtered out certain categories and am scrolling through List View, for example, then only new posts from categories toggled on should be visible and continue to be loaded at the bottom.

Same for Map View: if I toggle off a category, like Food, then when I dismiss the Filter it should refresh map posts with just the other categories.

abdulhafeez commented 7 years ago

But I can filter out those posts locally for all views (which I have not yet done) ... this would be much faster than waiting for responses from server side.

yuriyua commented 7 years ago

I think it does no make sense to store this parameters from the server side. We can re-send category filter from cookies (or other way from the app).

ajones05 commented 7 years ago

But I can filter out those posts locally for all views (which I have not yet done) ... this would be much faster than waiting for responses from server side.

I see, OK I thought you had done what was possible already. So basically you would just load more posts initially and filter them out locally? That is what I thought you meant initially.

abdulhafeez commented 7 years ago

Exactly and this means @yuriyua does not have to do anything. Just let the server side remain as it was before. This way, yuriyua will not have to apply filters for request-nearest api nor for myposts.

ajones05 commented 7 years ago

Agreed, OK

abdulhafeez commented 7 years ago

@yuriyua can you reverse the change you made to myposts api for multiple filters?

yuriyua commented 7 years ago

@abdulhafeez Back category ID to single value?

abdulhafeez commented 7 years ago

Yes, exactly ... if it does not effect anything.

yuriyua commented 7 years ago

@ajones05 How should we make category filter on the site (multiple or single)?

abdulhafeez commented 7 years ago

You can keep it for site if sending no category_id parameter does not effect things. I will not send any param.

yuriyua commented 7 years ago

ok, I will back category id parameter to single value for api

yuriyua commented 7 years ago

DONE https://github.com/ajones05/seearound.me/wiki/Mobile-Api-Reference/_compare/adcd9c9d4aac8eb70e930e4e13de5e68fe4cdfd9...22ae8d51e4ef5e3f51c958325ee1975f2dfd6771

abdulhafeez commented 7 years ago

Thanks! All is fine now. However, I some times get 500 on request-nearest. Please make sure it stays same as it was before.

yuriyua commented 7 years ago

I will check logs, please let me know when it will happen again.

ajones05 commented 7 years ago

I think this implementation is good, which will let the user see quickly how it's working. However, additionally, when the user hits "Filter" again to close the category options, the posts are refreshed from only the relevant categories.

It works well to immediately show the filter changes. However, after I dismiss the filter panel, it still does not update the top 15 with just the active categories.

abdulhafeez commented 7 years ago

Are you talking about list view? The view should stay same after dismissing the categories popover.

ajones05 commented 7 years ago

No, I mean in map view. This is why: if most or all posts are in one or a few categories (like in this screenshot, where most are "food") then the user is simply looking at a blank map. img_4852

abdulhafeez commented 7 years ago

Sorry, I am still failing to understand this requirement. When the popover is dismissed, the map shows only the pins from selected categories. It is already that way. Why do you want to refresh the same view? It will result in the same view in same state. OR do you mean we should cancel all filters and show all pins when dismissed?

ajones05 commented 7 years ago

No problem, let me try to explain better. When the filter is dismissed, the user should again see the top 15 posts. However, now it is the top 15 with the filter applied. So in the screenshot above, after the filter is dismissed, it should show the top 15 posts in Safety, Events, Development, and Other -- but not Food. (Right now, it just shows an empty map, because all 15 top posts in this area right now are Food).

abdulhafeez commented 7 years ago

OK, that (the scene in the screen shot) is possibly after moving the circle to a different location?

ajones05 commented 7 years ago

Whether I move the screen or not, it does not show 15 map pins. It only shows (15 - (whatever is filtered off)). So for example it will show 0 or 3 or 6 or 11, but not 15 unless the filters that are off were not visible in the original 15 anyway

abdulhafeez commented 7 years ago

OK, I think I finally understood what you mean and unfortunately, we are back to the start ... this cannot be done on front end only. It involves back end. @yuriyua have you understood this requirement?

ajones05 commented 7 years ago

OK that's what I had thought. @yuriyua let me know if you need anything, but basically we need the API to do the same as on desktop.

yuriyua commented 7 years ago

DONE. I changed category filter query to order.

abdulhafeez commented 7 years ago

@yuriyua can you please guide me what params I need to send to get next top 15 filtered posts? on request-nearest api.