updated sorting

This commit is contained in:
Vishwa Gaurav
2022-06-29 16:03:42 +05:30
parent d4c790f274
commit f61aeec7e4
2 changed files with 23 additions and 9 deletions

View File

@@ -20,7 +20,7 @@ function Query(queryObj) {
this.remoteFilter = queryObj.remoteFilter || "";
this.salary = queryObj.salary || "";
this.experienceLevel = queryObj.experienceLevel || "";
this.sortBy = queryObj.sortBy || "";
//internal variable
this.limit = Number(queryObj.limit) || 0;
}
@@ -84,13 +84,6 @@ Query.prototype.getSalary = function () {
};
return salaryRange[this.salary.toLowerCase()] ?? "";
};
Query.prototype.getSortBy = function () {
const sortBy = {
recent: "DD",
relevant: "R",
};
return sortBy[this.salary.toLowerCase()] ?? "";
};
/*
* EXAMPLE OF A SAMPLE QUERY
@@ -114,7 +107,11 @@ Query.prototype.url = function (start) {
if (this.getRemoteFilter() !== "") query += `&f_WT=${this.getRemoteFilter()}`;
if (this.getJobType() !== "") query += `&f_JT=${this.getJobType()}`;
query += `&start=${start}`;
if (this.sortBy !== "") query += `&sortBy=${this.getSortBy}`;
if (this.sortBy == "recent" || this.sortBy == "relevant") {
let sortMethod = "R";
if (this.sortBy == "recent") sortMethod = "DD";
query += `&sortBy=${sortMethod}`;
}
return encodeURI(query);
};

17
test.js Normal file
View File

@@ -0,0 +1,17 @@
const linkedIn = require('./index');
const queryOptions = {
keyword: 'software engineer',
location: 'los angeles',
dateSincePosted: 'past Week',
jobType: 'full time',
remoteFilter: 'remote',
salary: '100000',
experienceLevel: 'entry level',
limit: '1',
sortBy: 'recent'
};
linkedIn.query(queryOptions).then(response => {
console.log(response); // An array of Job objects
});