Skip to content

mirage: Add default_version and yanked to crate serializer #9840

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

Merged
merged 2 commits into from
Nov 4, 2024

Conversation

eth3lbert
Copy link
Contributor

This PR adds default_version and yanked to the crate serializer.

Related:

@eth3lbert eth3lbert force-pushed the mirage-default-version branch 2 times, most recently from 0e04bd5 to c2b40fc Compare November 4, 2024 13:55
Comment on lines 22 to 23
'default_version',
'yanked',
Copy link
Member

Choose a reason for hiding this comment

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

are you sure that we need these mentioned here? I would've thought that those are only necessary for the fields that come directly from the corresponding factory/model

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw we have

just_updated: this.serialize(just_updated).crates.map(it => ({ ...it, versions: null })),
most_downloaded: this.serialize(most_downloaded).crates.map(it => ({ ...it, versions: null })),
new_crates: this.serialize(new_crates).crates.map(it => ({ ...it, versions: null })),
most_recently_downloaded: this.serialize(most_recently_downloaded).crates.map(it => ({
...it,
versions: null,
})),
num_crates,
num_downloads,
popular_categories: this.serialize(popular_categories).categories,
popular_keywords: this.serialize(popular_keywords).keywords,
which leverages serializer. So I just made the change in the serializer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But after your awareness, I think we might also want to change the factory and fixture as well?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand what you're saying 😅

my question is: do the tests work the same as before when these two lines are removed again? or is something breaking then?

Copy link
Contributor Author

@eth3lbert eth3lbert Nov 4, 2024

Choose a reason for hiding this comment

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

Oh, my bad, I thought it was necessary to add these, that was quite embarrassing! A quick inspection of the mirage response confirms your absolute right.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed the attrs part.


Should we add these fields to mirage/factory or mirage/fixtures?

Copy link
Member

@Turbo87 Turbo87 Nov 4, 2024

Choose a reason for hiding this comment

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

Should we add these fields to mirage/factory or mirage/fixtures?

no :)

factory is for regular fields, model is for relationships, fixtures can die for all I care, and the serializer can be (mis)used for "computed" fields 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TIL!!

@Turbo87 Turbo87 added A-frontend 🐹 C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear labels Nov 4, 2024
@eth3lbert eth3lbert force-pushed the mirage-default-version branch from c2b40fc to 80d8f97 Compare November 4, 2024 16:12
@Turbo87 Turbo87 merged commit df4621a into rust-lang:main Nov 4, 2024
9 checks passed
@eth3lbert eth3lbert deleted the mirage-default-version branch November 4, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend 🐹 C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants