Skip to content

Commit

Permalink
Merge branch 'master' into refund-donation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nnachevvv authored Oct 28, 2023
2 parents 398c341 + 6d1bd9f commit 9a7cbe8
Show file tree
Hide file tree
Showing 22 changed files with 241 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-pr-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check whether tests are enabled for this PR
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
name: Build API docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Login to GitHub Packages Docker Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -32,7 +32,7 @@ jobs:
run: echo "VERSION=master-$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV

- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
env:
NODE_ENV: production
with:
Expand All @@ -55,10 +55,10 @@ jobs:
name: Build migrations docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Login to GitHub Packages Docker Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -73,7 +73,7 @@ jobs:
run: echo "VERSION=master-$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV

- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
env:
NODE_ENV: production
with:
Expand All @@ -97,10 +97,10 @@ jobs:
name: Build seed docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Login to GitHub Packages Docker Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -115,7 +115,7 @@ jobs:
run: echo "VERSION=master-$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV

- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
env:
NODE_ENV: production
with:
Expand All @@ -130,7 +130,7 @@ jobs:
name: Scan k8s manifests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install kustomize
uses: imranismail/setup-kustomize@v2
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
name: dev
url: https://dev.podkrepi.bg/swagger
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install kubectl
uses: azure/setup-kubectl@v3
Expand Down Expand Up @@ -221,7 +221,7 @@ jobs:
name: prod
url: https://podkrepi.bg/swagger
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install kubectl
uses: azure/setup-kubectl@v3
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/security-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
env:
NODE_ENV: production
with:
Expand All @@ -35,10 +35,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
push: false
file: Dockerfile.migrations
Expand All @@ -56,7 +56,7 @@ jobs:
name: Scan k8s manifests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install kustomize
uses: imranismail/setup-kustomize@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@v3
Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,7 @@ yarn

## Create Docker containers for the Dev Database(postgres) and the Identity Server(Keycloak)

Use below command for `docker-compose` version `>=2.5`

```shell
docker-compose --profile local-keycloak up -d
```

or with earlier versions of docker-compose:
Run the below command in your terminal:

```shell
docker compose up -d pg-db keycloak
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/assets/templates/welcome.mjml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<mj-text
align="left"
color="#ffffff"
font-size="45px"
font-size="35px"
font-weight="bold"
font-family="open Sans Helvetica, Arial, sans-serif"
padding-left="25px"
Expand Down Expand Up @@ -45,8 +45,8 @@
>Discord сървъра</a
>, където се помещава нашият виртуален офис. Съветът ни е да прочетете внимателно какво
пише на началната страница в канал #започни-от-тук. <br /><br />
След това може да се включите в дискусиите и Ви чакаме на обща среща в понеделник от 18:30
ч. в гласовия канал #обща-среща-пон-18:30 на сървъра. <br /><br />
След това може да се включите в дискусиите и Ви чакаме на обща среща всяка сряда от 19:00
ч. в гласовия канал #обща-среща-сряда-19ч на сървъра. <br /><br />
Още веднъж благодарим за готовността да помогнете за нашата кауза!
</mj-text>
<mj-text
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/auth/auth.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('AuthService', () => {
let config: ConfigService
let admin: KeycloakAdminClient
let keycloak: KeycloakConnect.Keycloak
let marketing: NotificationsProviderInterface<any>
let marketing: NotificationsProviderInterface<unknown>

const person: Person = {
id: 'e43348aa-be33-4c12-80bf-2adfbf8736cd',
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('AuthService', () => {
service = module.get<AuthService>(AuthService)
config = module.get<ConfigService>(ConfigService)
admin = module.get<KeycloakAdminClient>(KeycloakAdminClient)
marketing = module.get<NotificationsProviderInterface<any>>(NotificationsProviderInterface)
marketing = module.get<NotificationsProviderInterface<never>>(NotificationsProviderInterface)
keycloak = module.get<KeycloakConnect.Keycloak>(KEYCLOAK_INSTANCE)
})

Expand Down
31 changes: 19 additions & 12 deletions apps/api/src/bank-transactions/bank-transactions.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from './dto/bank-transactions-query-dto'
import { CampaignService } from '../campaign/campaign.service'
import { BankDonationStatus } from '@prisma/client'
import { DateTime, Interval } from 'luxon'

@ApiTags('bank-transaction')
@Controller('bank-transaction')
Expand Down Expand Up @@ -121,21 +122,27 @@ export class BankTransactionsController {
mode: RoleMatchingMode.ANY,
})
async rerunBankTransactionsForDate(@Body() body: { startDate: string; endDate: string }) {
Logger.debug('rerunBankTransactionsForDate startDate: ', body.startDate)
Logger.debug(
'rerunBankTransactionsForDate startDate: ' + body.startDate + ' endDate: ' + body.endDate,
)
if (!body.startDate) throw new BadRequestException('Missing startDate in Request')
if (!body.endDate) throw new BadRequestException('Missing endDate in Request')

const startDate = new Date(body.startDate.split('T')[0])
const endDate = new Date(body.endDate.split('T')[0])
const startDate = DateTime.fromISO(body.startDate)
const endDate = DateTime.fromISO(body.endDate).plus({ days: 1 }) //include endDate in the interval
const interval = Interval.fromDateTimes(startDate, endDate)
const dayCount = interval.length('days')

//rerun transactions iterating from startDate to endDate
for (
const dateToCheck = startDate;
dateToCheck <= endDate;
dateToCheck.setDate(dateToCheck.getDate() + 1)
) {
Logger.debug('Getting transactions for date: ' + dateToCheck.toISOString().split('T')[0])
await this.bankTransactionsService.rerunBankTransactionsForDate(dateToCheck)
}
Logger.debug('rerunBankTransactionsForDate days: ' + dayCount)
if (dayCount > 31)
throw new BadRequestException(
'Date range is more than 31 days. Please select a smaller date range',
)

//iterate over all dates in the interval
interval.splitBy({ days: 1 }).map(async (d) => {
Logger.debug('rerunBankTransactionsForDate date: ', d.start.toISODate())
await this.bankTransactionsService.rerunBankTransactionsForDate(new Date(d.start.toISODate()))
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ export class BankTransactionsService {
}

async rerunBankTransactionsForDate(transactionsDate: Date) {
this.irisBankImport.importBankTransactionsTASK(transactionsDate)
await this.irisBankImport.importBankTransactionsTASK(transactionsDate)
}
}
1 change: 0 additions & 1 deletion apps/api/src/campaign-file/campaign-file.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { CampaignFileService } from './campaign-file.service'
import { CampaignService } from '../campaign/campaign.service'
import { KeycloakTokenParsed, isAdmin } from '../auth/keycloak'
import { ApiTags } from '@nestjs/swagger'
import { CampaignFileRole } from '@prisma/client'

@ApiTags('campaign-file')
@Controller('campaign-file')
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/campaign/campaign.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('CampaignController', () => {
let controller: CampaignController
let prismaService: PrismaService
let campaignService: CampaignService
let marketingProvider: NotificationsProviderInterface<any>
let marketingProvider: NotificationsProviderInterface<unknown>
let marketingService: MarketingNotificationsService
const personServiceMock = {
findOneByKeycloakId: jest.fn(() => {
Expand Down Expand Up @@ -196,7 +196,7 @@ describe('CampaignController', () => {
prismaService = prismaMock
campaignService = module.get<CampaignService>(CampaignService)
marketingService = module.get<MarketingNotificationsService>(MarketingNotificationsService)
marketingProvider = module.get<NotificationsProviderInterface<any>>(
marketingProvider = module.get<NotificationsProviderInterface<never>>(
NotificationsProviderInterface,
)

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/campaign/campaign.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { MarketingNotificationsService } from '../notifications/notifications.se

describe('CampaignService', () => {
let service: CampaignService
let marketing: NotificationsProviderInterface<any>
let marketing: NotificationsProviderInterface<unknown>

const mockCreateCampaign = {
slug: 'test-slug',
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('CampaignService', () => {
.compile()

service = module.get<CampaignService>(CampaignService)
marketing = module.get<NotificationsProviderInterface<any>>(NotificationsProviderInterface)
marketing = module.get<NotificationsProviderInterface<never>>(NotificationsProviderInterface)
})

describe('update', () => {
Expand Down
1 change: 0 additions & 1 deletion apps/api/src/config/shutdown.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { INestApplication, ShutdownSignal } from '@nestjs/common'
import { PrismaService } from '../prisma/prisma.service'

export function setupShutdownHooks(app: INestApplication) {
// https://www.prisma.io/docs/guides/upgrade-guides/upgrading-versions/upgrading-to-prisma-5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fs from 'fs'
import { PrismaClient } from '@prisma/client'
import * as sgClient from '@sendgrid/client'
import { Logger } from '@nestjs/common'
import { ClientRequest } from '@sendgrid/client/src/request'

sgClient.setApiKey(process.env['SENDGRID_API_KEY'] || '')

Expand All @@ -28,7 +29,7 @@ async function createMarketingTemplatesIfNotExisting() {
url: `/v3/designs`,
method: 'POST',
body: data,
} as any
} as ClientRequest

const [response] = await sgClient.request(request)

Expand Down
6 changes: 4 additions & 2 deletions apps/api/src/notifications/notifications.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('MarketingNotificationsController', () => {
jest.spyOn(marketingProvider, 'getContactsInfo').mockImplementation(async () => ({}))
// Mock hash
jest
.spyOn(MarketingNotificationsService.prototype as any, 'generateHash')
.spyOn(MarketingNotificationsService.prototype, 'generateHash')
.mockReturnValue('hash-value')
})

Expand All @@ -128,7 +128,9 @@ describe('MarketingNotificationsController', () => {
it('should skip sending if user is registered + subscribed', async () => {
prismaMock.person.findFirst.mockResolvedValue(RegisteredMock)

await expect(controller.sendConfirmation({ email: RegisteredMock.email })).resolves.toEqual({
await expect(
controller.sendConfirmation({ email: RegisteredMock.email as string }),
).resolves.toEqual({
message: 'Subscribed',
})

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/prisma/prisma.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PrismaClient } from '@prisma/client'
import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common'
import { Injectable, OnModuleInit } from '@nestjs/common'

@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
Expand Down
Loading

0 comments on commit 9a7cbe8

Please sign in to comment.