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

Make api resources more beautiful #559

Merged
merged 23 commits into from
Mar 24, 2021

Conversation

tomaspavlin
Copy link
Contributor

Closes #500

@@ -318,7 +318,7 @@
}
],
'acceptable_blood_groups': [
'A', 0
'A', '0'
Copy link
Member

Choose a reason for hiding this comment

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

Tohle tam bylo schválně abychom si uměli poradit i s číslem když by to tak někdo náhodou poslal.

@tomaspavlin tomaspavlin marked this pull request as ready for review March 21, 2021 19:10
Copy link
Member

@kubantjan kubantjan left a comment

Choose a reason for hiding this comment

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

Musim rict ze jsem trosku zmatenej z toho i z toho odkazu na PR #562 pisu nejaky otazky, pripadne si zavolejme.

@@ -53,7 +53,7 @@
RECIPIENTS = [
{
'acceptable_blood_groups': [
'A', 0
'A', '0'
Copy link
Member

Choose a reason for hiding this comment

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

nechas tam teda aspon nekdy tu 0?

Copy link
Member

Choose a reason for hiding this comment

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

nebo to ted hezky nejde? Jako ve swaggeru to nevyzadujeme, je dulezity abychom zvladli jak 0 tak O ale nemusime asi zvladat int, to je mozna zbytecne obecny.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Níže v tomhle file tu 0 na několika místech nechávám

@@ -51,7 +51,8 @@

RecipientJson = patient_api.model('Recipient', {
'db_id': fields.Integer(required=True, description='Database id of the patient'),
'acceptable_blood_groups': fields.List(required=False, cls_or_instance=fields.Nested(BloodGroupEnumJson)),
'acceptable_blood_groups': fields.List(required=False, cls_or_instance=fields.Nested(BloodGroupEnumJson),
example=['A', '0']),
Copy link
Member

Choose a reason for hiding this comment

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

ten example asi je hezci delat pres blood group enum ne?

@@ -69,4 +59,5 @@ def post(self, txm_event_id: int) -> str:
:configuration.max_matchings_to_show_to_viewer]
calculated_matchings_dto.show_not_all_matchings_found = False
logging.debug('Collected matchings and sending them')
return jsonify(calculated_matchings_dto)
dataclasses.asdict(calculated_matchings_dto)
return response_ok(calculated_matchings_dto)
Copy link
Member

Choose a reason for hiding this comment

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

to dataclasses tam davat nemusis ne? V response ok volas jsonify?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dataclasses jsem tam zapomněl z testování. Ano, v response ok je jsonify a může se to v budoucnu nahradit tím marshalling.

def response_ok(data, code=200):
    return make_response(jsonify(data), code)

@@ -30,7 +30,7 @@
}
},
"200": {
"description": "Success.",
"description": "Success",
Copy link
Member

Choose a reason for hiding this comment

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

proc tady mazes tu .?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Protože jsem odstranil description='Success.' a 'Success' je zřejmě nějaká default hodnota flasku. Mít description Success u response_ok mi připadá zbytečné.


def response_error_matching_not_found(self):
model = self._create_fail_response_model()
return self.response(code=404, model=model, description='Matching for provided id was not found.')
Copy link
Member

Choose a reason for hiding this comment

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

nemame ted nastaveny ten kod na nekolika mistech? Vzdy tohle jsme nejak meli reseny v tom hladnlovani erroriu?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tohle je to, co jsme měli napsané u každé routy a je to jen kvůli dokumentaci swaggeru.

Copy link
Member

Choose a reason for hiding this comment

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

me tenhle kod mate cely ten soubor namespaces, kdyz mame jeste error_handler.py kterej taky nejak probublava do swaggeru, mam pocit ze je tady divna duplicita. Muzem si zavolat dyztak.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Jak jsme se domluvili na callu, vytvořil jsem na tohle issue #590

@kubantjan
Copy link
Member

Chapu PR #562 spravne tak, ze jsi tady vypnul nejaky testy a zas se maji zapnout v tamtom PR?

…ces_more_beautiful

# Conflicts:
#	txmatching/web/swagger/swagger.json
Copy link
Member

@kubantjan kubantjan left a comment

Choose a reason for hiding this comment

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

ASi ok takto

@tomaspavlin tomaspavlin merged commit f47bd1b into master Mar 24, 2021
@tomaspavlin tomaspavlin deleted the 500_make_api_resources_more_beautiful branch March 24, 2021 15:21
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.

Make api resources more beautiful
2 participants