Skip to content

Commit

Permalink
571: refactor methods and types
Browse files Browse the repository at this point in the history
  • Loading branch information
necitboss committed Jul 5, 2024
1 parent 7b37b79 commit 1a32f2f
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 51 deletions.
2 changes: 1 addition & 1 deletion app/db/clear_users.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from .db_methods import client
from .db_main import client

logger = logging.getLogger('root_logger')

Expand Down
File renamed without changes.
10 changes: 0 additions & 10 deletions app/db/db_types.py

This file was deleted.

8 changes: 2 additions & 6 deletions app/db/methods/celery_check.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
from datetime import datetime

from app.db.db_methods import get_celery_check_collection
from app.db.methods.client import get_client, get_db, get_fs
from app.db.db_main import get_celery_check_collection
from app.db.methods.client import get_db

from app.db.types.Logs import Logs

# client = get_client()
db = get_db()
# fs = get_fs()

celery_check_collection = get_celery_check_collection() # collection for mapping celery_task to check

Expand Down
11 changes: 3 additions & 8 deletions app/db/methods/check.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from gridfs import GridFSBucket, NoFile
from gridfs import NoFile
from datetime import datetime

import pymongo

from app.db.db_methods import get_checks_collection, get_users_collection, get_files_info_collection
from app.db.methods.client import get_client, get_db, get_fs
from app.db.db_main import get_checks_collection, get_users_collection, get_files_info_collection
from app.db.methods.client import get_db, get_fs
from app.db.types.Check import Check


# client = get_client()
db = get_db()
fs = get_fs()

Expand All @@ -18,9 +17,6 @@
files_info_collection = get_files_info_collection()





def add_check(file_id, check):
checks_id = checks_collection.insert_one(check.pack()).inserted_id
files_info_collection.update_one({'_id': file_id}, {"$push": {'checks': checks_id}})
Expand Down Expand Up @@ -134,7 +130,6 @@ def get_checks_cursor(filter={}, limit=10, offset=0, sort=None, order=None):
# get logs cursor with specified parameters



def get_user_checks(login):
return checks_collection.find({'user': login})

Expand Down
6 changes: 2 additions & 4 deletions app/db/methods/criteria_pack.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from datetime import datetime

from app.db.db_methods import get_criteria_pack_collection
from app.db.methods.client import get_client, get_db, get_fs
from app.db.db_main import get_criteria_pack_collection
from app.db.methods.client import get_db, get_fs

# from app.db.types. import Logs

# client = get_client()
db = get_db()
fs = get_fs()

Expand Down
2 changes: 1 addition & 1 deletion app/db/methods/edit_user.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from app.db.db_methods import users_collection
from app.db.db_main import users_collection


def edit_user(user):
Expand Down
2 changes: 1 addition & 1 deletion app/db/methods/file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from app.db.db_methods import get_files_info_collection, get_users_collection
from app.db.db_main import get_files_info_collection, get_users_collection
from app.db.methods.client import get_client, get_db, get_fs
from os.path import basename
from bson import ObjectId
Expand Down
6 changes: 2 additions & 4 deletions app/db/methods/log.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import pymongo

from app.db.db_methods import get_logs_collection
from app.db.methods.client import get_client, get_db, get_fs
from app.db.db_main import get_logs_collection
from app.db.methods.client import get_db

from app.db.types.Logs import Logs

# client = get_client()
db = get_db()
# fs = get_fs()

logs_collection = get_logs_collection()

Expand Down
5 changes: 1 addition & 4 deletions app/db/methods/user.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import pymongo

from app.db.db_methods import get_users_collection
from app.db.db_main import get_users_collection
from app.db.methods.client import get_db
from app.db.types.User import User

from app.db.methods.file import delete_presentation


# client = get_client()
db = get_db()
# fs = get_fs()

users_collection = get_users_collection()

Expand Down
3 changes: 1 addition & 2 deletions app/db/types/ConsumerDBManager.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from app.db.methods.client import get_client, get_db, get_fs
from app.db.methods.client import get_db, get_fs


from app.db.types.Consumers import Consumers

# client = get_client()
db = get_db()
fs = get_fs()

Expand Down
2 changes: 1 addition & 1 deletion app/routes/check_list.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from flask import Blueprint, render_template, jsonify, request

from app.utils import format_check_for_table, checklist_filter
from app.db import db_methods
from app.db import db_main
from app.db.methods import check as check_methods

from flask_login import login_required, current_user
Expand Down
2 changes: 1 addition & 1 deletion app/routes/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from flask import Blueprint, render_template, Response
from flask_login import login_required

from app.db import db_methods
from app.db import db_main
from app.db.methods import file as file_methods
from app.root_logger import get_root_logger

Expand Down
2 changes: 1 addition & 1 deletion app/routes/get_last_check_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from flask import Blueprint, render_template, redirect, url_for
from flask_login import login_required

from app.db import db_methods
from app.db import db_main
from app.root_logger import get_root_logger


Expand Down
2 changes: 1 addition & 1 deletion app/routes/get_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from flask import Blueprint, Response, render_template
from flask_login import login_required

from app.db import db_methods
from app.db import db_main
from app.db.methods import file as file_methods

from app.root_logger import get_root_logger
Expand Down
2 changes: 1 addition & 1 deletion app/routes/get_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from flask import Blueprint, abort, request, Response
from flask_login import login_required, current_user

from app.db import db_methods
from app.db import db_main
from app.db.methods import file as file_methods
from app.db.methods import check as check_methods

Expand Down
4 changes: 0 additions & 4 deletions app/routes/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
from app.root_logger import get_root_logger
from datetime import datetime, timedelta
from app.db.methods.log import get_logs_cursor
# from app.server_consts import logger
logs = Blueprint('logs', __name__, template_folder='templates', static_folder='static')
logger = get_root_logger('web')


# def get_logger():
# return logger

@logs.route("/")
@login_required
def logs_main():
Expand Down
2 changes: 1 addition & 1 deletion app/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from celery.signals import worker_ready

from passback_grades import run_passback
from db import db_methods
from db import db_main
from db.types.Check import Check
from main.checker import check
from main.parser import parse
Expand Down

0 comments on commit 1a32f2f

Please sign in to comment.