From 865f2c0567ee7cd3817bb8f0fb3feb9f51fdb672 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 May 2022 02:35:54 +0000 Subject: [PATCH 1/9] build(deps): bump docker/metadata-action from 3 to 4 Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 3 to 4. - [Release notes](https://github.com/docker/metadata-action/releases) - [Upgrade guide](https://github.com/docker/metadata-action/blob/master/UPGRADE.md) - [Commits](https://github.com/docker/metadata-action/compare/v3...v4) --- updated-dependencies: - dependency-name: docker/metadata-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d242ede..a1fa385 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,7 +54,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Extra metadata (tags, labels) id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v4 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: type=semver,pattern={{version}},value=${{ needs.release.outputs.tag }} From b896c26f5b918edfc70beb704a862b49731c30da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 May 2022 02:35:59 +0000 Subject: [PATCH 2/9] build(deps): bump docker/setup-buildx-action from 1 to 2 Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 1 to 2. - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](https://github.com/docker/setup-buildx-action/compare/v1...v2) --- updated-dependencies: - dependency-name: docker/setup-buildx-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d242ede..12167fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,7 +45,7 @@ jobs: with: ref: refs/tags/${{ needs.release.outputs.tag }} - name: set up Docker builder - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Log in to the Cntainer registry uses: docker/login-action@v1 with: From 83e02483a80cb04d977c963ebf4e719f884e77fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 May 2022 02:36:01 +0000 Subject: [PATCH 3/9] build(deps): bump docker/build-push-action from 2 to 3 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 2 to 3. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d242ede..9647c14 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,7 +60,7 @@ jobs: tags: type=semver,pattern={{version}},value=${{ needs.release.outputs.tag }} flavor: latest=auto - name: Build and push Docker image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: . push: true From 5630b523e1a5115e0489028aed81b550a7f41b18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 May 2022 02:43:16 +0000 Subject: [PATCH 4/9] build(deps): update fastapi requirement from ^0.75.2 to ^0.78.0 Updates the requirements on [fastapi](https://github.com/tiangolo/fastapi) to permit the latest version. - [Release notes](https://github.com/tiangolo/fastapi/releases) - [Commits](https://github.com/tiangolo/fastapi/compare/0.75.2...0.78.0) --- updated-dependencies: - dependency-name: fastapi dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2847ec0..b591a70 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ authors = ["MarionetkaX "] [tool.poetry.dependencies] python = "^3.10" -fastapi = "^0.75.2" +fastapi = "^0.78.0" uvicorn = "^0.17.6" SQLAlchemy = "^1.4.32" alembic = "^1.7.7" From 066d3bdac421989d1d9f1082f7718f29129546ad Mon Sep 17 00:00:00 2001 From: MiloslavskiySergey Date: Wed, 27 Jul 2022 13:47:33 +0300 Subject: [PATCH 5/9] refactor: change in indicators --- main.py | 8 +++++--- task.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 6083c3d..15234d4 100644 --- a/main.py +++ b/main.py @@ -20,6 +20,7 @@ Site, \ Email from settings import SECRET_KEY +from services.network_load import interest_calculation app = FastAPI() @@ -46,14 +47,15 @@ async def calculate(identification: str, where(Traffic.id == traffic[0].id). values(id=traffic[0].id, counter=Traffic.counter+1, - average_load=Traffic.counter * 0.0184, - maximum_load=Traffic.counter * 0.0305, )) await session.commit() return traffic[0] traffic_id = (await session.execute(insert(Traffic).values(counter=1, create_at=date.today(), - site_id=site[0].id))).inserted_primary_key[0] + site_id=site[0].id, + average_load=interest_calculation()['average_load'], + maximum_load=interest_calculation()['maximum_load'], + ))).inserted_primary_key[0] await session.commit() return (await session.execute(select(Traffic).where(Traffic.id == traffic_id))).first()[0] diff --git a/task.py b/task.py index 7c9c82a..338bda0 100644 --- a/task.py +++ b/task.py @@ -39,8 +39,8 @@ async def send_message(): sleep(1) -schedule.every().day.at(f'{NOTIFICATION_SEND_TIME}').do(send_message) -#schedule.every(20).seconds.do(send_message) +# schedule.every().day.at(f'{NOTIFICATION_SEND_TIME}').do(send_message) +schedule.every(20).seconds.do(send_message) while True: get_event_loop().run_until_complete(schedule.run_pending()) From a04a4550fb1395508f09c2b00757988540cf6bb3 Mon Sep 17 00:00:00 2001 From: MiloslavskiySergey Date: Wed, 27 Jul 2022 13:49:12 +0300 Subject: [PATCH 6/9] fix: fixed task --- task.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task.py b/task.py index 338bda0..a84aa65 100644 --- a/task.py +++ b/task.py @@ -39,8 +39,8 @@ async def send_message(): sleep(1) -# schedule.every().day.at(f'{NOTIFICATION_SEND_TIME}').do(send_message) -schedule.every(20).seconds.do(send_message) +schedule.every().day.at(f'{NOTIFICATION_SEND_TIME}').do(send_message) +# schedule.every(20).seconds.do(send_message) while True: get_event_loop().run_until_complete(schedule.run_pending()) From a824195c3757ecbd6ff16e9ea2f714c43bfe34fa Mon Sep 17 00:00:00 2001 From: MiloslavskiySergey Date: Wed, 27 Jul 2022 13:49:32 +0300 Subject: [PATCH 7/9] refactor: change in indicators --- services/network_load.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 services/network_load.py diff --git a/services/network_load.py b/services/network_load.py new file mode 100644 index 0000000..a3faf2c --- /dev/null +++ b/services/network_load.py @@ -0,0 +1,19 @@ +"""Расчет нагрузки сети.""" +from datetime import datetime +from random import uniform + + +def interest_calculation() -> dict: + """Генерация процента нагруженности сети.""" + + week_day = datetime.today().weekday() + if (week_day >= 0) and (week_day <= 4): + return { + 'average_load': 45 + uniform(5, 10), + 'maximum_load': 45 + uniform(10, 20) + } + else: + return { + 'average_load': 42 + uniform(0, 5), + 'maximum_load': 42 + uniform(5, 10) + } From 939977d3f1e8115c06bd615af14f7df8a1a5fa07 Mon Sep 17 00:00:00 2001 From: MiloslavskiySergey Date: Wed, 27 Jul 2022 13:58:25 +0300 Subject: [PATCH 8/9] refactor: change in indicators --- main.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/main.py b/main.py index 59fd181..e613643 100644 --- a/main.py +++ b/main.py @@ -63,11 +63,6 @@ async def calculate(identification: str, where(Traffic.id == traffic[0].id). values(id=traffic[0].id, counter=Traffic.counter+1, -<<<<<<<<< Temporary merge branch 1 - average_load=Traffic.counter * 0.0125, - maximum_load=Traffic.counter * 0.0195, -========= ->>>>>>>>> Temporary merge branch 2 )) await session.commit() return traffic[0] From bf0401ef824f4dd1d698d2c7d1f0295d3a6f4072 Mon Sep 17 00:00:00 2001 From: MiloslavskiySergey Date: Wed, 27 Jul 2022 14:01:08 +0300 Subject: [PATCH 9/9] refactor: change cors --- main.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index e613643..e932fcd 100644 --- a/main.py +++ b/main.py @@ -25,12 +25,8 @@ app = FastAPI() -origins = [ - 'http://sbmpei.ru', - 'https://sbmpei.ru', - 'http://localhost', - 'http://localhost:8095', -] +origins = ['*'] + app.add_middleware( CORSMiddleware,