From 1f94475753027432293a9095e333bee3545ed545 Mon Sep 17 00:00:00 2001 From: ychung-mot Date: Thu, 21 Nov 2024 10:38:25 -0800 Subject: [PATCH 1/2] chore: backup container script update --- .../scripts/ocp4/rocket.chat.integration.js | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/backup-container/src/scripts/ocp4/rocket.chat.integration.js b/backup-container/src/scripts/ocp4/rocket.chat.integration.js index 04d489a2..23b49729 100644 --- a/backup-container/src/scripts/ocp4/rocket.chat.integration.js +++ b/backup-container/src/scripts/ocp4/rocket.chat.integration.js @@ -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, + }, + ], + }, }; } -} \ No newline at end of file +} From 3d0aa93d19a6fb22506ad7ebfd47c3b87e098b5e Mon Sep 17 00:00:00 2001 From: ychung-mot Date: Thu, 21 Nov 2024 14:07:02 -0800 Subject: [PATCH 2/2] chore: multiple hosting count --- .../Repositories/RentalListingRepository.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/server/StrDss.Data/Repositories/RentalListingRepository.cs b/server/StrDss.Data/Repositories/RentalListingRepository.cs index 68ae8612..b13a367e 100644 --- a/server/StrDss.Data/Repositories/RentalListingRepository.cs +++ b/server/StrDss.Data/Repositories/RentalListingRepository.cs @@ -161,6 +161,26 @@ public async Task GetGroupedRentalListingsCount(string? all, string? addres return count; } + //public async Task 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 CountHostListingsAsync(string hostName) { var query = _dbSet.AsNoTracking(); @@ -170,7 +190,11 @@ public async Task 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,