Skip to content

Refactor job filtering logic and improve expiry calculation#66

Closed
priyanshuuu777 wants to merge 2 commits intonumfocus:mainfrom
priyanshuuu777:fix-filter-jobs
Closed

Refactor job filtering logic and improve expiry calculation#66
priyanshuuu777 wants to merge 2 commits intonumfocus:mainfrom
priyanshuuu777:fix-filter-jobs

Conversation

@priyanshuuu777
Copy link
Contributor

Summary

Refactored the filterJobs function for better readability and reliability.

Improvements

  • Simplified filtering using Array.filter()
  • Optimized 30-day expiry calculation
  • Added safer OSS parsing
  • Improved remote matching logic
  • Added default parameter handling

No breaking changes.

@stefanv
Copy link
Collaborator

stefanv commented Feb 17, 2026

Thanks for your suggested contribution, @priyanshuuu777. Please:

  1. List the tools used to produce this PR.
  2. Provide a justification for the changes.
  3. Split up changes: one patch per change, so we can apply them selectively.

@priyanshuuu777
Copy link
Contributor Author

This PR was created using:

Node.js (for local testing)

Modern JavaScript (ES6+)

VS Code (development environment)

Git for version control

Readability – Switched to Array.filter() for a more declarative approach.

Maintainability – Simplified expiration logic using a constant instead of day calculations.

Safety – Added default parameters and safer numeric parsing to prevent runtime errors.

Robustness – Improved remote matching logic to handle case-insensitive values.

Refactored loop-based filtering to use Array.filter() for improved readability.
Replaced day-difference calculation with a fixed 30-day millisecond constant for clarity and performance.
Improved parsing of ossTimeGt using numeric validation to prevent NaN issues.
Replaced string includes check with case-insensitive regex for more flexible matching.
Added default values for jobs and filter parameters to prevent runtime crashes when undefined.

@stefanv
Copy link
Collaborator

stefanv commented Feb 17, 2026

No, I meant which agent.

Please split into one commit per change, with a detailed message motivating that commit.

@priyanshuuu777
Copy link
Contributor Author

This PR was produced manually by me.
No automated refactoring tools or code-generation agents were used.

refactor: replace imperative loop with Array.filter for clearer logic

Replaced the manual for-loop and include flag pattern with
Array.filter() to make the filtering logic more declarative
and easier to reason about.

This reduces mutable state, removes nested condition checks,
and aligns the function with modern JavaScript best practices.

No behaviour changes intended.

2
refactor: simplify job expiry calculation using fixed 30-day constant

Replaced day-difference computation with a direct millisecond
comparison using a 30-day constant.

This improves clarity and avoids unnecessary Math.ceil and
absolute value calculations while preserving existing behavior.

3
fix: validate ossTimeGt parsing to prevent NaN edge cases

Improved parsing of ossTimeGt by validating numeric input before
conversion. This prevents unintended comparisons when invalid
values (e.g., non-numeric strings) are provided.

Behaviour remains unchanged for valid numeric inputs.

4
refactor: use case-insensitive regex for remote location matching

Replaced string includes check with case-insensitive regex
to ensure matching works reliably for values like
"Remote", "remote", or "REMOTE".

Improves robustness without changing intended behavior.

5
refactor: add default parameters for jobs and filter

Added default values to prevent runtime errors when
undefined arguments are passed to filterJobs.

This makes the function more defensive and safer to reuse
in different contexts.

- Refresh styling with cleaner, modern design
- Add smooth hover effects and improved shadows
- Switch to CSS Grid for responsive layout
- Improve filter sidebar with rounded corners
- Add mobile responsiveness
- Update dependencies (dompurify, gatsby)
@priyanshuuu777 priyanshuuu777 marked this pull request as draft February 17, 2026 16:07
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.

2 participants