-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new service file for crating base user types
- Loading branch information
Showing
5 changed files
with
75 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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 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,15 @@ | ||
# _ _ _ _ _ __ __ ____ | ||
# | | (_) | | | | (_) | \/ |/ __ \ | ||
# | | _ | |_ | |__ _ _ _ _ __ ___ | \ / | | | | | ||
# | | | | | __| | "_ \ | | | | | | | "_ ` _ \ | |\/| | | | | | ||
# | |____ | | | |_ | | | | | | | |_| | | | | | | | | | | | |__| | | ||
# |______| |_| \__| |_| |_| |_| \__,_| |_| |_| |_| |_| |_|\___\_\ | ||
|
||
from redis_storage.params_creator import get_redis_link | ||
from content_limits import init_limit | ||
from flask import Flask | ||
|
||
|
||
def limit_generator(app: Flask): | ||
uri, params = get_redis_link() | ||
return init_limit(app, uri, params) |
This file contains 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 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,45 @@ | ||
# _ _ _ _ _ __ __ ____ | ||
# | | (_) | | | | (_) | \/ |/ __ \ | ||
# | | _ | |_ | |__ _ _ _ _ __ ___ | \ / | | | | | ||
# | | | | | __| | "_ \ | | | | | | | "_ ` _ \ | |\/| | | | | | ||
# | |____ | | | |_ | | | | | | | |_| | | | | | | | | | | | |__| | | ||
# |______| |_| \__| |_| |_| |_| \__,_| |_| |_| |_| |_| |_|\___\_\ | ||
|
||
from storage.db_session import base_init | ||
from storage.user_type import UserType | ||
|
||
# TODO in json or something else | ||
USER_TYPES = [ | ||
UserType( | ||
name='Free', | ||
max_channel_count=2, | ||
max_message_size=256, | ||
bufferization=True, | ||
max_bufferred_message_count=256, | ||
buffered_data_persistency=12, | ||
end_to_end_data_encryption=False | ||
) | ||
] | ||
|
||
|
||
# init data in tables | ||
def init_db_data(): | ||
sess_object = base_init() | ||
session = sess_object() | ||
accounts = session.query(UserType).first() | ||
if accounts: | ||
print('db inited') | ||
return | ||
print('generate db data...') | ||
for user_type in USER_TYPES: | ||
session.add(user_type) | ||
session.commit() | ||
print('db init done') | ||
|
||
|
||
def main(): | ||
init_db_data() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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