Skip to content

Commit

Permalink
Merge branch 'dev' into feat/SRS-660
Browse files Browse the repository at this point in the history
  • Loading branch information
mishraomp authored Dec 31, 2024
2 parents b47c679 + e7972e7 commit a59fc78
Show file tree
Hide file tree
Showing 27 changed files with 556 additions and 358 deletions.
3 changes: 3 additions & 0 deletions backend/src/app/resolvers/site/sitePublic.resolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe('SiteResolver', () => {
undefined,
undefined,
undefined,
undefined,
);
});

Expand Down Expand Up @@ -161,6 +162,7 @@ describe('SiteResolver', () => {
undefined,
undefined,
undefined,
undefined,
);
expect(result).toEqual(expectedFilteredSites);
});
Expand Down Expand Up @@ -225,6 +227,7 @@ describe('SiteResolver', () => {
undefined,
undefined,
undefined,
undefined,
);
expect(result).toEqual(expectedFilteredSites);
});
Expand Down
14 changes: 11 additions & 3 deletions backend/src/app/resolvers/site/sitePublic.resolver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Args, Query, Resolver } from '@nestjs/graphql';
import { Args, Int, Query, Resolver } from '@nestjs/graphql';
import { Unprotected } from 'nest-keycloak-connect';
import {
FetchSiteDetail,
Expand Down Expand Up @@ -38,8 +38,8 @@ export class SitePublicResolver {
@Query(() => SearchSiteResponse, { name: 'searchSites' })
async searchSites(
@Args('searchParam', { type: () => String }) searchParam: string,
@Args('page', { type: () => String }) page: number,
@Args('pageSize', { type: () => String }) pageSize: number,
@Args('page', { type: () => Int }) page: number,
@Args('pageSize', { type: () => Int }) pageSize: number,
@Args('id', { type: () => String, nullable: true }) id?: string,
@Args('srStatus', { type: () => String, nullable: true }) srStatus?: string,
@Args('siteRiskCode', { type: () => String, nullable: true })
Expand Down Expand Up @@ -71,6 +71,13 @@ export class SitePublicResolver {
whenCreated?: Date,
@Args('whenUpdated', { type: () => String, nullable: true })
whenUpdated?: Date,
@Args('siteIds', {
type: () => [String],
nullable: true,
description:
'If provided, only applies the filters to the specified sites',
})
siteIds?: string[],
) {
this.sitesLogger.log('SiteResolver.searchSites() start ');
return await this.siteService.searchSites(
Expand All @@ -95,6 +102,7 @@ export class SitePublicResolver {
longSeconds,
whenCreated,
whenUpdated,
siteIds,
);
}

Expand Down
9 changes: 8 additions & 1 deletion backend/src/app/services/site/site.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,20 @@ export class SiteService {
longSeconds?: string,
whenCreated?: Date,
whenUpdated?: Date,
siteIds?: string[],
) {
this.sitesLogger.log('SiteService.searchSites() start');
this.sitesLogger.debug('SiteService.searchSites() start');
const siteUtil: SiteUtil = new SiteUtil();
const response = new SearchSiteResponse();

const query = this.siteRepository.createQueryBuilder('sites').where(
const query = this.siteRepository.createQueryBuilder('sites');

if (siteIds?.length) {
query.whereInIds(siteIds);
}

query.andWhere(
new Brackets((qb) => {
qb.where('CAST(sites.id AS TEXT) LIKE :searchParam', {
searchParam: `%${searchParam}%`,
Expand Down
9 changes: 0 additions & 9 deletions charts/app/templates/backend/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ spec:
key: user
name: postgres-crunchy-pguser-postgres
resources: # this is optional
limits:
cpu: {{ .Values.backend.resources.limits.cpu }}
memory: {{ .Values.backend.resources.limits.memory }}
requests:
cpu: {{ .Values.backend.resources.requests.cpu }}
memory: {{ .Values.backend.resources.requests.memory }}
Expand Down Expand Up @@ -128,9 +125,6 @@ spec:
- name: SEED_DATA_PATH
value: "/mnt/sql/data_migration.sql"
resources: # this is optional
limits:
cpu: {{ .Values.backend.resources.limits.cpu }}
memory: {{ .Values.backend.resources.limits.memory }}
requests:
cpu: {{ .Values.backend.resources.requests.cpu }}
memory: {{ .Values.backend.resources.requests.memory }}
Expand Down Expand Up @@ -217,9 +211,6 @@ spec:
periodSeconds: 30
timeoutSeconds: 5
resources: # this is optional
limits:
cpu: {{ .Values.backend.resources.limits.cpu }}
memory: {{ .Values.backend.resources.limits.memory }}
requests:
cpu: {{ .Values.backend.resources.requests.cpu }}
memory: {{ .Values.backend.resources.requests.memory }}
Expand Down
3 changes: 0 additions & 3 deletions charts/app/templates/frontend/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ spec:
periodSeconds: 30
timeoutSeconds: 5
resources:
limits:
cpu: 30m
memory: 75Mi
requests:
cpu: 15m
memory: 25Mi
Expand Down
3 changes: 0 additions & 3 deletions charts/app/values-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ backend:
pdb:
enabled: false
resources:
limits:
cpu: 100m
memory: 250Mi
requests:
cpu: 50m
memory: 150Mi
Expand Down
3 changes: 0 additions & 3 deletions charts/app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ backend:
#-- the target cpu utilization percentage, is from request cpu and NOT LIMIT CPU.
targetCPUUtilizationPercentage: 80
resources:
limits:
cpu: 150m
memory: 250Mi
requests:
cpu: 50m
memory: 150Mi
Expand Down
24 changes: 0 additions & 24 deletions charts/crunchy/templates/PostgresCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ spec:
requests:
cpu: {{ .Values.crunchy.pgmonitor.exporter.requests.cpu }}
memory: {{ .Values.crunchy.pgmonitor.exporter.requests.memory }}
limits:
cpu: {{ .Values.crunchy.pgmonitor.exporter.limits.cpu }}
memory: {{ .Values.crunchy.pgmonitor.exporter.limits.memory }}

{{ end }}

Expand All @@ -71,19 +68,13 @@ spec:
requests:
cpu: {{ .Values.crunchy.instances.requests.cpu }}
memory: {{ .Values.crunchy.instances.requests.memory }}
limits:
cpu: {{ .Values.crunchy.instances.limits.cpu }}
memory: {{ .Values.crunchy.instances.limits.memory }}

sidecars:
replicaCertCopy:
resources:
requests:
cpu: {{ .Values.crunchy.instances.replicaCertCopy.requests.cpu }}
memory: {{ .Values.crunchy.instances.replicaCertCopy.requests.memory }}
limits:
cpu: {{ .Values.crunchy.instances.replicaCertCopy.limits.cpu }}
memory: {{ .Values.crunchy.instances.replicaCertCopy.limits.memory }}
dataVolumeClaimSpec:
accessModes:
- "ReadWriteOnce"
Expand Down Expand Up @@ -177,35 +168,23 @@ spec:
requests:
cpu: {{ .Values.crunchy.pgBackRest.repoHost.requests.cpu }}
memory: {{ .Values.crunchy.pgBackRest.repoHost.requests.memory }}
limits:
cpu: {{ .Values.crunchy.pgBackRest.repoHost.limits.cpu }}
memory: {{ .Values.crunchy.pgBackRest.repoHost.limits.memory }}
sidecars:
# this stuff is for the "pgbackrest" container in the "postgres-crunchy-ha" set of pods
pgbackrest:
resources:
requests:
cpu: {{ .Values.crunchy.pgBackRest.sidecars.pgBackRest.requests.cpu }}
memory: {{ .Values.crunchy.pgBackRest.sidecars.pgBackRest.requests.memory }}
limits:
cpu: {{ .Values.crunchy.pgBackRest.sidecars.pgBackRest.limits.cpu }}
memory: {{ .Values.crunchy.pgBackRest.sidecars.pgBackRest.limits.memory }}
pgbackrestConfig:
resources:
requests:
cpu: {{ .Values.crunchy.pgBackRest.sidecars.requests.cpu }}
memory: {{ .Values.crunchy.pgBackRest.sidecars.requests.memory }}
limits:
cpu: {{ .Values.crunchy.pgBackRest.sidecars.limits.cpu }}
memory: {{ .Values.crunchy.pgBackRest.sidecars.limits.memory }}
jobs:
resources:
requests:
cpu: {{ .Values.crunchy.pgBackRest.jobs.requests.cpu }}
memory: {{ .Values.crunchy.pgBackRest.jobs.requests.memory }}
limits:
cpu: {{ .Values.crunchy.pgBackRest.jobs.limits.cpu }}
memory: {{ .Values.crunchy.pgBackRest.jobs.limits.memory }}
{{- end }}
patroni:
dynamicConfiguration:
Expand Down Expand Up @@ -238,9 +217,6 @@ spec:
requests:
cpu: {{ .Values.crunchy.proxy.pgBouncer.requests.cpu }}
memory: {{ .Values.crunchy.proxy.pgBouncer.requests.memory }}
limits:
cpu: {{ .Values.crunchy.proxy.pgBouncer.limits.cpu }}
memory: {{ .Values.crunchy.proxy.pgBouncer.limits.memory }}
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
Expand Down
27 changes: 0 additions & 27 deletions charts/crunchy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,10 @@ crunchy: # enable it for TEST and PROD, for PR based pipelines simply use single
requests:
cpu: 50m
memory: 128Mi
limits:
cpu: 150m
memory: 256Mi
replicaCertCopy:
requests:
cpu: 1m
memory: 32Mi
limits:
cpu: 50m
memory: 64Mi

pgBackRest:
enabled: true
Expand Down Expand Up @@ -80,37 +74,22 @@ crunchy: # enable it for TEST and PROD, for PR based pipelines simply use single
requests:
cpu: 5m
memory: 32Mi
limits:
cpu: 20m
memory: 64Mi
repoHost:
requests:
cpu: 20m
memory: 128Mi
limits:
cpu: 50m
memory: 256Mi
sidecars:
requests:
cpu: 5m
memory: 16Mi
limits:
cpu: 20m
memory: 64Mi
pgBackRest: # little more as these container in the statefulset pods do the pvc backups
requests:
cpu: 25m
memory: 128Mi
limits:
cpu: 50m
memory: 256Mi
jobs:
requests:
cpu: 20m
memory: 256Mi
limits:
cpu: 100m
memory: 512Mi

patroni:
postgresql:
Expand All @@ -135,9 +114,6 @@ crunchy: # enable it for TEST and PROD, for PR based pipelines simply use single
requests:
cpu: 5m
memory: 32Mi
limits:
cpu: 20m
memory: 64Mi
maxConnections: 10 # make sure less than postgres max connections

# Postgres Cluster resource values:
Expand All @@ -148,8 +124,5 @@ crunchy: # enable it for TEST and PROD, for PR based pipelines simply use single
requests:
cpu: 1m
memory: 16Mi
limits:
cpu: 35m
memory: 32Mi
databaseInitSQL:
enabled: true
20 changes: 20 additions & 0 deletions frontend/src/app/components/button/Button.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,23 @@
.SITE-Button.tertiary:hover:not(:disabled) {
background-color: var(--surface-tertiary-hover);
}

.SITE-Button.btn-icon {
background: transparent;
border: 1px solid transparent;
color: var(--surface-primary-default);
}
.SITE-Button.btn-icon:hover:not(:disabled) {
background-color: var(--surface-color-brand-blue-20);
}
.SITE-Button.btn-icon:focus {
background-color: var(--surface-color-brand-blue-20);
border: 1px solid var(--surface-color-primary-active-border);
}
.SITE-Button.btn-icon.btn-active {
background: var(--surface-color-primary-default);
color: var(--typography-color-primary-invert);
}
.SITE-Button.btn-icon.btn-active:hover {
background: var(--surface-color-primary-default);
}
23 changes: 20 additions & 3 deletions frontend/src/app/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,37 @@ import clsx from 'clsx';

import './Button.css';

export type ButtonVariant = 'primary' | 'secondary' | 'tertiary';
export type ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'icon';
export type ButtonSize = 'small' | 'medium';

type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
size?: ButtonSize;
variant?: ButtonVariant;
active?: boolean;
};

export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
({ variant = 'primary', size = 'medium', className, ...props }, ref) => {
(
{
variant = 'primary',
size = 'medium',
className,
active = false,
...props
},
ref,
) => {
const variantCssClass = variant === 'icon' ? 'btn-icon' : variant;
return (
<button
ref={ref}
className={clsx(['SITE-Button', variant, size, className])}
className={clsx([
'SITE-Button',
variantCssClass,
size,
active && 'btn-active',
className,
])}
{...props}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { render, fireEvent, screen } from '@testing-library/react';
import Pagination from './Pagination';
import { text } from 'stream/consumers';

describe('Pagination Component', () => {
const selectPageMock = jest.fn(() => {});
Expand All @@ -22,12 +21,8 @@ describe('Pagination Component', () => {
/>,
);

expect(
screen.getByText('1', { selector: '.pagination-page-active' }),
).toBeInTheDocument();
expect(
screen.getByText('100', { selector: '.pagination-page' }),
).toBeInTheDocument();
expect(screen.getByRole('button', { name: '1' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '100' })).toBeInTheDocument();
// Add more assertions based on your component's logic
});

Expand All @@ -42,10 +37,8 @@ describe('Pagination Component', () => {
/>,
);

expect(
screen.getByText('1', { selector: '.pagination-page-active' }),
).toBeInTheDocument();
fireEvent.click(screen.getByText('2', { selector: '.pagination-page' }));
expect(screen.getByRole('button', { name: '1' })).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '2' }));
expect(selectPageMock).toHaveBeenCalledWith(2);
});

Expand Down
Loading

0 comments on commit a59fc78

Please sign in to comment.