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

Remove repetitive safe_query #7001

Closed
iamareebjamal opened this issue May 13, 2020 · 9 comments · Fixed by #7017
Closed

Remove repetitive safe_query #7001

iamareebjamal opened this issue May 13, 2020 · 9 comments · Fixed by #7017

Comments

@iamareebjamal
Copy link
Member

You'll find a lot of unnecessary and repetitive safe_query calls like safe_query(db, Session, 'id', view_kwargs['session_id'], 'session_id')

First of all, all of this should be abstracted, manually calling this is the ultimate source of bugs. However, that will take massive restructuring of the project and hence, for now, just refactor it to be simpler, like safe_query_kwargs(Session, view_kwargs, 'session_id'), that's all the info it needs to do its thing, no need for extra verbosity. If possible, change to safe_query_by_id(Session, view_kwargs['session_id'])

@iamareebjamal
Copy link
Member Author

See last commit of #6997 for more info

@satya7289
Copy link
Member

@iamareebjamal I want to work on this issue.

@prateekj117
Copy link
Member

@satya7289 Go ahead.

@satya7289 satya7289 mentioned this issue May 14, 2020
6 tasks
@satya7289
Copy link
Member

I think @iamareebjamal has already been resolved this issue.

@iamareebjamal
Copy link
Member Author

Not really?

@satya7289
Copy link
Member

I got it. I have to convert the all safe_query(Session, 'id', view_kwargs['session_id'], 'session_id')

  1. self_query_by_id(Session,view_kwargs['session_id']) if view_kwargs['session_id']=='session_id'. and second parameter is 'id'.

Am I right? . @iamareebjama

@iamareebjamal
Copy link
Member Author

No, you need to create a new method which takes the dictionary and key and does the same thing as safe query but without repetition

@satya7289
Copy link
Member

No, you need to create a new method which takes the dictionary and key and does the same thing as safe query but without repetition

I'm actually new in this, I do not understand 'safe query but without repetition' part, need some more clarification. @iamareebjamal

@iamareebjamal
Copy link
Member Author

You have to change safe_query(db, Session, 'id', view_kwargs['session_id'], 'session_id') into safe_query_kwargs(Session, view_kwargs, 'session_id') so there's no repetition

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