Skip to content

Commit

Permalink
Fixed code standared violation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachinbisht27 committed May 8, 2024
1 parent 7620db7 commit 6a3a440
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 27 deletions.
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG] "
labels: bug
assignees: Sachinbisht27

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Set webhook payload '...'
2. Trigger webhook '....'
3. See the error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information):**
- Webhook Payload ``` here```
- Environment - Production/Staging/other

**Additional context**
Add any other context about the problem here.

**Acceptance Criteria**
Add acceptance criteria here.

**Documentation**
Add whatever documentation will be required here.
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE] "
labels: enhancement
assignees: Sachinbisht27

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.


**Acceptance Criteria**
Add acceptance criteria here.

**Documentation**
Add whatever documentation will be required here.
37 changes: 37 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!-- Pull Request Title Guidelines -->
<!--
Please follow the format: #<issue_id> <Title>
- <issue_id>: Id of the issue for which the PR belongs to (e.g., #1023)
- <Title>: A brief summary of the change (e.g., Add user authentication functionality)
Example of Pull Request Title: #1023 Add user authentication functionality
-->

#[ISSUE_ID]
<!--- If there is an open issue, please link to the issue here by replacing [ISSUE_ID]-->
<!-- Make sure the PR is against the `develop` branch -->

### Please complete the following steps and check these boxes before filing your PR:


### Types of changes
<!--- What types of changes does your code introduce? -->
- [ ] Bug fix (a change which fixes an issue)
- [ ] New feature (a change which adds functionality)


### Short description of what this resolves:
<!--- Describe your changes in detail -->
<!--- Why these change required? What problem does it solve? -->


### Checklist:
<!--- Mark the checkboxes accordingly. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] I have performed a self-review of my own code.
- [ ] The code follows the style guidelines of this project.
- [ ] The code changes are passing the CI checks
- [ ] I have documented my code wherever required.
- [ ] The changes requires a change to the documentation.
- [ ] I have updated the documentation based on the my changes.
- [ ] I have added tests to cover my changes (if not applicable, please state why)
- [ ] All new and existing tests are passing.
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: pre-commit

on:
pull_request:
push:
branches:
- develop
- main
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
17 changes: 15 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-yaml
- id: check-merge-conflict
- id: check-added-large-files
- id: debug-statements
- id: requirements-txt-fixer
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 24.4.2
hooks:
- id: black
args: [--line-length=88]
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
exclude: __init__.py
args: [--max-line-length=170]
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
32 changes: 16 additions & 16 deletions SLACKAPP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,52 @@

1. Go to the channel on which you want to install the app
2. Go to the view all members icon on the top right of the channel

![image](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/13cc0d92-076e-4fd5-b985-fb5102efac79)


3. Click on **add app** option
4. Click on **View app directory**
5. Click on the **build** option at the top right of the menu
6. Create an app from scratch
7. Provide a name to the app and assign it to a workspace
8. Go to OAuth and Permission menu

![image (9)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/252b96f9-ce02-4c74-bcdc-0527b01c3742)


9. Under the scope section, give the app permission to write messages

![image (10)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/6183d4aa-4577-4fe8-af35-5c8baf28d93c)


10. Install the app to the workspace

![image (11)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/4b75f0a7-0c34-4abe-b31d-120ed99d8679)


11. Give permission to the app

![image (12)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/1ef99851-9258-4c87-88f3-22dd7971d665)


12. Once the app is installed copy the OAuth Token as it will be used for authentication.

![image (14)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/355d7d13-9cef-4d6b-9a6d-894c96685e95)


13. Go to the channel where you want to add app.
14. Click on the `channel name` .
15. Click on the integrations tab here.

![Untitled](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/cc301091-2403-4541-ad55-305224bc7f7c)


16. Then click on the `Add apps`.

![Untitled (2)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/1cf34c76-a38a-4f85-86c7-dd4ef0241246)


17. Then recognize the newly created app and add to the channel.

![Untitled (3)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/17cf0b6f-d8bb-4033-81f4-8bc64e543a8e)
Expand Down
6 changes: 3 additions & 3 deletions app/services/budget_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def handle(self, alert_attrs, alert_data):

# Check if the alert is for the previous month
if year_month_of_budget_interval != current_year_month:
## The pub/sub is sending us alerts for the previous month on the first day of the new month.
## To handle this condition, we compare the Month-Year of the budget alert interval with the current Month-Year.
# The pub/sub is sending us alerts for the previous month on the first day of the new month.
# To handle this condition, we compare the Month-Year of the budget alert interval with the current Month-Year.
return

billing_id = alert_attrs.get("billingAccountId")
Expand All @@ -47,7 +47,7 @@ def handle(self, alert_attrs, alert_data):

notify = notification_helper.notify(slack_block)

if notify == True:
if notify:
self.insert_new_threshold(cost, budget, budget_name, threshold)

def is_new_threshold_greater(self, threshold):
Expand Down
4 changes: 2 additions & 2 deletions app/services/slack_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def send_alert(self, slack_block):
channel=self.channel_name,
blocks=slack_block["blocks"],
)
logger.info(f"Alert Sent")
logger.info("Alert Sent")
return True
except Exception as e:
logger.error(f"Exception occurred:{e}")
logger.error(f"Exception occurred:{e}. Response: {response}")
return False
6 changes: 3 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pre-commit==2.20.0
python-dotenv==0.20.0
slackclient==2.9.4
functions-framework==3.2.0
google-cloud-logging==3.5.0
google_cloud_bigquery==3.11.4
pre-commit==2.20.0
python-dotenv==0.20.0
slackclient==2.9.4
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
slackclient==2.9.4
functions-framework==3.2.0
google-cloud-logging==3.5.0
google_cloud_bigquery==3.11.4
slackclient==2.9.4
Werkzeug==2.3.7

0 comments on commit 6a3a440

Please sign in to comment.