mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-25 23:45:52 +03:00
[PR #145] [MERGED] Refactor model #269
Labels
No labels
Stale
bug
discussion
enhancement
good first issue
good first issue
help wanted
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/rspotify#269
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ramsayleung/rspotify/pull/145
Author: @ramsayleung
Created: 10/28/2020
Status: ✅ Merged
Merged: 11/17/2020
Merged by: @marioortizmanero
Base:
master← Head:ramsay_refactor_model📝 Commits (10+)
1fa25d4Make copyright as a struct instead of HashMap<String,String>41f1ce0Merge branch 'master' into ramsay_refactor_model2ebe01bAdd missing fieldis_private_sessionforDevice.c9a2de5Fix broken model reference link.2f94301ChangePublicUser.imagesfromOption<Vec<Image>>toVec<Image>20e2e8fAdd three missing fields forSimplifiedTrack.ee5ea95Update CHANGELOG.87764faSet default value if PublicUser.images isn't present.92f8ed0Add missing fieldproductforPrivateUser.38cef90Merge branch 'master' into ramsay_refactor_model📊 Changes
26 files changed (+1282 additions, -322 deletions)
View changed files
📝
CHANGELOG.md(+86 -2)📝
src/client.rs(+8 -6)📝
src/model/album.rs(+22 -19)📝
src/model/artist.rs(+17 -10)📝
src/model/audio.rs(+40 -28)📝
src/model/category.rs(+8 -5)📝
src/model/context.rs(+39 -25)➖
src/model/cud_result.rs(+0 -7)📝
src/model/device.rs(+12 -6)📝
src/model/enums/country.rs(+252 -14)📝
src/model/enums/misc.rs(+27 -42)📝
src/model/enums/mod.rs(+2 -2)📝
src/model/enums/types.rs(+53 -44)📝
src/model/image.rs(+4 -2)📝
src/model/mod.rs(+26 -5)📝
src/model/offset.rs(+4 -2)📝
src/model/page.rs(+12 -9)📝
src/model/playing.rs(+4 -13)📝
src/model/playlist.rs(+28 -12)📝
src/model/recommend.rs(+10 -14)...and 6 more files
📄 Description
Refactor
rspotifymodel to fix issues refering in #127Most of newly added code are test cases.
copyrightfromHashMap<String, String>tostruct CopyrightPartialEq(andEqif possible) for everything.Deviceis missing the fieldis_private_session: boolSimplfiiedTrackis missing theis_playable,linked_fromandrestrictionsfields.PublicUser::imagesshould be aVec<Image>and representNoneas an emptyVec.PrivateUseris missing theproductfield, which should be anenum Subscription { Premium, Free }.IncludeExternalcan just be replaced with aboolin the search function.Restrictionsis located in thealbummodule, despite it not having any particular relevance toalbums.Single-item modules likeimageshould have their items placed in the above scope.Device::idandDevice::volume_percentcan be null in the Spotify API, so they should be an Option.Playingshould be replaced withCurrentlyPlayingContext, since it is the same.PlaylistTrack::added_atcan be null so should be Option.PlaylistTrackis poorly named in the Spotify API. It should be calledPlaylistItemsince it can also contain episodes.languageshouldn't be inSimplifiedEpisodeif it's deprecated.AudioAnalysisSectionandAudioAnalysisSegmentcould contain a#[serde::flatten]edTimeIntervalinstead of the having the fields inline.AudioAnalysisMeasureis identical toTimeInterval, and so should be replaced by it.FullPlayingContextdoesn't exist in the Spotify API. It should be replaced withCurrentlyPlaybackContext.SimplifiedPlayingContextalso doesn't exist, and should be replaced withCurrentlyPlayingContext.CUDResultis oddly named; it should refer to playlists in its title.PlaylistResultmight be a better name. But it's not even necessary at all, the functions can just return String directly.{FullArtist, FullPlaylist}::followersis aHashMap<String, Option<Value>>. It should be a structFollowers { total: usize }.Actions::disallowscan be replaced with aVec<DisallowKey>orHashSet<DisallowKey>by removing all entires whose value is false, which will result in a simpler API.FullAlbum::release_dateandFullAlbum::release_date_precisionare Strings. Instead,it should be deserialized into a proper date type likeand aNaiveDateenum DatePrecision { Year, Month, Day }. PS:release_datecan't deserialized into a date type likeNaiveDate, since it might only hasyeare.g.2020, which can't convert to a date.Stringprobably is a right choice.SimplifiedEpisodeandFullEpisode.FullAlbums,PageSimplifiedAlbums, etc exist as wrappers. This makes the API more complex. Instead, have that type exist solely in the API function that needs it, and then return aVec<FullAlbum>. This drastically reduces the number of public API types.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.