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

New script requested_changes #65

Merged
merged 3 commits into from
Jun 18, 2024
Merged

New script requested_changes #65

merged 3 commits into from
Jun 18, 2024

Conversation

YustinaKvr
Copy link
Contributor

  1. Script requested_changes.py has been added

Comment on lines +21 to +50
db_host = os.getenv("DB_HOST")
db_port = os.getenv("DB_PORT")
db_csv = os.getenv("DB_CSV") # main postgres db, where open PRs tables for both public and hybrid clouds are stored
db_user = os.getenv("DB_USER")
db_password = os.getenv("DB_PASSWORD")


def check_env_variables():
required_env_vars = [
"DB_HOST", "DB_PORT",
"DB_CSV", "DB_USER", "DB_PASSWORD", "GITEA_TOKEN"
]
for var in required_env_vars:
if os.getenv(var) is None:
raise Exception("Missing environment variable: %s", var)


def connect_to_db(db_name):
logging.info("Connecting to Postgres (%s)...", db_name)
try:
return psycopg2.connect(
host=db_host,
port=db_port,
dbname=db_name,
user=db_user,
password=db_password
)
except psycopg2.Error as e:
logging.error("Connecting to Postgres: an error occurred while trying to connect to the database: %s", e)
return None
Copy link
Member

Choose a reason for hiding this comment

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

i don't understand why are you using same code in all files, please introduce db class and reuse it

Copy link
Member

Choose a reason for hiding this comment

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

same for env variables

Comment on lines +346 to +348
org_string = "docs"
rtc_table = "repo_title_category"
changes_table = "requested_changes"
Copy link
Member

Choose a reason for hiding this comment

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

if using const, better not to store them here, move to first lines and probably good to have ability to change them through env variables

Comment on lines +360 to +361
main(org_string, rtc_table, changes_table)
main(f"{org_string}-swiss", f"{rtc_table}_swiss", f"{changes_table}_swiss")
Copy link
Member

Choose a reason for hiding this comment

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

use for cycle by dictionary with envs, in case that in future there will be more environments and add logging for each call. Also main is a bad name for this func

@YustinaKvr YustinaKvr merged commit d50c35d into main Jun 18, 2024
2 checks passed
@YustinaKvr YustinaKvr deleted the requested_changes branch June 18, 2024 12:12
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.

3 participants