Skip to content
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

Scaffolding of a FLASK app for WhatsApp analytics #5

Merged
merged 22 commits into from
Apr 18, 2024

Conversation

Sachinbisht27
Copy link
Member

@Sachinbisht27 Sachinbisht27 commented Apr 13, 2024

#3

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

Types of changes

  • Bug fix (a change which fixes an issue)
  • New feature (a change which adds functionality)

Short description of what this resolves:

Added changes

  • Application architecture
  • Database connectivity
  • Setup FLASK application
  • Updated README.MD for the installation guidelines
  • Logic to handle or process the webhook payload
  • Webhook Transaction log table to store the webhook's data
  • Google-cloud-logging for the monitoring of the service
  • CI checks for the better coding standards
  • Save the webhook transaction logs in the database as of now
  • Migrations for maintaining the database schemas through automation
  • Create all the database models based on the database schema

Checklist:

  • 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.\

@Sachinbisht27 Sachinbisht27 self-assigned this Apr 13, 2024
Comment on lines +5 to +10
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-yaml
- id: check-merge-conflict
- id: check-added-large-files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few more hooks which can be helpful for our usecase

  1. flake8 - Purpose: Runs the Flake8 code linter to check for PEP 8 violations and other style issues.
  2. black - Purpose: Applies the Black code formatter to format Python code according to PEP 8 standards.
  3. isort - Purpose: Sorts import statements in Python files according to PEP 8 guidelines.
  4. mypy - Purpose: Runs the MyPy static type checker to find type errors in Python code.
  5. docformatter - Purpose: Formats docstrings in Python files to adhere to PEP 257 guidelines.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few more hooks in the pre-commit config.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it helpful so far? @Sachinbisht27

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, @Satendra-SR. For the code formatting and increasing readability of the code.

@Satendra-SR Satendra-SR changed the base branch from main to develop April 13, 2024 12:51
@Sachinbisht27 Sachinbisht27 removed the WIP label Apr 15, 2024
@Sachinbisht27 Sachinbisht27 changed the title Scaffolding of a FastAPI app for WhatsApp analytics Scaffolding of a FLASK app for WhatsApp analytics Apr 18, 2024
on:
pull_request:
push:
branches: [main]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add develop branch as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

3. Activate the virtual environment
```sh
source ./venv/bin/activate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's include Windows command as well. I believe we have different commands to active in MacOS vs Windows.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added command for win-os

README.md Outdated
4. Install the dependencies:
```sh
pip install -r requirements-dev.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge requirements-dev.txt and requirements.txt and use requirements.txt instead as there are only one additional package we are using in requirements-dev.txt

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged

Comment on lines +5 to +10
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-yaml
- id: check-merge-conflict
- id: check-added-large-files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it helpful so far? @Sachinbisht27

config.py Outdated
Comment on lines 3 to 5
from dotenv import load_dotenv

load_dotenv()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we need this on cloud function. Can we out it under if condition? If ENV is development, then load this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, @Satendra-SR Moved the load_dotenv() to the environment condition.

Copy link
Member

@Satendra-SR Satendra-SR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some changes in the last review, got approved mistakenly

# add your model's MetaData object here
# for 'autogenerate' support

target_metadata = models.Base.metadata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we try this?

target_metadata = db.metadata

Copy link
Member

@Satendra-SR Satendra-SR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions, else looks good to go

from api import app

logger = logging.getLogger()
logging.basicConfig(level=logging.DEBUG)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get the logging level from ENV?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, updating.

config.py Outdated
Comment on lines 8 to 13
from os import path

from dotenv import load_dotenv

basedir = path.abspath(path.dirname(__file__))
load_dotenv(path.join(basedir, ".env"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from os import path
from dotenv import load_dotenv
basedir = path.abspath(path.dirname(__file__))
load_dotenv(path.join(basedir, ".env"))
from dotenv import load_dotenv
load_dotenv()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@Sachinbisht27 Sachinbisht27 merged commit 6e450f9 into develop Apr 18, 2024
1 check passed
@Satendra-SR Satendra-SR deleted the feature/3-scaffolding-fastapi-app branch April 19, 2024 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants