-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add export service hours feature and migrate email, http -> https #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
66aa780
70a9c5e
bc78f03
8d6a7e3
6cd3773
c225852
7b0fe6d
82d1437
f741681
e6cebc7
b9f3e68
05eebfa
820c736
f7372a9
436975c
0b8982e
a1fb01e
b821a4a
e560d03
24e0dec
adfeff5
4785887
8b48610
24bd3de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,48 @@ | ||
| import { | ||
| AttendanceExportsResult, | ||
| AttendanceExportsXLSX, | ||
| AttendanceQueryExportsConditions, | ||
| type ServiceHoursExportResult, | ||
| type ServiceHoursExportsXLSX, | ||
| type ServiceHoursQueryExportsConditions, | ||
| ExportsModelImpl, | ||
| staticImplements, | ||
| } from './types'; | ||
| import { BaseExportsModel } from './exports_base'; | ||
| import { ServiceSession, type AttendanceStatus } from '@db/entities'; | ||
| import { User } from '@db/entities'; | ||
| import { HTTPErrors } from '@utils/errors'; | ||
| import { WorkSheet } from 'node-xlsx'; | ||
| import appDataSource from '@utils/init_datasource'; | ||
|
|
||
| // @staticImplements<ExportsModelImpl>() | ||
| export class ServiceHoursExportsModel extends BaseExportsModel {} | ||
| @staticImplements<ExportsModelImpl>() | ||
| export class ServiceHoursExportsModel extends BaseExportsModel { | ||
| public static async queryExports({ type, order }: ServiceHoursQueryExportsConditions) { | ||
| const result: ServiceHoursExportResult[] = await appDataSource.manager | ||
| .createQueryBuilder() | ||
| .select(['user.user_id', 'user.username', 'user.service_hours']) | ||
| .from(User, 'user') | ||
| .orderBy(`user.${type}`, order) | ||
| .getMany(); | ||
| return result; | ||
| } | ||
| public static async formatXLSX(conds: ServiceHoursQueryExportsConditions) { | ||
| const ret = await this.queryExports(conds); | ||
|
|
||
| if (ret.length === 0) throw HTTPErrors.RESOURCE_NOT_FOUND; | ||
|
|
||
| const data: ServiceHoursExportsXLSX = [ | ||
| ['user_id', 'username', 'service_hours'], | ||
| ...ret.map( | ||
| (r) => [r.user_id, r.username, r.service_hours] satisfies ServiceHoursExportsXLSX[1], | ||
| ), | ||
| ]; | ||
|
|
||
| const sheetOptions = this.getSheetOptions(data); | ||
|
|
||
| return { name: 'service hours', data, options: sheetOptions }; | ||
| } | ||
| public static async packXLSX( | ||
| type: ServiceHoursQueryExportsConditions['type'], | ||
| order: ServiceHoursQueryExportsConditions['order'], | ||
| ) { | ||
| const worksheet = await this.formatXLSX({ type, order }); | ||
|
|
||
| return this.constructXLSX(worksheet); | ||
| } | ||
| } | ||
SebassNoob marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FROM oven/bun:1.1.3 | ||
| FROM oven/bun:1.1.7 | ||
| WORKDIR /app | ||
|
|
||
| COPY . . | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FROM oven/bun:1.1.3 | ||
| FROM oven/bun:1.1.7 | ||
| WORKDIR /app | ||
|
|
||
| COPY . . | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,21 +1,20 @@ | ||||||||||||||
| FROM oven/bun:1.1.3 | ||||||||||||||
| FROM oven/bun:1.1.7 | ||||||||||||||
| WORKDIR /app | ||||||||||||||
|
|
||||||||||||||
| COPY . . | ||||||||||||||
|
|
||||||||||||||
| RUN bun install --frozen-lockfile | ||||||||||||||
| RUN bun install --frozen-lockfile && \ | ||||||||||||||
| # install curl, lsb-release and gnupg | ||||||||||||||
| apt-get update && apt-get install -y curl gnupg lsb-release && apt-get clean && \ | ||||||||||||||
|
Comment on lines
+6
to
+8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consolidate installation steps. The installation of apt-get update && apt-get install -y --no-install-recommends curl gnupg lsb-release && apt-get clean && \Committable suggestion
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| # install curl, lsb-release and gnupg | ||||||||||||||
| RUN apt-get update && apt-get install -y curl lsb-release gnupg && apt-get clean | ||||||||||||||
| # add postgresql repository | ||||||||||||||
| curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \ | ||||||||||||||
| echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list && \ | ||||||||||||||
|
|
||||||||||||||
| # add postgresql repository | ||||||||||||||
| RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - | ||||||||||||||
| RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list | ||||||||||||||
| # update and install postgresql-client-16, tzdata | ||||||||||||||
| apt-get update && apt-get install -y --fix-missing postgresql-client-16 tzdata && apt-get clean && \ | ||||||||||||||
|
|
||||||||||||||
| # update and install postgresql-client-16, tzdata | ||||||||||||||
| RUN apt-get update && apt-get install -y --fix-missing postgresql-client-16 tzdata && apt-get clean | ||||||||||||||
|
|
||||||||||||||
| RUN ARCH=$(case "$(uname -m)" in "x86_64") echo "amd64";; "ppc64le") echo "ppc64le";; *) echo "Unsupported architecture"; exit 1;; esac) && \ | ||||||||||||||
| ARCH=$(case "$(uname -m)" in "x86_64") echo "amd64";; "ppc64le") echo "ppc64le";; *) echo "Unsupported architecture"; exit 1;; esac) && \ | ||||||||||||||
| DOWNLOAD_URL=$(case "$ARCH" in "amd64") echo "https://dl.min.io/client/mc/release/linux-amd64/mc";; "ppc64le") echo "https://dl.min.io/client/mc/release/linux-ppc64le/mc";; *) echo "Unsupported architecture"; exit 1;; esac) && \ | ||||||||||||||
| # Install wget to download MinIO client | ||||||||||||||
| apt-get update && apt-get install -y wget && \ | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,21 +1,24 @@ | ||||||
| FROM oven/bun:1.1.3 | ||||||
| FROM oven/bun:1.1.7 | ||||||
| WORKDIR /app | ||||||
|
|
||||||
| COPY . . | ||||||
|
|
||||||
| RUN bun install --production --frozen-lockfile | ||||||
| RUN bun install --production --frozen-lockfile && \ | ||||||
|
|
||||||
| # install curl, lsb-release and gnupg | ||||||
| RUN apt-get update && apt-get install -y curl lsb-release gnupg && apt-get clean | ||||||
| # install curl, lsb-release and gnupg | ||||||
| apt-get update && apt-get install -y curl gnupg lsb-release && apt-get clean && \ | ||||||
|
|
||||||
| # add postgresql repository | ||||||
| RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - | ||||||
| RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list | ||||||
| # add postgresql repository | ||||||
| curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \ | ||||||
| echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list && \ | ||||||
|
|
||||||
| # update and install postgresql-client-16, tzdata | ||||||
| RUN apt-get update && apt-get install -y --fix-missing postgresql-client-16 tzdata && apt-get clean | ||||||
| # update and install postgresql-client-16, tzdata | ||||||
| # set timeout to 8 minutes | ||||||
| echo 'Acquire::http::Timeout "480";' > /etc/apt/apt.conf.d/99timeout && \ | ||||||
| echo 'Acquire::ftp::Timeout "480";' >> /etc/apt/apt.conf.d/99timeout && \ | ||||||
| apt-get update && apt-get install -y --fix-missing postgresql-client-16 tzdata && apt-get clean && \ | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pin package versions and use Consider pinning package versions and using apt-get install -y --no-install-recommends --fix-missing postgresql-client-16=16.0 tzdata=2023a && apt-get clean && \Committable suggestion
Suggested change
|
||||||
|
|
||||||
| RUN ARCH=$(case "$(uname -m)" in "x86_64") echo "amd64";; "ppc64le") echo "ppc64le";; *) echo "Unsupported architecture"; exit 1;; esac) && \ | ||||||
| ARCH=$(case "$(uname -m)" in "x86_64") echo "amd64";; "ppc64le") echo "ppc64le";; *) echo "Unsupported architecture"; exit 1;; esac) && \ | ||||||
| DOWNLOAD_URL=$(case "$ARCH" in "amd64") echo "https://dl.min.io/client/mc/release/linux-amd64/mc";; "ppc64le") echo "https://dl.min.io/client/mc/release/linux-ppc64le/mc";; *) echo "Unsupported architecture"; exit 1;; esac) && \ | ||||||
| # Install wget to download MinIO client | ||||||
| apt-get update && apt-get install -y wget && \ | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FROM oven/bun:1.1.3 | ||
| FROM oven/bun:1.1.7 | ||
| WORKDIR /app | ||
|
|
||
| COPY . . | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove trailing spaces to maintain clean and consistent formatting.
Tools
yamllint