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

[TO CLOSE] Add pagination parameter for GET sentences #61

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jean553
Copy link
Collaborator

@jean553 jean553 commented Feb 1, 2018

I still have to implement interface tests.

@jean553 jean553 changed the title WIP - add pagination parameter for GET sentences Add pagination parameter for GET sentences Feb 1, 2018
@jean553
Copy link
Collaborator Author

jean553 commented Feb 1, 2018

This PR is now available for review.

Copy link
Owner

@allan-simon allan-simon left a comment

Choose a reason for hiding this comment

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

see comments

#[derive(FromForm)]
struct LastId {
pub id: UUID,
}
Copy link
Owner

Choose a reason for hiding this comment

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

we need this because we can't implement a trait (FromForm) on a type ( UUID) that don't belong to us ?

Copy link
Owner

Choose a reason for hiding this comment

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

if so, it should be an issue raised to the rocket_contrib/uuid crate , as this crate is specifically made to ease interaction with uuid in rocket, so it should do that for us.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm gonna do a second check on this point.

ORDER BY
added_at,
sentence.id
LIMIT 100
LIMIT 10
Copy link
Owner

Choose a reason for hiding this comment

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

why changing the limit ?

@@ -128,19 +139,19 @@ fn get_all_sentences<'r>(
structure::text
FROM sentence
JOIN language ON (sentence.language_id = language.id)
WHERE sentence.id > $1
Copy link
Owner

Choose a reason for hiding this comment

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

your ids are not sequential , so if a new id get inserted you will certainly miss it.

let mut response = reqwest::get(&url).unwrap();
let url = Url::parse_with_params(
&url,
&[("id", "00000000-0000-0000-0000-000000000000")],
Copy link
Owner

Choose a reason for hiding this comment

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

it's not a valid uuid per-rfc so it should not work actually...


/* insert multiple sentences with different
content and "consecutives" uuids,
from a full-zeros uuid to x-x-x-x-...13 */
Copy link
Owner

Choose a reason for hiding this comment

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

something is wrong if you need to make consecutive uuid (see my comment above)


/* insert multiple sentences with different
content and "consecutives" uuids,
from a full-zeros uuid to x-x-x-x-...13 */
Copy link
Owner

Choose a reason for hiding this comment

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

something is wrong if you need to make consecutive uuid (see my comment above) , i.e you're tricking the reality to please your test though you should do the oppositve (i.e in reality multiple sentences add in order A B C don't have any garantee to have uuid in order A B C )

const SENTENCE_MAX_INDEX: usize = 15;
for id in 1..SENTENCE_MAX_INDEX {

/* ensure the uuids strings are all valid uuids */
Copy link
Owner

Choose a reason for hiding this comment

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

why is the code below ensuring that ?

assert_eq!(
sentences.len(),
3,
);
Copy link
Owner

Choose a reason for hiding this comment

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

80 lines for a test, with a lot of mundane (i.e low non-functional details ) happening , makes the test very obscure to understand.

Copy link
Owner

Choose a reason for hiding this comment

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

don't hesitate to create helper functions to outsource low details outside of the "reading" path.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, will be done in a separated dedicated PR #62.

@jean553 jean553 changed the title Add pagination parameter for GET sentences [TO CLOSE] Add pagination parameter for GET sentences Feb 19, 2018
@jean553
Copy link
Collaborator Author

jean553 commented Feb 19, 2018

This PR will be replaced by consecutive small PRs.

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.

None yet

2 participants