Skip to content
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

Sourcery refactored master branch #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Sep 23, 2022

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from 0niel September 23, 2022 09:24
Comment on lines -69 to +74
if question_type == 'shortanswer' or question_type == 'numerical' or question_type == 'multichoice' or question_type == 'truefalse':
if question_type in [
'shortanswer',
'numerical',
'multichoice',
'truefalse',
]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AnswersDB.add_user_answer refactored with the following changes:

This removes the following comments ( why? ):

# если пользователь не отпралял этот вариант ответа

Comment on lines -179 to +246
if await AnswersDB.find_question_by_ans(conn, question, answer, session) is None:
return await conn[DATABASE_NAME][QUESTIONS_COLLECTION_NAME].find_one_and_update(
return (
await conn[DATABASE_NAME][
QUESTIONS_COLLECTION_NAME
].find_one_and_update(
{'question': question},
{'$push': {'answers': {'answer': answer, 'users': [], 'correct': [
user_info], 'not_correct': []}}}, {"_id": 0},
return_document=ReturnDocument.AFTER, session=session
)
else:
return await conn[DATABASE_NAME][QUESTIONS_COLLECTION_NAME].find_one_and_update(
{'question': question, 'answers.answer': answer},
{'$push': {'answers.$.correct': user_info}}, {"_id": 0},
return_document=ReturnDocument.AFTER, session=session
{
'$push': {
'answers': {
'answer': answer,
'users': [],
'correct': [user_info],
'not_correct': [],
}
}
},
{"_id": 0},
return_document=ReturnDocument.AFTER,
session=session,
)
else:
if await AnswersDB.find_question_by_ans(conn, question, answer, session) is None:
return await conn[DATABASE_NAME][QUESTIONS_COLLECTION_NAME].find_one_and_update(
{'question': question},
{'$push': {'answers': {'answer': answer, 'users': [],
'correct': [], 'not_correct': [user_info]}}}, {"_id": 0},
return_document=ReturnDocument.AFTER, session=session
if await AnswersDB.find_question_by_ans(
conn, question, answer, session
)
else:
return await conn[DATABASE_NAME][QUESTIONS_COLLECTION_NAME].find_one_and_update(
is None
else await conn[DATABASE_NAME][
QUESTIONS_COLLECTION_NAME
].find_one_and_update(
{'question': question, 'answers.answer': answer},
{'$push': {'answers.$.not_correct': user_info}}, {"_id": 0},
return_document=ReturnDocument.AFTER, session=session
{'$push': {'answers.$.correct': user_info}},
{"_id": 0},
return_document=ReturnDocument.AFTER,
session=session,
)
)

if await AnswersDB.find_question_by_ans(conn, question, answer, session) is None:
return await conn[DATABASE_NAME][QUESTIONS_COLLECTION_NAME].find_one_and_update(
{'question': question},
{'$push': {'answers': {'answer': answer, 'users': [],
'correct': [], 'not_correct': [user_info]}}}, {"_id": 0},
return_document=ReturnDocument.AFTER, session=session
)
else:
return await conn[DATABASE_NAME][QUESTIONS_COLLECTION_NAME].find_one_and_update(
{'question': question, 'answers.answer': answer},
{'$push': {'answers.$.not_correct': user_info}}, {"_id": 0},
return_document=ReturnDocument.AFTER, session=session
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AnswersDB.add_user_approve refactored with the following changes:

Comment on lines -222 to +270
if user_info not in question_db['viewers']:
document = await conn[DATABASE_NAME][QUESTIONS_COLLECTION_NAME].find_one_and_update(
{'question': question}, {
'$push': {'viewers': user_info}},
{"_id": 0}, return_document=ReturnDocument.AFTER, session=session
)
return document
else:
if user_info in question_db['viewers']:
return question_db
document = await conn[DATABASE_NAME][QUESTIONS_COLLECTION_NAME].find_one_and_update(
{'question': question}, {
'$push': {'viewers': user_info}},
{"_id": 0}, return_document=ReturnDocument.AFTER, session=session
)
return document
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AnswersDB.add_new_viewer refactored with the following changes:

Comment on lines -245 to -252
if answer_['subquestion'] == answer[0] and answer_['answer'] == answer[1]:
if user_info in answer_['users']:
if (
answer_['subquestion'] == answer[0]
and answer_['answer'] == answer[1]
and user_info in answer_['users']
):
return True
elif answer_['answer'] == answer:
for user in answer_['users']:
if user == user_info:
return True
else:
if answer_['answer'] == answer:
for user in answer_['users']:
if user == user_info:
return True
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AnswersDB.is_user_send_answer refactored with the following changes:

Comment on lines -155 to +156
if isinstance(data['answer'], list):
if len(data['answer']) == 2:
data['answer'] = 0
if isinstance(data['answer'], list) and len(data['answer']) == 2:
data['answer'] = 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function add_approve refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants