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] Add search functionality for event posts #222

Closed
KeremZaman opened this issue Dec 10, 2021 · 2 comments
Closed

[Backend] Add search functionality for event posts #222

KeremZaman opened this issue Dec 10, 2021 · 2 comments

Comments

@KeremZaman
Copy link
Collaborator

We need to add search functionality for event posts to filter posts by title, content, location, number of players etc. (as specified in API documentation).

@KeremZaman KeremZaman self-assigned this Dec 10, 2021
KeremZaman pushed a commit that referenced this issue Dec 12, 2021
- Add filtering by query, player capacity, spectators capacity, number of players, number of spectators, location name, event date, creation date, duration of the event, sport type, event owner, age, coordinates, skill levels

- Make relative imports absolute
KeremZaman pushed a commit that referenced this issue Dec 12, 2021
- Add unittests for event search functionality
- Configure test database
- Convert relative imports to absolute imports in serializers.py
KeremZaman pushed a commit that referenced this issue Dec 12, 2021
- Add testing command to run tests before starting application
- Add wait_for_db script for backend service to wait until database is ready
KeremZaman pushed a commit that referenced this issue Dec 12, 2021
test_filter_by_date was failing due to the default value of the date field in EventPost model. By quoting the related part about auto_now_add from django documentation:
" So even if you set a value for this field when creating the object, it will be ignored."

Since the dates specified for the sample events created for tests were ignored, date_by_filter test was failing. This bug would cause wrong event dates while user creating an event, it is fixed by changing default value to the time of the event creation.
@KeremZaman
Copy link
Collaborator Author

I implemented search functionality and added unittests. Also, made required changes in django settings and dockerfile to run tests before application starts.

Furthermore, tests helped me to discover a critical bug in Eventpost model. For the date field, auto_now_add was set True. According to the django documentation, even if we set date to a specific value while creating the object, auto_now_add will cause it to be ignored and set date to current time instead. This behavior would prevent users to set event dates, but it's fixed by giving current time manually as default value.

@KeremZaman
Copy link
Collaborator Author

Reviewed and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant