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

[Backend] Post search based on distance #450

Merged
merged 1 commit into from
Dec 18, 2022

Conversation

irfanbozkurt
Copy link
Member

Description:

Based on my research last week (see finalized results here), today I decided to implement Spherical Law of Cosines in a query for distance-based search queries.

Here's the query:
Screen Shot 2022-12-17 at 16 57 57

Todo's:

  • Find a way to add this custom query into Django's filtering
  • Implement the search endpoint

Task Deadline: 17.12.2022 22:00

@irfanbozkurt irfanbozkurt added Type: Enhancement New features via code and/or design. Team: Backend Backend based work - for backend team labels Dec 17, 2022
@irfanbozkurt irfanbozkurt self-assigned this Dec 17, 2022
@irfanbozkurt
Copy link
Member Author

I had to completely change the search endpoint to only send raw queries to the database. Although it was challenging, I found a way to implement desired functionality.

@irfanbozkurt
Copy link
Member Author

Usage:
If you add a "dist" parameter to the post search endpoint, you should also pass "longitude" and "latitude" parameters; and the endpoint will only bring you posts that were created within "dist" kilometers.
Screen Shot 2022-12-17 at 21 41 14

@irfanbozkurt
Copy link
Member Author

I added the usage information to the old documentation as well. Other teams can refer to there.

Copy link
Contributor

@oguzhandemirelx oguzhandemirelx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A wonderful improvement, my friend. I tested the changes locally and had no issues. Merged!

@oguzhandemirelx oguzhandemirelx merged commit adbaa06 into master Dec 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team: Backend Backend based work - for backend team Type: Enhancement New features via code and/or design.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants