Skip to content

Commit

Permalink
fix dump
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariiiii committed Dec 8, 2024
1 parent c483745 commit c476259
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 39 deletions.
20 changes: 0 additions & 20 deletions backend/app/init_db.py

This file was deleted.

17 changes: 8 additions & 9 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from routes.statistic import bp as statistic_routes
from models import Client
from pymongo import MongoClient
#from utils.dump import create_sample_data
from utils.dump import create_sample_data

app = Flask(__name__)
app.config.from_object(Config)
Expand All @@ -19,14 +19,13 @@
disconnect()
connect(host=app.config['MONGO_URI'])

#@app.before_first_request
#def check_collections():
#client = MongoClient(app.config['MONGO_URI'])
#db = client.get_default_database()
##collections = db.list_collection_names()
#if not collections:
# pass
##create_sample_data()
@app.before_first_request
def check_collections():
client = MongoClient(app.config['MONGO_URI'])
db = client.get_default_database()
collections = db.list_collection_names()
if not collections:
create_sample_data()

app.register_blueprint(auth_routes_bp)
app.register_blueprint(request_routes_bp)
Expand Down
2 changes: 1 addition & 1 deletion backend/app/routes/auth_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ def register():
print(e)
return jsonify({"message": "Ошибка со стороны сервера"}), 404
else:
return jsonify({"message": "ОшибкаЭ пользователь с такой почтой существует"}), 401
return jsonify({"message": "Ошибка пользователь с такой почтой существует"}), 401
6 changes: 2 additions & 4 deletions backend/app/utils/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from bson import ObjectId
from models import Credit, CreditHistory, CreditRequest, Client, Admin, InteractionHistory

connect(db="credit_database", host="localhost", port=27017)

def create_sample_data():

credits = [
Expand Down Expand Up @@ -75,5 +73,5 @@ def load_data_from_json(dump_file):
CreditRequest(**credit_request_data).save()
print("Данные успешно загружены из дампа.")

create_sample_data()
load_data_from_json(dump_data_to_json("mongo_dump.json"))
# create_sample_data()
# load_data_from_json(dump_data_to_json("mongo_dump.json"))
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
mongo:
image: mongodb/mongodb-community-server:7.0.0-ubi8
Expand All @@ -12,7 +10,7 @@ services:
container_name: backend
build: ./backend
ports:
- "5000:5000"
- "127.0.0.1:5000:5000"
environment:
- MONGO_URI=mongodb://mongo:27017/credit_database
depends_on:
Expand All @@ -24,7 +22,7 @@ services:
container_name: frontend
build: ./frontend
ports:
- "8080:8080"
- "127.0.0.1:8080:8080"
networks:
- default
depends_on:
Expand Down
1 change: 0 additions & 1 deletion mongo_dump.json

This file was deleted.

0 comments on commit c476259

Please sign in to comment.