Fix: Rebase

Chore: Updated dependencies
Chore: Python 3.10
Chore: Node 18
Chore: Ansible to support new layouts
This commit is contained in:
Amritanshu Agrawal 2022-05-09 23:56:51 +05:30
parent 13df9614bb
commit 763af272d1
18 changed files with 116 additions and 90 deletions

View File

@ -209,29 +209,52 @@ def delete_data(date_: date, vouchers: List[Voucher], db: Session) -> None:
sub_voucher = aliased(Voucher) sub_voucher = aliased(Voucher)
sub_query = select(sub_voucher.id).where(sub_voucher.date < date_).subquery() sub_query = select(sub_voucher.id).where(sub_voucher.date < date_).subquery()
db.execute(delete(Inventory).where(Inventory.voucher_id.in_(sub_query)))
db.execute(delete(EmployeeBenefit).where(EmployeeBenefit.voucher_id.in_(sub_query)))
db.execute(delete(Incentive).where(Incentive.voucher_id.in_(sub_query)))
db.execute(delete(Journal).where(and_(Journal.voucher_id.in_(sub_query), ~Journal.voucher_id.in_(vouchers))))
db.execute( db.execute(
delete(DbImage).where( delete(Inventory).where(Inventory.voucher_id.in_(sub_query)).execution_options(synchronize_session=False)
)
db.execute(
delete(EmployeeBenefit)
.where(EmployeeBenefit.voucher_id.in_(sub_query))
.execution_options(synchronize_session=False)
)
db.execute(
delete(Incentive).where(Incentive.voucher_id.in_(sub_query)).execution_options(synchronize_session=False)
)
db.execute(
delete(Journal)
.where(and_(Journal.voucher_id.in_(sub_query), ~Journal.voucher_id.in_(vouchers)))
.execution_options(synchronize_session=False)
)
db.execute(
delete(DbImage)
.where(
and_( and_(
DbImage.resource_type == "voucher", DbImage.resource_type == "voucher",
DbImage.resource_id.in_(sub_query), DbImage.resource_id.in_(sub_query),
~DbImage.resource_id.in_(vouchers), ~DbImage.resource_id.in_(vouchers),
) )
) )
.execution_options(synchronize_session=False)
)
db.execute(
delete(Voucher)
.where(Voucher.date < date_, ~Voucher.id.in_(vouchers))
.execution_options(synchronize_session=False)
) )
db.execute(delete(Voucher).where(Voucher.date < date_, ~Voucher.id.in_(vouchers)))
def cleanup_lint(date_: date, db: Session) -> None: def cleanup_lint(date_: date, db: Session) -> None:
# Insert executes on the end so keep list of batches and journals # Insert executes on the end so keep list of batches and journals
db.execute(delete(Batch).where(~Batch.id.in_(select(distinct(Inventory.batch_id)).subquery())))
db.execute(delete(Fingerprint).where(Fingerprint.date < date_))
db.execute(delete(Attendance).where(Attendance.date < date_))
db.execute( db.execute(
delete(Employee).where( delete(Batch)
.where(~Batch.id.in_(select(distinct(Inventory.batch_id)).subquery()))
.execution_options(synchronize_session=False)
)
db.execute(delete(Fingerprint).where(Fingerprint.date < date_).execution_options(synchronize_session=False))
db.execute(delete(Attendance).where(Attendance.date < date_).execution_options(synchronize_session=False))
db.execute(
delete(Employee)
.where(
and_( and_(
~Employee.id.in_(select(distinct(Journal.account_id)).subquery()), ~Employee.id.in_(select(distinct(Journal.account_id)).subquery()),
~Employee.id.in_(select(distinct(Fingerprint.employee_id)).subquery()), ~Employee.id.in_(select(distinct(Fingerprint.employee_id)).subquery()),
@ -248,22 +271,27 @@ def cleanup_lint(date_: date, db: Session) -> None:
Employee.leaving_date < date_, Employee.leaving_date < date_,
) )
) )
.execution_options(synchronize_session=False)
) )
db.execute( db.execute(
delete(AccountBase).where( delete(AccountBase)
.where(
and_( and_(
~AccountBase.id.in_(select(Employee.id).subquery()), ~AccountBase.id.in_(select(Employee.id).subquery()),
AccountBase.account_type == Employee.__mapper_args__["polymorphic_identity"], AccountBase.account_type == Employee.__mapper_args__["polymorphic_identity"],
) )
) )
.execution_options(synchronize_session=False)
) )
db.execute( db.execute(
delete(Account).where( delete(Account)
.where(
and_( and_(
~Account.id.in_(select(distinct(Journal.account_id)).subquery()), ~Account.id.in_(select(distinct(Journal.account_id)).subquery()),
Account.is_fixture == False, # noqa: E712 Account.is_fixture == False, # noqa: E712
Account.is_starred == False, Account.is_starred == False, # noqa: E712
Account.account_type == Account.__mapper_args__["polymorphic_identity"], Account.account_type == Account.__mapper_args__["polymorphic_identity"],
) )
) )
.execution_options(synchronize_session=False)
) )

View File

@ -5,9 +5,9 @@ description = "Accounting plus inventory management for a restaurant."
authors = ["tanshu <git@tanshu.com>"] authors = ["tanshu <git@tanshu.com>"]
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.8" python = "^3.10"
uvicorn = {extras = ["standard"], version = "^0.15.0"} uvicorn = {extras = ["standard"], version = "^0.17.6"}
fastapi = "^0.70.1" fastapi = "^0.76.0"
python-jose = {extras = ["cryptography"], version = "^3.3.0"} python-jose = {extras = ["cryptography"], version = "^3.3.0"}
passlib = {extras = ["bcrypt"], version = "^1.7.4"} passlib = {extras = ["bcrypt"], version = "^1.7.4"}
psycopg2-binary = "^2.9.2" psycopg2-binary = "^2.9.2"
@ -16,16 +16,16 @@ python-multipart = "^0.0.5"
PyJWT = "^2.3.0" PyJWT = "^2.3.0"
alembic = "^1.7.5" alembic = "^1.7.5"
itsdangerous = "^2.0.1" itsdangerous = "^2.0.1"
python-dotenv = "^0.19.2" python-dotenv = "^0.20.0"
pydantic = {extras = ["dotenv"], version = "^1.8.2"} pydantic = {extras = ["dotenv"], version = "^1.8.2"}
starlette = "^0.16.0" starlette = "^0.18.0"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
flake8 = "^4.0.1" flake8 = "^4.0.1"
black = "^21.10b0" black = "^22.3.0"
isort = {extras = ["toml"], version = "^5.10.0"} isort = {extras = ["toml"], version = "^5.10.0"}
pre-commit = "^2.15.0" pre-commit = "^2.15.0"
mypy = "^0.910" mypy = "^0.950"
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -euo pipefail
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P ) parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P )
cd "$parent_path" || exit cd "$parent_path" || exit
#./lint.sh
./lint.sh
if [ 1 -eq "$#" ] if [ 1 -eq "$#" ]
then then
@ -25,6 +25,12 @@ curl --silent 'https://git.tanshu.com/tanshu/brewman/raw/tag/latest/brewman/pypr
cd "$parent_path/docker/app" || exit cd "$parent_path/docker/app" || exit
docker build --tag brewman:latest . docker build --tag brewman:latest .
if [ 1 -eq "$#" ]
then
docker tag brewman:latest "$1"
else
echo "No version bump"
fi
cd "$parent_path/docker" || exit cd "$parent_path/docker" || exit
docker save brewman:latest | bzip2 | pv | ssh vancity 'bunzip2 | sudo docker load' docker save brewman:latest | bzip2 | pv | ssh vancity 'bunzip2 | sudo docker load'
ansible-playbook --limit vancity playbook-exp.yml ansible-playbook --limit vancity playbook-exp.yml

View File

@ -13,7 +13,7 @@ RUN mv /node_modules /app/overlord/ \
&& /app/overlord/node_modules/.bin/ng build && /app/overlord/node_modules/.bin/ng build
FROM python:3.9 FROM python:3.10
LABEL maintainer="Amritanshu <docker@tanshu.com>" LABEL maintainer="Amritanshu <docker@tanshu.com>"
COPY pyproject.toml /app/pyproject.toml COPY pyproject.toml /app/pyproject.toml

View File

@ -2,7 +2,7 @@ HOST=0.0.0.0
PORT=80 PORT=80
LOG_LEVEL=WARN LOG_LEVEL=WARN
DEBUG=false DEBUG=false
SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@db:5432/acc SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@172.26.5.85:5432/acc
MODULE_NAME=brewman.main MODULE_NAME=brewman.main
PROJECT_NAME=brewman PROJECT_NAME=brewman
POSTGRES_SERVER=db POSTGRES_SERVER=db

View File

@ -2,7 +2,7 @@ HOST=0.0.0.0
PORT=80 PORT=80
LOG_LEVEL=WARN LOG_LEVEL=WARN
DEBUG=false DEBUG=false
SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@db:5432/exp SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@172.26.5.85:5432/exp
MODULE_NAME=brewman.main MODULE_NAME=brewman.main
PROJECT_NAME=brewman PROJECT_NAME=brewman
POSTGRES_SERVER=db POSTGRES_SERVER=db

View File

@ -2,7 +2,7 @@ HOST=0.0.0.0
PORT=80 PORT=80
LOG_LEVEL=WARN LOG_LEVEL=WARN
DEBUG=false DEBUG=false
SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@db:5432/hops SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@172.26.5.85:5432/hops
MODULE_NAME=brewman.main MODULE_NAME=brewman.main
PROJECT_NAME=brewman PROJECT_NAME=brewman
POSTGRES_SERVER=db POSTGRES_SERVER=db

View File

@ -2,7 +2,7 @@ HOST=0.0.0.0
PORT=80 PORT=80
LOG_LEVEL=WARN LOG_LEVEL=WARN
DEBUG=false DEBUG=false
SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@db:5432/mhl SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@172.26.5.85:5432/mhl
MODULE_NAME=brewman.main MODULE_NAME=brewman.main
PROJECT_NAME=brewman PROJECT_NAME=brewman
POSTGRES_SERVER=db POSTGRES_SERVER=db

View File

@ -31,7 +31,12 @@ server {
proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://localhost:{{ host_port }}; proxy_pass http://localhost:{{ host_port }};
} }
location /db-image { location /fingerprint-report {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://localhost:{{ host_port }};
} location /db-image {
proxy_set_header Host $host:$server_port; proxy_set_header Host $host:$server_port;
proxy_set_header X-Scheme $scheme; proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-For $remote_addr;

View File

@ -33,8 +33,6 @@
state: started state: started
restart_policy: "unless-stopped" restart_policy: "unless-stopped"
env_file: "/var/lib/{{ host_directory }}/.env" env_file: "/var/lib/{{ host_directory }}/.env"
links:
- "postgres:db"
published_ports: published_ports:
- "127.0.0.1:{{ host_port }}:80" - "127.0.0.1:{{ host_port }}:80"
volumes: volumes:

View File

@ -33,8 +33,6 @@
state: started state: started
restart_policy: "unless-stopped" restart_policy: "unless-stopped"
env_file: "/var/lib/{{ host_directory }}/.env" env_file: "/var/lib/{{ host_directory }}/.env"
links:
- "postgres:db"
published_ports: published_ports:
- "127.0.0.1:{{ host_port }}:80" - "127.0.0.1:{{ host_port }}:80"
volumes: volumes:

View File

@ -33,8 +33,6 @@
state: started state: started
restart_policy: "unless-stopped" restart_policy: "unless-stopped"
env_file: "/var/lib/{{ host_directory }}/.env" env_file: "/var/lib/{{ host_directory }}/.env"
links:
- "postgres:db"
published_ports: published_ports:
- "127.0.0.1:{{ host_port }}:80" - "127.0.0.1:{{ host_port }}:80"
volumes: volumes:

View File

@ -33,8 +33,6 @@
state: started state: started
restart_policy: "unless-stopped" restart_policy: "unless-stopped"
env_file: "/var/lib/{{ host_directory }}/.env" env_file: "/var/lib/{{ host_directory }}/.env"
links:
- "postgres:db"
published_ports: published_ports:
- "127.0.0.1:{{ host_port }}:80" - "127.0.0.1:{{ host_port }}:80"
volumes: volumes:

10
lint.sh
View File

@ -1,9 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eEu -o pipefail
shopt -s extdebug
IFS=$'\n\t'
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P ) parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P )
cd "$parent_path/overlord" || exit cd "$parent_path/overlord" || exit
npx prettier --write src/app npx prettier --write src/app
npx ng lint --fix npx ng lint --fix
cd "$parent_path/brewman" || exit cd "$parent_path/brewman" || exit
isort brewman poetry run isort brewman
black brewman poetry run black brewman
flake8 brewman poetry run flake8 brewman

1
overlord/.gitignore vendored
View File

@ -31,6 +31,7 @@ chrome-profiler-events*.json
.history/* .history/*
# misc # misc
/.angular/cache
/.sass-cache /.sass-cache
/connect.lock /connect.lock
/coverage /coverage

View File

@ -14,46 +14,46 @@
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@angular/animations": "^12.2.13", "@angular/animations": "^13.3.6",
"@angular/cdk": "^12.2.12", "@angular/cdk": "^13.3.6",
"@angular/common": "^12.2.13", "@angular/common": "^13.3.6",
"@angular/compiler": "^12.2.13", "@angular/compiler": "^13.3.6",
"@angular/core": "^12.2.13", "@angular/core": "^13.3.6",
"@angular/flex-layout": "^12.0.0-beta.35", "@angular/flex-layout": "^13.0.0-beta.38",
"@angular/forms": "^12.2.13", "@angular/forms": "^13.3.6",
"@angular/material": "^12.2.12", "@angular/material": "^13.3.6",
"@angular/material-moment-adapter": "^12.2.12", "@angular/material-moment-adapter": "^13.3.6",
"@angular/platform-browser": "^12.2.13", "@angular/platform-browser": "^13.3.6",
"@angular/platform-browser-dynamic": "^12.2.13", "@angular/platform-browser-dynamic": "^13.3.6",
"@angular/router": "^12.2.13", "@angular/router": "^13.3.6",
"@ngx-loading-bar/core": "^5.1.2", "@ngx-loading-bar/core": "^6.0.2",
"@ngx-loading-bar/http-client": "^5.1.2", "@ngx-loading-bar/http-client": "^6.0.2",
"@ngx-loading-bar/router": "^5.1.2", "@ngx-loading-bar/router": "^6.0.2",
"@types/mousetrap": "1.6.8", "@types/mousetrap": "1.6.9",
"angular2-hotkeys": "^2.4.0", "angular2-hotkeys": "^13.1.0",
"mathjs": "^10.0.0", "mathjs": "^10.5.2",
"moment": "^2.29.1", "moment": "^2.29.3",
"rxjs": "^6.6.7", "rxjs": "^6.6.7",
"tslib": "^2.1.0", "tslib": "^2.1.0",
"zone.js": "~0.11.4" "zone.js": "~0.11.4"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "^12.2.13", "@angular-devkit/build-angular": "^13.3.5",
"@angular-eslint/builder": "^12.6.1", "@angular-eslint/builder": "^13.2.1",
"@angular-eslint/eslint-plugin": "^12.6.1", "@angular-eslint/eslint-plugin": "^13.2.1",
"@angular-eslint/eslint-plugin-template": "^12.6.1", "@angular-eslint/eslint-plugin-template": "^13.2.1",
"@angular-eslint/schematics": "^12.6.1", "@angular-eslint/schematics": "^13.2.1",
"@angular-eslint/template-parser": "^12.6.1", "@angular-eslint/template-parser": "^13.2.1",
"@angular/cli": "^12.2.13", "@angular/cli": "^13.3.5",
"@angular/compiler-cli": "^12.2.13", "@angular/compiler-cli": "^13.3.6",
"@angular/language-service": "^12.2.13", "@angular/language-service": "^13.3.6",
"@types/jasmine": "~3.7.4", "@types/jasmine": "~3.7.4",
"@types/node": "^16.11.6", "@types/node": "^17.0.31",
"@typescript-eslint/eslint-plugin": "4.28.2", "@typescript-eslint/eslint-plugin": "5.23.0",
"@typescript-eslint/parser": "4.28.2", "@typescript-eslint/parser": "5.23.0",
"eslint": "^7.26.0", "eslint": "^8.2.0",
"eslint-plugin-import": "^2.25.2", "eslint-plugin-import": "2.26.0",
"husky": "^7.0.4", "husky": "^8.0.1",
"jasmine-core": "~3.8.0", "jasmine-core": "~3.8.0",
"jasmine-spec-reporter": "7.0.0", "jasmine-spec-reporter": "7.0.0",
"karma": "^6.3.2", "karma": "^6.3.2",
@ -61,11 +61,11 @@
"karma-coverage": "~2.0.3", "karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.1", "karma-jasmine": "~4.0.1",
"karma-jasmine-html-reporter": "^1.6.0", "karma-jasmine-html-reporter": "^1.6.0",
"lint-staged": "^11.2.6", "lint-staged": "^12.4.1",
"prettier": "^2.4.1", "prettier": "^2.6.2",
"standard-version": "^9.3.2", "standard-version": "^9.3.2",
"ts-node": "^9.1.1", "ts-node": "^9.1.1",
"typescript": "~4.2.4" "typescript": "~4.6.4"
}, },
"husky": { "husky": {
"hooks": { "hooks": {

View File

@ -18,18 +18,6 @@
* BROWSER POLYFILLS * BROWSER POLYFILLS
*/ */
/**
* IE11 requires the following for NgClass support on SVG elements
*/
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/** /**
* By default, zone.js will patch all possible macroTask and DomEvents * By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags * user can disable parts of macroTask/DomEvents patch by setting following flags

View File

@ -19,7 +19,9 @@ declare const require: {
}; };
// First, initialize the Angular testing environment. // First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
teardown: { destroyAfterEach: false }
});
// Then we find all the tests. // Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/); const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules. // And load the modules.