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

Pagination - I #54

Merged
merged 10 commits into from
Jan 24, 2024
Merged

Conversation

Parth858
Copy link
Contributor

@Parth858 Parth858 commented Jan 8, 2024

Added basic pagination as per Django documentation for jobs,user list view retrieved per page number of data is 2 (for sample) also added dynamic endpoint filters for get_jobs by category and get posted jobs with pagination.

Copy link
Collaborator

@HimanshuSharma-Angel HimanshuSharma-Angel left a comment

Choose a reason for hiding this comment

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

make sure to run your changes with different test cases.

Comment on lines 77 to 78
page_number = request.GET.get("page", 1)
paginator = Paginator(jobs_data, 5) # 5 items per page
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use it from constant, store it in constant.

apps/jobs/views.py Show resolved Hide resolved
@action(detail=False, methods=["get"])
def get_posted_jobs(self, request):
"""
API: localhost:8000/jobs/get_posted_jobs/
Copy link
Collaborator

Choose a reason for hiding this comment

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

base_url

Copy link
Contributor Author

@Parth858 Parth858 left a comment

Choose a reason for hiding this comment

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

As Discussed With FE the code has been updated with filters which can retrieve jobs as per the user preference dynamically.

@@ -427,6 +428,54 @@ def get_job_categories(self, request):
serialized_job_categories, status.HTTP_200_OK
)

@action(detail=False, methods=["get"])
def get_jobs(self, request):
Copy link
Contributor Author

@Parth858 Parth858 Jan 15, 2024

Choose a reason for hiding this comment

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

  1. Retrive jobs as per quary parameter also jobs where exp <=3.
request: http://localhost:8000/jobs/get_jobs/?category=Security&experience=3

response: { {
            "job_id": "beb1b9dc-5106-423c-95e8-efbbc0103d8b",
            "job_role": "Security Analysist II",
            "location": "Mumbai",
            "post_date": "2023-10-11",
            "posted": true,
            "experience": 0,
            "created_at": "2024-01-11T18:07:00.626348Z",
            "updated_at": "2024-01-11T18:07:00.626348Z",
            "employer_id": "5e1f2925-9deb-492f-8a06-f451daf9310a",
            "job_type": "full time",
            "salary": "30000.00",
            "qualifications": "OWASP",
            "vacency_position": 5,
            "industry": "IT",
            "category": "Security",
            "is_active": true,
            "company": "d937d8f3-6c54-4bf2-b652-e44597910693",
            "description": {
                "About": "You will be responsible for designing, developing, testing, and deploying distributed machine learning systems and large-scale solutions for our world-wide customer base",
                "Job Responsibilities": "No Job Responsibilities provided",
                "Skills Required": "No skills details provided",
                "Educations/Certifications": "No Education details provided"
            }
        },
        {
            "job_id": "c8fddf51-644e-42a7-8ef1-d91178dbf22d",
            "job_role": "Junior Developer",
            "location": "Mumbai",
            "post_date": "2023-10-11",
            "posted": true,
            "experience": 3,
            "created_at": "2024-01-19T12:41:51.821701Z",
            "updated_at": "2024-01-19T12:41:51.829724Z",
            "employer_id": "5e1f2925-9deb-492f-8a06-f451daf9310a",
            "job_type": "full time",
            "salary": "30000.00",
            "qualifications": "OWASP",
            "vacency_position": 5,
            "industry": "IT",
            "category": "Security",
            "is_active": true,
            "company": "d937d8f3-6c54-4bf2-b652-e44597910693",
            "description": {
                "About": "Manage the group of people as well as make the upcomming task secure.",
                "Job Responsibilities": "No Job Responsibilities provided",
                "Skills Required": "No skills details provided",
                "Educations/Certifications": "No Education details provided"
            }
  1. Dynamically retriving of jobs as per the queary updation
request: http://localhost:8000/jobs/get_jobs/?job_type=full time
response: {
            "job_id": "be5f509a-855a-4de8-b13e-7cb6cf2243fc",
            "job_role": "Product Manager",
            "location": "California",
            "post_date": "2023-10-11",
            "posted": true,
            "experience": 0,
            "created_at": "2024-01-11T17:58:36.746918Z",
            "updated_at": "2024-01-11T17:58:36.746918Z",
            "employer_id": "5e1f2925-9deb-492f-8a06-f451daf9310a",
            "job_type": "full time",
            "salary": "20000.00",
            "qualifications": "Commerces, Data Managment",
            ...

Copy link
Collaborator

@HimanshuSharma-Angel HimanshuSharma-Angel left a comment

Choose a reason for hiding this comment

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

approving @Himan10 please validate

COVER_LETTER_DOCUMENT_TYPE = "cover_letter"

ITEMS_PER_PAGE = 5
PAST_3_WEEK_DATETIME_DAYS18 = 18
Copy link
Collaborator

Choose a reason for hiding this comment

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

change the variable name to something else, something that resembles to the functionality for which we are using it.

Copy link
Contributor Author

@Parth858 Parth858 Jan 19, 2024

Choose a reason for hiding this comment

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

lets not change the name they are as we discussed and as per the functionality.

@Himan10
Copy link
Collaborator

Himan10 commented Jan 18, 2024

@Parth858 share the latest request/response of the API endpoints present in this PR.

Copy link
Contributor Author

@Parth858 Parth858 left a comment

Choose a reason for hiding this comment

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

I have added the latest API endpoints with its request/response.

@@ -355,6 +368,82 @@ def featured_jobs(self, request):
response.SOMETHING_WENT_WRONG, status.HTTP_500_INTERNAL_SERVER_ERROR
)

@action(detail=False, methods=["get"])
def get_posted_jobs(self, request):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(update sample response where per page items are 3 )

request: http://localhost:8000/jobs/get_posted_jobs/?page=2
response:  "data": [
        {
            "job_id": "beb1b9dc-5106-423c-95e8-efbbc0103d8b",
            "job_role": "Security Analysist II",
            "location": "Mumbai",
            "post_date": "2023-10-11",
            "posted": true,
            "experience": 0,
            "created_at": "2024-01-11T18:07:00.626348Z",
            "updated_at": "2024-01-11T18:07:00.626348Z",
            "employer_id": "5e1f2925-9deb-492f-8a06-f451daf9310a",
            "job_type": "full time",
            "salary": "30000.00",
            "qualifications": "OWASP",
            "vacency_position": 5,
            "industry": "IT",
            "category": "Security",
            "is_active": true,
            "company": "d937d8f3-6c54-4bf2-b652-e44597910693",
            "description": {
                "About": "You will be responsible for designing, developing, testing, and deploying distributed machine learning systems and large-scale solutions for our world-wide customer base",
                "Job Responsibilities": "No Job Responsibilities provided",
                "Skills Required": "No skills details provided",
                "Educations/Certifications": "No Education details provided"
            },
            "Number of Applicants": 0
        },
        {
            "job_id": "c8fddf51-644e-42a7-8ef1-d91178dbf22d",
            "job_role": "Junior Developer",
            "location": "Mumbai",
            "post_date": "2023-10-11",
            "posted": true,
            "experience": 3,
            "created_at": "2024-01-19T12:41:51.821701Z",
            "updated_at": "2024-01-19T12:41:51.829724Z",
            "employer_id": "5e1f2925-9deb-492f-8a06-f451daf9310a",
            "job_type": "full time",
            "salary": "30000.00",
            "qualifications": "OWASP",
            "vacency_position": 5,
            "industry": "IT",
            "category": "Security",
            "is_active": true,
            "company": "d937d8f3-6c54-4bf2-b652-e44597910693",
            "description": {
                "About": "Manage the group of people as well as make the upcomming task secure.",
                "Job Responsibilities": "No Job Responsibilities provided",
                "Skills Required": "No skills details provided",
                "Educations/Certifications": "No Education details provided"
            },
            "Number of Applicants": 0
        },
        {
            "job_id": "fc52dbad-8a83-4276-99be-a61104234ff9",
            "job_role": "Unit Tester",
            "location": "California",
            "post_date": "2023-10-11",
            "posted": true,
            "experience": 0,
            "created_at": "2024-01-11T18:02:26.112538Z",
            "updated_at": "2024-01-11T18:02:26.112538Z",
            "employer_id": "5e1f2925-9deb-492f-8a06-f451daf9310a",
            "job_type": "full time",
            "salary": "20000.00",
            "qualifications": "Commerces, Data Managment",
            "vacency_position": 3,
            "industry": "IT",
            "category": "Testing",
            "is_active": true,
            "company": "b2490ff9-cb56-4627-9653-921051267074",
            "description": {
                "About": "You will be responsible for designing, developing, testing, and deploying distributed machine learning systems and large-scale solutions for our world-wide customer base",
                "Job Responsibilities": "No Job Responsibilities provided",
                "Skills Required": "No skills details provided",
                "Educations/Certifications": "No Education details provided"
            },
            "Number of Applicants": 0
        }
    ]
}

Copy link
Collaborator

@hims1911 hims1911 left a comment

Choose a reason for hiding this comment

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

lgtm @Himan10 you can merge

@Himan10 Himan10 merged commit 13cf3dc into null-open-security-community:main Jan 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants