-
Notifications
You must be signed in to change notification settings - Fork 1
352 DB limitation #427
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
Merged
Merged
352 DB limitation #427
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9a5e998
Added new methods to control storage limits in DBManager
t33nsy 3a58841
Added route to watch used storage and max storage
t33nsy 927930f
temp
t33nsy 8a20911
added training stop in presentation route
t33nsy 8802224
temp
t33nsy 1d4e949
removed max_size from comfig
t33nsy dcdab5b
changes
t33nsy fdf1bef
fixed test, added mock
t33nsy 489a3fd
fixes, added button on capacity.py
t33nsy f7011df
Changed in too_big test response from 404 to 413
t33nsy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| from flask import Blueprint, render_template | ||
| from app.mongo_odm import DBManager | ||
| from app.root_logger import get_root_logger | ||
| from app.lti_session_passback.auth_checkers import is_admin | ||
|
|
||
| logger = get_root_logger() | ||
|
|
||
| BYTES_PER_MB = 1024*1024 | ||
|
|
||
| routes_capacity = Blueprint( | ||
| 'routes_capacity', __name__, url_prefix='/capacity') | ||
|
|
||
| @routes_capacity.route('/', methods=['GET']) | ||
| def storage_capacity(): | ||
| if not is_admin(): | ||
| return {}, 404 | ||
| current_size = DBManager().get_used_storage_size() | ||
| max_size = DBManager().get_max_size() | ||
| ratio = current_size / max_size | ||
| return render_template( | ||
| 'capacity.html', | ||
| size=round(current_size / BYTES_PER_MB, 2), | ||
| max_size=round(max_size / BYTES_PER_MB, 2), | ||
| ratio=round(ratio * 100, 1) | ||
| ) | ||
|
|
||
| @routes_capacity.route('/refresh_capacity', methods=['POST']) | ||
| def refresh_capacity(): | ||
| if not is_admin(): | ||
| return {}, 404 | ||
| DBManager().recalculate_used_storage_data() | ||
| return {'message': 'OK'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| {% extends 'base.html' %} | ||
|
|
||
| {% block content %} | ||
| <div class="container mt-4"> | ||
| <div class="card"> | ||
| <div class="card-body"> | ||
| <h4 class="card-title">Загруженность Базы Данных</h4> | ||
| <p><strong>Использовано:</strong> {{ size }} Мбайт</p> | ||
| <p><strong>Максимум:</strong> {{ max_size }} Мбайт</p> | ||
| <p><strong>Заполнено:</strong> {{ ratio }}%</p> | ||
| <div class="progress"> | ||
| <div class="progress-bar" role="progressbar" style="width: {{ ratio }}%;" aria-valuenow="{{ ratio }}" aria-valuemin="0" aria-valuemax="100"> | ||
| {{ ratio }} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <button type="button" id="refresh_button">Обновить данные</button> | ||
|
|
||
| <script src="/static/js/libraries/jquery.min.js"></script> | ||
| <script> | ||
| $('#refresh_button').click(function() { | ||
| $.post("{{ url_for('routes_capacity.refresh_capacity') }}", {}, function(data) { | ||
| location.reload(); | ||
| }); | ||
| }); | ||
| </script> | ||
| </div> | ||
| </div> | ||
| {% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавьте метод для актуализации данных (вдруг где-то логика дала сбой и насчитала нам что-то, или вручную из бд были удалены файлы) - ему нужно будет пройтись по всем документам и посчитать их общий вес