Skip to content

feat(fb): implement submission CRUD service - #64

Merged
muratmuzaffer merged 3 commits into
mainfrom
feat/submission-CRUD-service
Jan 21, 2026
Merged

feat(fb): implement submission CRUD service#64
muratmuzaffer merged 3 commits into
mainfrom
feat/submission-CRUD-service

Conversation

@muratmuzaffer

@muratmuzaffer muratmuzaffer commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Implements the submission service layer for managing form submissions as specified in issue #48.

Added

  • SubmissionService class in services/form/app/services/submission_service.py
  • Three core async methods:
    • create_submission() - Creates submission with form validation
    • get_submission_by_id() - Retrieves submission by ID
    • get_submissions_by_form_id() - Paginated submission list (default: 10, max: 100)
  • Form validation:
    • Checks if form exists
    • Checks if form is active
    • Checks if form has started (start_date)
    • Checks if deadline has not passed (deadline)
  • Atomic submission_count increment on form
  • Export from app/services/__init__.py

Technical Details

  • All methods use async/await pattern
  • Uses Motor async driver for MongoDB operations
  • Uses await cursor.to_list(length=limit) for pagination
  • Raises ValueError for business logic errors
  • Re-raises PyMongoError for database errors
  • Handles timezone-naive/aware datetime comparison

Related Issue

Closes #48

Checklist

@muratmuzaffer muratmuzaffer self-assigned this Jan 20, 2026
@muratmuzaffer muratmuzaffer added the enhancement New feature or request label Jan 20, 2026

@DogukanUrker DogukanUrker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

WAY better than the prev. PR - just have a few things to consider. than we good to go. good job!!

Comment thread services/form/.env.example
Comment thread services/form/app/services/submission_service.py
Comment thread services/form/app/services/submission_service.py
- Add ObjectId.is_valid() validation in _to_object_id
- Restore .env.example file
@muratmuzaffer

Copy link
Copy Markdown
Contributor Author

.env.example deletion
Reverted. the file is now restored. Sorry for the scope creep!

Regarding ObjectId.is_valid() validation
Added validation as suggested. Now raises ValueError for invalid ObjectId strings instead of bson.errors.InvalidId, keeping error handling consistent with the rest of the service.

@DogukanUrker
DogukanUrker self-requested a review January 21, 2026 08:51

@DogukanUrker DogukanUrker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good now, you can merge it whenever

@muratmuzaffer
muratmuzaffer merged commit fbaeef2 into main Jan 21, 2026
2 checks passed
@muratmuzaffer
muratmuzaffer deleted the feat/submission-CRUD-service branch January 21, 2026 19:04
@muratmuzaffer

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback!

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

Labels

backend enhancement New feature or request form

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(fb): implement submission CRUD service

2 participants