Skip to content

Commit

Permalink
fix log registry
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavyadav-dev committed Nov 15, 2024
1 parent 83a00e6 commit 76c5fe9
Show file tree
Hide file tree
Showing 7 changed files with 344 additions and 224 deletions.
8 changes: 4 additions & 4 deletions .env
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
RABBITMQ_HOST=rabbitmq
RABBITMQ_HOST=localhost
RABBITMQ_PORT=5672
RABBITMQ_USER=rootuser
RABBITMQ_PASSWORD=rootuser

MONGODB_URL=mongodb://rootuser:rootuser@mongodb:27017?authSource=admin
MONGODB_URL=mongodb://rootuser:rootuser@localhost:27017?authSource=admin
MONGODB_USER=rootuser
MONGODB_PASSWORD=rootuser

POSTGRESQL_URL=postgres://rootuser:rootuser@postgres:5432/postgres?sslmode=disable
POSTGRESQL_HOST=localhost
POSTGRESQL_USER=rootuser
POSTGRESQL_PASSWORD=rootuser
POSTGRESQL_PORT=5432
POSTGRESQL_HOST=postgres
POSTGRESQL_DB=postgres
POSTGRESQL_URL=postgres://rootuser:rootuser@localhost:5432/postgres?sslmode=disable

SMTP_HOST=smtp.gmail.com
SMTP_PORT=465
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
sudo docker rm -f worker_service || true
sudo docker-compose up -d --build
sudo docker exec -it nginx nginx -s reload
sudo docker exec nginx nginx -s reload
11 changes: 11 additions & 0 deletions databases/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,16 @@ def insert_mongodb(data, collection, db="db"):
mongo_db = mongo_client[db]
mongo_collection = mongo_db[collection]
mongo_collection.insert_one(data)
# mongo_collection.
except Exception as e:
print(f"MongoDB insert Error: {e}")


def update_mongodb(filter, data, collection, db="db"):
try:
print("DB: ", db, "Collection: ", collection, "category: ", data)
mongo_db = mongo_client[db]
mongo_collection = mongo_db[collection]
mongo_collection.update_one(data)
except Exception as e:
print(f"MongoDB update Error {e}")
26 changes: 18 additions & 8 deletions databases/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,31 @@
dbname=POSTGRESQL_DB,
user=POSTGRESQL_USER,
password=POSTGRESQL_PASSWORD,
host=POSTGRESQL_HOST
host=POSTGRESQL_HOST,
port=POSTGRESQL_PORT,
)

pg_cursor = pg_connection.cursor()
def insert_postgresql(data):
try:
query = "INSERT INTO hip_table (name, id) VALUES (%s, %s);"
pg_cursor.execute(query, (data['field1'], data['field2']))
def counter_update_client_postgresql(category, health_id):
try:
query = f"UPDATE client_stats SET {category} = {category} + 1 WHERE health_id = %s;"
pg_cursor.execute(query, (health_id,))
pg_connection.commit()
print(f"{category} counter updated successfully for health_id {health_id}.")
except Exception as e:
print(f"PostgreSQL Error: {e}")
pg_connection.rollback()

def counter_update_healthcare_postgresql(category, healthcare_id):
try:
query = f"UPDATE healthcare_pref SET {category} = {category} + 1 WHERE healthcare_id = %s;"
pg_cursor.execute(query, (healthcare_id,))
pg_connection.commit()
print(f"{category} counter updated successfully for healthcare_id {healthcare_id}.")
except Exception as e:
print(f"PostgreSQL Error: {e}")
pg_connection.rollback()


pg_cursor.close()
pg_connection.close()

# pg_cursor.close()
# pg_connection.close()
Loading

0 comments on commit 76c5fe9

Please sign in to comment.