optimize the background jobs
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using BoredCareers.Entities;
|
||||
using BoredCareers.Services.TimerService;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
@@ -177,12 +178,12 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
return joblisting;
|
||||
}
|
||||
|
||||
public async Task<JobListing[]> GetJobListingsPastExipre() {
|
||||
List<JobListing> joblistings = new List<JobListing>();
|
||||
public async Task<JobListingDTO[]> GetJobListingsPastExipre() {
|
||||
List<JobListingDTO> joblistings = new List<JobListingDTO>();
|
||||
using (MySqlConnection connection = GetConnection()) {
|
||||
await connection.OpenAsync();
|
||||
string command = @"
|
||||
SELECT *
|
||||
SELECT ID, CompanyID
|
||||
FROM JobListing
|
||||
WHERE IsDeleted = FALSE
|
||||
AND CreatedTime < NOW() - INTERVAL 1 MONTH;
|
||||
@@ -193,38 +194,9 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
while (await reader.ReadAsync()) {
|
||||
int _id = reader.GetInt32("ID");
|
||||
int _companyid = reader.GetInt32("CompanyID");
|
||||
string _title = reader.GetString("Title");
|
||||
string _postalcode = reader.GetString("PostalCode");
|
||||
string _country = reader.GetString("Country");
|
||||
string _state = reader.GetString("StateOrRegion");
|
||||
string _city = reader.GetString("City");
|
||||
int _salarymin = reader.GetInt32("SalaryMin");
|
||||
int _salarymax = reader.GetInt32("SalaryMax");
|
||||
string _jobtype = reader.GetString("JobType");
|
||||
bool _remote = reader.GetBoolean("Remote");
|
||||
string _description = reader.GetString("Description");
|
||||
JobListingSkill[] _skills = await GetJobListingSkills(_id);
|
||||
DateTime _createtime = reader.GetDateTime("CreatedTime");
|
||||
DateTime _modifiedtime = reader.GetDateTime("ModifiedTime");
|
||||
bool _isdeleted = reader.GetBoolean("IsDeleted");
|
||||
|
||||
joblistings.Add(new JobListing() {
|
||||
ID = _id,
|
||||
CompanyID = _companyid,
|
||||
Title = _title,
|
||||
PostalCode = _postalcode,
|
||||
Country = _country,
|
||||
StateOrRegion = _state,
|
||||
City = _city,
|
||||
SalaryMin = _salarymin,
|
||||
SalaryMax = _salarymax,
|
||||
JobType = _jobtype,
|
||||
Remote = _remote,
|
||||
Description = _description,
|
||||
Skills = _skills,
|
||||
CreatedTime = _createtime,
|
||||
ModifiedTime = _modifiedtime,
|
||||
IsDeleted = _isdeleted
|
||||
joblistings.Add(new JobListingDTO() {
|
||||
JobListingID = _id,
|
||||
CompanyID = _companyid
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user