-
Notifications
You must be signed in to change notification settings - Fork 75
Use project IDs internaly to manage projects #3884
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
base: master
Are you sure you want to change the base?
Conversation
8bf8a20 to
2d54ae3
Compare
Pull Request Test Coverage Report for Build 15041670829Details
💛 - Coveralls |
2d54ae3 to
61b99d1
Compare
tomasMizera
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Managed to go through the app folder so far, will continue later!
| // In theory we could send that request only for this one project. | ||
| listProjectsByName(); | ||
| // To ensure project will be in sync with server, send fetchProjectsByProjectId request. | ||
| fetchProjectsByProjectId( { projectId } ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you fetch state only of this one project, won't other local projects states get unknown (not calculated)? When requesting this API (in fetchProjectsByProjectId) we clear the projects model and so the resulting state of the other projects is now likely unknown (I did not test this, just assumption from the code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds plausible from the look of it. Will test it later again when the review is finished.
|
|
||
| //! Stops running project upload or update | ||
| Q_INVOKABLE void stopProjectSync( const QString &projectId ); | ||
| Q_INVOKABLE void stopProjectSync( const QString &projectId ) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should not be const, it alters things (maybe not directly, but it does)!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with that it changes some things. We should probably have some discussion about using const and in what cases is it intended to use.
|
|
||
| //! Forwards call to LocalProjectsManager to remove local project | ||
| Q_INVOKABLE void removeLocalProject( const QString &projectId ); | ||
| Q_INVOKABLE void removeLocalProject( const QString &projectId ) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, I believe this one should not be const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing as mentioned above.
Also refactor some clang-tidy warnings in MerginApi
61b99d1 to
9ab3d46
Compare
| projectNamesToRequest.erase( projectNamesToRequest.begin() + listProjectsByNameApiLimit, projectNamesToRequest.end() ); | ||
| Q_ASSERT( projectNamesToRequest.count() == listProjectsByNameApiLimit ); | ||
| projectNamesToRequest.erase( projectNamesToRequest.begin() + maxProjectRequests, projectNamesToRequest.end() ); | ||
| Q_ASSERT( projectNamesToRequest.count() == maxProjectRequests ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess
| Q_ASSERT( projectNamesToRequest.count() == maxProjectRequests ); | |
| Q_ASSERT( projectNamesToRequest.count() <= maxProjectRequests ); |
| Q_ASSERT( r == transaction.replyPullProjectInfo ); | ||
|
|
||
| if ( r->error() == QNetworkReply::NoError ) | ||
| { | ||
| QByteArray data = r->readAll(); | ||
| const QByteArray data = r->readAll(); | ||
| CoreUtils::log( "pull " + projectFullName, QStringLiteral( "Downloaded project info." ) ); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to compare if the server project ID is the same as the local project ID - in case remote project was renamed and some other project now bears the same name. We would try to sync a completely different project
| @@ -2817,7 +2949,7 @@ void MerginApi::pushInfoReplyFinished() | |||
| transaction.replyPushProjectInfo->deleteLater(); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to compare if the server project ID is the same as the local project ID - in case remote project was renamed and some other project now bears the same name. We would try to sync a completely different project
| * \return true when sync has started, false otherwise (e.g. due to a missing authorization or invalid server) | ||
| */ | ||
| Q_INVOKABLE bool pushProject( const QString &projectNamespace, const QString &projectName, bool isInitialPush = false ); | ||
| bool pushProject( const QString &projectFullName, const QString &projectId, bool isInitialPush = false ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and other API definitions should not need to accept both projectName and projectId. The ID should be enough - we can lookup the name via mLocalProjectsManager


Fixes #1969
This PR adds foundational work for supporting project IDs in mobile app. Besides issue mentioned above this is preliminary work for #1008, #1102, #576, project renaming etc.
Outline of the changes done:
getFullProjectName(),extractProjectName()has been moved fromMerginApiLocalProjectsupports UUID type of IDs + newgenerateProjectId()MerginProjectsupports UUID type of IDs + newfullname()LocalProjectsListchanged to HashMapLocalProjectsDictwith ID as keyprojectFromMerginName(), it was used only by testsupdateProjectId()necessary function for creating new projects on server ( server returns new ID for already existing projects, app needs to adapt to it)listProjectsByName()stays until there isv2endpoint for IDsmigrateProjectToMergin()just a wrapper forcreateProject()( i think it was used just by tests)projectDiffableFiles()not used anywheregetFullProjectName()&extractProjectName()to utilsdeleteProject()to use immediate deletion instead of scheduled, we use it only internally for project managementtopicparameter fromnetworkErrorOccured()it was only used by tests (they use http error codes now)projectIdChanged()signal to trigger update of local project ID to server generated IDgetProjectDetails()it's leaner version ofgetProjectInfo(), the response won't contain versioning historyTransactionsnow keep projectId as keyprojectId()to get project ID of active projectlistProjectsByName()byfetchProjectsById()porjectNames(), it was used internally and is not necessary since we moved to IDsQVariant::typetoQMetaTypefindProjectByName()with template function