Skip to content

Commit

Permalink
Merge pull request #803 from bcgov/yj
Browse files Browse the repository at this point in the history
Yj
  • Loading branch information
ychung-mot authored Nov 21, 2024
2 parents b0a06e4 + 3d0aa93 commit bb1d4ba
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 20 deletions.
48 changes: 29 additions & 19 deletions backup-container/src/scripts/ocp4/rocket.chat.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,56 @@ class Script {
process_incoming_request({ request }) {
let data = request.content;
let attachmentColor = `#36A64F`;
let statusMsg = `Status`;
let isError = data.statusCode === `ERROR`;
let statusMsg = `Successful backup`; // Default message

// Check for "Backup Size: 0" in the message
const backupSizeZero = /Backup Size: 0/.test(data.message);

// Determine if there's an error
let isError = data.statusCode === `ERROR` || backupSizeZero;

if (isError) {
statusMsg = `Error`;
attachmentColor = `#A63636`;
statusMsg = `Failed backup`; // Change message for errors
attachmentColor = `#A63636`; // Change color to red

// Replace "Successfully backed up" in data.message with "Backup failed"
data.message = data.message.replace('Successfully backed up', 'Backup failed');
}

let friendlyProjectName=``;
if(data.projectFriendlyName) {
friendlyProjectName = data.projectFriendlyName
let friendlyProjectName = ``;
if (data.projectFriendlyName) {
friendlyProjectName = data.projectFriendlyName;
}

let projectName=``;
let projectName = ``;
if (data.projectName) {
projectName = data.projectName
if(!friendlyProjectName) {
friendlyProjectName = projectName
projectName = data.projectName;
if (!friendlyProjectName) {
friendlyProjectName = projectName;
}
}

if(projectName) {
statusMsg += ` message received from [${friendlyProjectName}](https://console.apps.silver.devops.gov.bc.ca/k8s/cluster/projects/${projectName}/workloads):`;
if (projectName) {
statusMsg += ` message received from [${friendlyProjectName}](https://console.apps.emerald.devops.gov.bc.ca/k8s/cluster/projects/b0471a-prod/workloads):`;
} else {
statusMsg += ` message received:`;
}

// Add bold formatting for error messages
if (isError) {
statusMsg = `**${statusMsg}**`;
}

return {
content:{
content: {
text: statusMsg,
attachments: [
{
text: `${data.message}`,
color: attachmentColor
}
]
}
color: attachmentColor,
},
],
},
};
}
}
}
26 changes: 25 additions & 1 deletion server/StrDss.Data/Repositories/RentalListingRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,26 @@ public async Task<int> GetGroupedRentalListingsCount(string? all, string? addres

return count;
}
//public async Task<int> CountHostListingsAsync(string hostName)
//{
// var query = _dbSet.AsNoTracking();

// if (_currentUser.OrganizationType == OrganizationTypes.LG)
// {
// query = query.Where(x => x.ManagingOrganizationId == _currentUser.OrganizationId);
// }

// return await query
// .Where(x => x.EffectiveHostNm == hostName)
// .GroupBy(x => new { x.EffectiveBusinessLicenceNo, x.EffectiveHostNm, x.MatchAddressTxt })
// .Select(g => new RentalListingGroupDto
// {
// EffectiveBusinessLicenceNo = g.Key.EffectiveBusinessLicenceNo,
// EffectiveHostNm = g.Key.EffectiveHostNm,
// MatchAddressTxt = g.Key.MatchAddressTxt
// })
// .CountAsync();
//}
public async Task<int> CountHostListingsAsync(string hostName)
{
var query = _dbSet.AsNoTracking();
Expand All @@ -170,7 +190,11 @@ public async Task<int> CountHostListingsAsync(string hostName)
query = query.Where(x => x.ManagingOrganizationId == _currentUser.OrganizationId);
}

return await query.CountAsync(x => x.EffectiveHostNm == hostName);
return await query
.Where(x => x.EffectiveHostNm == hostName)
.Select(x => new { x.EffectiveBusinessLicenceNo, x.EffectiveHostNm, x.MatchAddressTxt })
.Distinct()
.CountAsync();
}

private static void ApplyFilters(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
Expand Down

0 comments on commit bb1d4ba

Please sign in to comment.