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

[needs-doc] Add stable id, save id, save count to project spec #6527

Closed
wants to merge 3 commits into from

Conversation

NathanW2
Copy link
Member

@NathanW2 NathanW2 commented Mar 5, 2018

Adds some new metadata about the project itself for future use.

<qgis version="2.99.0-Master" save-counter="7" projectname="" save-user-full="Nathan" id="3ed6e416-b659-455d-a870-99971197890" save-id="64e96782-d2aa-4350-b2f6-7e77f31eece" save-user="nathan">

Adds the following information:

  • id() -> Stable ID that never changes (can be used to track the project even if the file name changes)
  • saveId() -> Changes on each save to give you a ID number for that version
  • saveCounter() -> A int with a counter how many times this project has been saved. Same kind of deal as saveId() but we will have both anyway
  • saveUser() -> Last saved user
  • saveUserFull -> Last saved user full name.

NOTE: I was considering backporting this into 3.0 so that we can start getting projects including those ids for future release. If you save with a older version of QGIS it will nuke these values.

@NathanW2
Copy link
Member Author

NathanW2 commented Mar 5, 2018

Some background on why this might be a good idea. I would like to generate preview images for each project that is opened so I can use them in tooltips, however I have no stable ID I can use for filenames. This would provide that and would allow for moving the projects around but keeping the previews.

Another user for id() and saveId() is a possible future saving of projects in database or web server. Using these two ids we can track if a project has changed on the server by someone else etc. Would also allow backends to implement versioning around project save without making their own ids.

static QString generateUuid()
{
QString uuid = QUuid::createUuid().toString();
return uuid.mid( 1, uuid.length() - 3 );
Copy link
Collaborator

Choose a reason for hiding this comment

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

off topic - but wow it annoys me the format QUuid uses.

Copy link
Member Author

Choose a reason for hiding this comment

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

You and be both. Never once have I thought "man I wish this guid had { } around it". Silly.

QString mSaveId; // changing id for each save.
QString mSaveUser; // last saved user.
QString mSaveUserFull; // last saved user.
int mSaveCounter; // increasing save counter
Copy link
Collaborator

Choose a reason for hiding this comment

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

initialize to 0 here

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@NathanW2
Copy link
Member Author

NathanW2 commented Mar 5, 2018

@nirvn @m-kuhn @wonder-sk how do you feel about these?

@wonder-sk
Copy link
Member

I think it is a bit tricky with the IDs... if I have an existing project and use save-as to make a copy and modify that project afterwards, I would end up with both original and the new project sharing the same ID right?

And how would we use saveCounter()?

@nyalldawson
Copy link
Collaborator

I think it is a bit tricky with the IDs... if I have an existing project and use save-as to make a copy and modify that project afterwards, I would end up with both original and the new project sharing the same ID right?

Yes - that's the purpose of the persistent id -- it would allow tracking of project "forks" like this. The saveId() will be regenerated though and will be new.

@NathanW2
Copy link
Member Author

NathanW2 commented Mar 5, 2018 via email

@nyalldawson
Copy link
Collaborator

Hmm Martins point is valid if I wanted to use the id() to assign generate a
thumbnail using just that.

Wouldn't you use saveId() for that? Otherwise you'd see an outdated thumbnail.

so I still think it's valid to have these ids.

Very much so! I can see lots of potential use for them, and the sooner they start to be recorded in projects the better...

@NathanW2
Copy link
Member Author

NathanW2 commented Mar 6, 2018 via email

@nyalldawson
Copy link
Collaborator

Yeah i guess we can use save id and just delete the old one after each
save. That is a good point.

Doesn't that break to "save as" case though? E.g. open existing project, save as => original project thumbnail is deleted.

@NathanW2
Copy link
Member Author

NathanW2 commented Mar 6, 2018 via email

@m-kuhn
Copy link
Member

m-kuhn commented Mar 6, 2018

What about saving the thumbnail straight into the project file?

@nirvn
Copy link
Contributor

nirvn commented Mar 6, 2018

@m-kuhn , that's what I suggested (off github) yesterday. IMHO, that's what makes the most sense on the longer term.

@NathanW2
Copy link
Member Author

NathanW2 commented Mar 6, 2018 via email

@NathanW2
Copy link
Member Author

NathanW2 commented Mar 6, 2018 via email

@m-kuhn
Copy link
Member

m-kuhn commented Mar 6, 2018

I thought about that however the downside is that we need to load and parse the xml for each project in the browser tree which might be slow over networks.

Isn't that the same with the metadata in discussion here?

@NathanW2
Copy link
Member Author

NathanW2 commented Mar 6, 2018 via email

@m-kuhn
Copy link
Member

m-kuhn commented Mar 6, 2018

So maybe we will just store them in the project file as base64

can we go for qgd and ship it binary?

@NathanW2
Copy link
Member Author

NathanW2 commented Mar 6, 2018 via email

@NathanW2
Copy link
Member Author

So any thoughts on this logic? Even if we go with a qgz default format in future I still think having this logic in the project would be handy for tracking or other uses.

@nyalldawson
Copy link
Collaborator

So any thoughts on this logic? Even if we go with a qgz default format in future I still think having this logic in the project would be handy for tracking or other uses.

I'm +1. Obviously it has limitations, but I'd still find it super-useful.

The only improvement I can think of is adding (yet another) uuid - so we have:

  • original project id: created on new project, never changed, regardless of how the project is branched or modified.
  • unique project id: created on new project and reset when doing a "save as".
  • project version id: recreated on every save

@m-kuhn
Copy link
Member

m-kuhn commented Mar 12, 2018

So any thoughts on this logic?

I don't see any big downsides. One shouldn't blindly trust it, but if it's useful for something, go ahead. I can't see a better approach nor any risks.

@NathanW2
Copy link
Member Author

@wonder-sk your thoughts?

@wonder-sk
Copy link
Member

I think I am still confused about how all this would be used and what expectations developers can have from these new values:

  1. id() aka "stable id" aka "original project id" - if a user modifies prj1 and saves it as prj2, we still keep the ID untouched. I think this my main source of confusion: by having two different projects - prj1 and prj2 - how useful is the information for us that at some point the two projects were started from the same base project, but at this point they may be completely unrelated?

  2. id() [take two]: I am bit afraid of introducing a situation we had with layer IDs where in multi-project environment we could have different layers with the same IDs present - but this time with project IDs. There could easily be confusion that some plugins will think that id() returns a unique value for each loaded project, which is not true (and e.g. have a dictionary where project IDs would be used as keys).

  3. saveId(): agreed this may be useful. (Even though often project filename + last modified timestamp is good enough as a unique project identifier - but yes, saveId() would survive project file moves/copies while filename+timestamp would not.)

  4. saveCounter(): here I am confused again where could we use it - it seems to me it does not really add any new information compared to saveId() since two different projects with the same id() that diverged over time can have arbitrary relationship between counters. Having prj1 and prj2 with the same id() and with prj1 counter = 10 and prj2 counter = 11, we still cannot imply anything - prj1 and prj2 may have diverged at counter = 3, so prj1 cannot be considered as a previous version of prj2. If we ever need to somehow compare versions of projects, their timestamp seems like the best option.

  5. the "unique project id" as suggested by Nyall may not necessarily help the whole situation either - if a user copies a project in file browser, the unique project id would still stay the same although the two projects may diverge.

By the way... recently at Lutra we have been tasked to add support for loading/saving projects in PostgreSQL database. In a couple of days Peter or me should get back with a QEP discussing that.

@3nids 3nids added this to the 3.2 milestone Mar 14, 2018
@3nids 3nids removed the 3.2 label Mar 14, 2018
@m-kuhn m-kuhn modified the milestones: 3.2, 3.4 May 31, 2018
@nyalldawson nyalldawson removed the 3.4 label Jun 10, 2018
@qgis qgis deleted a comment from SamirSuhib Jun 22, 2018
@nyalldawson nyalldawson added the Requires Changes! Waiting on the submitter to make requested changes label Jun 22, 2018
@nyalldawson
Copy link
Collaborator

Ping @probot

@stale
Copy link

stale bot commented Jul 12, 2018

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@stale stale bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jul 12, 2018
@stale
Copy link

stale bot commented Jul 19, 2018

While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist.

@thbaumann
Copy link
Contributor

Hi @NathanW2: I picked up your idea of adding the username to the QGIS project file in my pullrequest 33843. Do you think it is pointed out enough that the code snippets were originally written by you or do you have any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Requires Changes! Waiting on the submitter to make requested changes stale Uh oh! Seems this work is abandoned, and the PR is about to close.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants