-
Notifications
You must be signed in to change notification settings - Fork 1.8k
do not revert on current revision #5564
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
Conversation
Generated by 🚫 Danger |
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.
Hi @CleverFool77, you handled the case nicely on frontend but still one can generate redundant revisions by making get request so let's handle this case in backend too. You will be doing changes for that in wiki_controller#revert. We can also add a test for it.
What do you think?
Thanks!
Hi @gauravano I went through this, In backend, we are just directly replacing the new revision with the all old duplicate revision. |
hey @CleverFool77, Here's how you can prevent the request in backend: First, let's see what we have in our tables:
The above is a snippet of rails console. The revisions table store revisions of each node. If we perform a query like node.revisions.last then it will give us the latest revision which is in effect at that time. So, we can compare the id which we receive in param with this last revision Id and if they're same we'll not revert. (The vid mentioned on each node doesn't point to the lastest revision. It points to the revision which was last created without revert action) |
Thank you so much for reference gaurav. I'll look into this and update the
PR.
Thanks
…On Sun, 8 Sep 2019, 03:24 Gaurav Sachdeva, ***@***.***> wrote:
hey @CleverFool77 <https://github.com/CleverFool77>,
Here's how you can prevent the request in backend:
First, let's see what we have in our tables:
[24] pry(main)> Node.last
Node Load (0.2ms) SELECT "node".* FROM "node" ORDER BY "node"."nid" DESC LIMIT ? [["LIMIT", 1]]
=> #<Node:0x00007f897835a0a8
nid: 44,
vid: 46,
type: "page",
language: "",
title: "test page",
uid: 1,
[25] pry(main)> Node.last.revisions
Node Load (0.2ms) SELECT "node".* FROM "node" ORDER BY "node"."nid" DESC LIMIT ? [["LIMIT", 1]]
Revision Load (0.2ms) SELECT "node_revisions".* FROM "node_revisions" WHERE "node_revisions"."nid" = ? ORDER BY "node_revisions"."timestamp" DESC [["nid", 44]]
=> [#<Revision:0x00007f8982cb1cf0 vid: 47, nid: 44, uid: 1, title: "test page", body: "something meaningfull!!!\r\n\r\none\r\n\r\ntwo", teaser: "", log: "", timestamp: 1567891987, format: 1, status: 1>,
#<Revision:0x00007f8982cb1ae8 vid: 46, nid: 44, uid: 1, title: "test page", body: "something meaningfull!!!\r\n\r\none\r\n\r\ntwo", teaser: "", log: "", timestamp: 1567891936, format: 1, status: 1>,
#<Revision:0x00007f8982cb18e0 vid: 45, nid: 44, uid: 1, title: "test page", body: "something meaningfull!!!\r\n\r\none", teaser: "", log: "", timestamp: 1567891904, format: 1, status: 1>,
#<Revision:0x00007f8982cb16b0 vid: 44, nid: 44, uid: 1, title: "test page", body: "something meaningfull!!!", teaser: "", log: "", timestamp: 1567891839, format: 1, status: 1>]
[26] pry(main)>
The above is a snippet of rails console. The revisions table store
revisions of each node. If we perform a query like node.revisions.last then
it will give us the latest revision which is in effect at that time. So, we
can compare the id which we receive in param with this last revision Id and
if they're same we'll not revert.
(The vid mentioned on each node doesn't point to the lastest revision. It
points to the revision which was last created without revert action)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5564?email_source=notifications&email_token=AGLS6SS5YMUYS2EQ7BRM7NTQIQPI7A5CNFSM4HHLOCPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6FC7GY#issuecomment-529149851>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGLS6SQB6DSKNHAZAKTTFPTQIQPI7ANCNFSM4HHLOCPA>
.
|
There are some conflicts. Kindly rebase |
As the person is inactive for more than a month, I am closing the PR. In case you want to push changes please feel free to open a new PR OR reopen this PR and add additional changes to it. |
Fixes #5551 (<=== Add issue number here)
Description
Earlier I tried removing the revert button for current revision but the ui became inconsistent because of this.
So Instead I made revert button disabled while showing the information on tooltip that already on current revision and can't revert anymore.
rake test
@publiclab/reviewers
for help, in a comment belowThanks!