test
This commit is contained in:
parent
ff547470b2
commit
8766eb3b1f
2 changed files with 114 additions and 97 deletions
72
.github/workflows/release.yaml
vendored
72
.github/workflows/release.yaml
vendored
|
|
@ -67,40 +67,40 @@ jobs:
|
||||||
docker compose pull
|
docker compose pull
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
|
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
|
||||||
- name: Notify Discord Success
|
# - name: Notify Discord Success
|
||||||
if: success()
|
# if: success()
|
||||||
run: |
|
# run: |
|
||||||
curl -H "Content-Type: application/json" \
|
# curl -H "Content-Type: application/json" \
|
||||||
-X POST \
|
# -X POST \
|
||||||
-d '{
|
# -d '{
|
||||||
"embeds": [{
|
# "embeds": [{
|
||||||
"title": "✅ Deployment Success!",
|
# "title": "✅ Deployment Success!",
|
||||||
"description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
|
# "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
|
||||||
"color": 3066993,
|
# "color": 3066993,
|
||||||
"footer": {
|
# "footer": {
|
||||||
"text": "Release Notification",
|
# "text": "Release Notification",
|
||||||
"icon_url": "https://example.com/success-icon.png"
|
# "icon_url": "https://example.com/success-icon.png"
|
||||||
},
|
# },
|
||||||
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
|
# "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
|
||||||
}]
|
# }]
|
||||||
}' \
|
# }' \
|
||||||
${{ secrets.DISCORD_WEBHOOK }}
|
# ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
|
|
||||||
- name: Notify Discord Failure
|
# - name: Notify Discord Failure
|
||||||
if: failure()
|
# if: failure()
|
||||||
run: |
|
# run: |
|
||||||
curl -H "Content-Type: application/json" \
|
# curl -H "Content-Type: application/json" \
|
||||||
-X POST \
|
# -X POST \
|
||||||
-d '{
|
# -d '{
|
||||||
"embeds": [{
|
# "embeds": [{
|
||||||
"title": "❌ Deployment Failed!",
|
# "title": "❌ Deployment Failed!",
|
||||||
"description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
|
# "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
|
||||||
"color": 15158332,
|
# "color": 15158332,
|
||||||
"footer": {
|
# "footer": {
|
||||||
"text": "Release Notification",
|
# "text": "Release Notification",
|
||||||
"icon_url": "https://example.com/failure-icon.png"
|
# "icon_url": "https://example.com/failure-icon.png"
|
||||||
},
|
# },
|
||||||
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
|
# "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
|
||||||
}]
|
# }]
|
||||||
}' \
|
# }' \
|
||||||
${{ secrets.DISCORD_WEBHOOK }}
|
# ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
|
|
|
||||||
|
|
@ -183,19 +183,26 @@ namespace BMA.EHR.Recruit.Service.Services
|
||||||
// 🚀 Prepare HTTP client once
|
// 🚀 Prepare HTTP client once
|
||||||
var httpClient1 = new HttpClient();
|
var httpClient1 = new HttpClient();
|
||||||
httpClient1.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token?.Replace("Bearer ", ""));
|
httpClient1.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token?.Replace("Bearer ", ""));
|
||||||
|
Console.WriteLine("118");
|
||||||
httpClient1.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
httpClient1.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||||
|
Console.WriteLine("117");
|
||||||
var apiUrl1 = $"{_configuration["API"]}/api/v1/org/pos/level";
|
var apiUrl1 = $"{_configuration["API"]}/api/v1/org/pos/level";
|
||||||
|
Console.WriteLine("116");
|
||||||
var response1 = await httpClient1.GetStringAsync(apiUrl1);
|
var response1 = await httpClient1.GetStringAsync(apiUrl1);
|
||||||
|
Console.WriteLine("115");
|
||||||
var posOptions = JsonConvert.DeserializeObject<RecruitPosRequest>(response1);
|
var posOptions = JsonConvert.DeserializeObject<RecruitPosRequest>(response1);
|
||||||
|
Console.WriteLine("114");
|
||||||
|
|
||||||
var recruitImport = await _context.RecruitImports.AsQueryable()
|
var recruitImport = await _context.RecruitImports.AsQueryable()
|
||||||
.FirstOrDefaultAsync(x => x.Id == examId);
|
.FirstOrDefaultAsync(x => x.Id == examId);
|
||||||
|
|
||||||
|
Console.WriteLine("113");
|
||||||
if (recruitImport == null)
|
if (recruitImport == null)
|
||||||
throw new Exception(GlobalMessages.DataNotFound);
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
|
||||||
var _placement = await _contextMetadata.Placements.AsQueryable()
|
var _placement = await _contextMetadata.Placements.AsQueryable()
|
||||||
.FirstOrDefaultAsync(x => x.PlacementType.Name == "สอบแข่งขัน" && x.RefId == recruitImport.Id);
|
.FirstOrDefaultAsync(x => x.PlacementType.Name == "สอบแข่งขัน" && x.RefId == recruitImport.Id);
|
||||||
|
Console.WriteLine("112");
|
||||||
// if (_placement != null)
|
// if (_placement != null)
|
||||||
// throw new Exception("รอบการสอบนี้ได้ทำการบรรจุไปแล้ว");
|
// throw new Exception("รอบการสอบนี้ได้ทำการบรรจุไปแล้ว");
|
||||||
|
|
||||||
|
|
@ -205,6 +212,7 @@ namespace BMA.EHR.Recruit.Service.Services
|
||||||
var districtsCache = await _contextOrg.district.ToListAsync();
|
var districtsCache = await _contextOrg.district.ToListAsync();
|
||||||
var subDistrictsCache = await _contextOrg.subDistrict.ToListAsync();
|
var subDistrictsCache = await _contextOrg.subDistrict.ToListAsync();
|
||||||
var educationLevelsCache = await _contextOrg.educationLevel.ToListAsync();
|
var educationLevelsCache = await _contextOrg.educationLevel.ToListAsync();
|
||||||
|
Console.WriteLine("101");
|
||||||
|
|
||||||
var placement = new Placement
|
var placement = new Placement
|
||||||
{
|
{
|
||||||
|
|
@ -224,6 +232,7 @@ namespace BMA.EHR.Recruit.Service.Services
|
||||||
LastUpdateFullName = FullName ?? "",
|
LastUpdateFullName = FullName ?? "",
|
||||||
};
|
};
|
||||||
await _contextMetadata.Placements.AddAsync(placement);
|
await _contextMetadata.Placements.AddAsync(placement);
|
||||||
|
Console.WriteLine("191");
|
||||||
|
|
||||||
// 🚀 Load all related data with single queries
|
// 🚀 Load all related data with single queries
|
||||||
var candidates = await _context.Recruits.AsQueryable()
|
var candidates = await _context.Recruits.AsQueryable()
|
||||||
|
|
@ -250,6 +259,7 @@ namespace BMA.EHR.Recruit.Service.Services
|
||||||
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token?.Replace("Bearer ", ""));
|
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token?.Replace("Bearer ", ""));
|
||||||
httpClient.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
httpClient.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||||
|
|
||||||
|
Console.WriteLine("181");
|
||||||
// 🚀 Batch HTTP requests
|
// 🚀 Batch HTTP requests
|
||||||
var orgTasks = candidates.Select(async candidate =>
|
var orgTasks = candidates.Select(async candidate =>
|
||||||
{
|
{
|
||||||
|
|
@ -267,6 +277,7 @@ namespace BMA.EHR.Recruit.Service.Services
|
||||||
return new { CitizenId = candidate.CitizenId ?? "", org = (dynamic?)null };
|
return new { CitizenId = candidate.CitizenId ?? "", org = (dynamic?)null };
|
||||||
}
|
}
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
Console.WriteLine("171");
|
||||||
|
|
||||||
var orgResults = await Task.WhenAll(orgTasks);
|
var orgResults = await Task.WhenAll(orgTasks);
|
||||||
var orgDict = orgResults.ToDictionary(x => x.CitizenId ?? "", x => x.org);
|
var orgDict = orgResults.ToDictionary(x => x.CitizenId ?? "", x => x.org);
|
||||||
|
|
@ -275,6 +286,7 @@ namespace BMA.EHR.Recruit.Service.Services
|
||||||
var placementProfiles = new List<PlacementProfile>();
|
var placementProfiles = new List<PlacementProfile>();
|
||||||
var placementEducations = new List<PlacementEducation>();
|
var placementEducations = new List<PlacementEducation>();
|
||||||
var placementCertificates = new List<PlacementCertificate>();
|
var placementCertificates = new List<PlacementCertificate>();
|
||||||
|
Console.WriteLine("161");
|
||||||
|
|
||||||
foreach (var candidate in candidates)
|
foreach (var candidate in candidates)
|
||||||
{
|
{
|
||||||
|
|
@ -433,12 +445,17 @@ namespace BMA.EHR.Recruit.Service.Services
|
||||||
LastUpdateFullName = FullName ?? "",
|
LastUpdateFullName = FullName ?? "",
|
||||||
};
|
};
|
||||||
placementCertificates.Add(placementCertificate);
|
placementCertificates.Add(placementCertificate);
|
||||||
|
Console.WriteLine("511");
|
||||||
}
|
}
|
||||||
|
Console.WriteLine("141");
|
||||||
|
|
||||||
// 🚀 Batch insert all records
|
// 🚀 Batch insert all records
|
||||||
await _contextMetadata.PlacementProfiles.AddRangeAsync(placementProfiles);
|
await _contextMetadata.PlacementProfiles.AddRangeAsync(placementProfiles);
|
||||||
|
Console.WriteLine("131");
|
||||||
await _contextMetadata.PlacementEducations.AddRangeAsync(placementEducations);
|
await _contextMetadata.PlacementEducations.AddRangeAsync(placementEducations);
|
||||||
|
Console.WriteLine("121");
|
||||||
await _contextMetadata.PlacementCertificates.AddRangeAsync(placementCertificates);
|
await _contextMetadata.PlacementCertificates.AddRangeAsync(placementCertificates);
|
||||||
|
Console.WriteLine("111");
|
||||||
|
|
||||||
// 🚀 Single SaveChanges at the end
|
// 🚀 Single SaveChanges at the end
|
||||||
await _contextMetadata.SaveChangesAsync();
|
await _contextMetadata.SaveChangesAsync();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue