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

UX improvements to transaction commits and concept deletion #178

Merged
merged 5 commits into from
Nov 2, 2021

Conversation

alexjpwalker
Copy link
Member

@alexjpwalker alexjpwalker commented Nov 1, 2021

What is the goal of this PR?

We've added an indicator for uncommitted changes within a transaction. While you are in a transaction that has uncommitted changes, an asterisk (*) will now be displayed in the prompt.

Also, concept deletion is now more transparent; the number of concepts being deleted (or updated) is printed to the console now. This is particularly helpful for catching when there is a bug in the match query that might cause it to delete no concepts, or the wrong concepts.

What are the changes implemented in this PR?

  • Indicate uncommitted changes
  • Print the number of concepts that are being deleted (or updated)

We chose to not add a confirmation prompt prior to deletion just yet, this is due to Console architecture making that too difficult for now. This is (still!) tracked in:

@alexjpwalker alexjpwalker changed the title UX improvements to transactions and concept deletion UX improvements to transaction commits and concept deletion Nov 1, 2021
TypeDBConsole.java Show resolved Hide resolved
@@ -309,6 +313,7 @@ private boolean transactionREPL(TypeDBClient client, String database, TypeDBSess
break;
} else if (replCommand.isSource()) {
runSource(tx, replCommand.asSource().file(), replCommand.asSource().printAnswers());
hasUncommittedChanges = true;
Copy link
Member

Choose a reason for hiding this comment

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

eh? what if the file only has match queries, then there's not uncommitted right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I'd assumed it was hard to verify that condition, but on second inspection we can do it.

Comment on lines 676 to 677
answerCount.getAndIncrement();
printer.conceptMap(x, tx);
Copy link
Member

Choose a reason for hiding this comment

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

I think this is odd - we've introduce an strong inconsistency with our protocol, rather than a minor one, by printing out all the maps that are being deleted. The user doesn't really have any interested in the concepts from which is deleted, so we shouldn't print them (they may not exist in a bit anyway!). Using this to count is ok though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I suppose that's fine. Seems odd to do all the work just to throw it away in the end, but given that it's not in line with the eventual solution we're aiming for, we probably shouldn't introduce unrealistic user expectations by printing them now.

Comment on lines 687 to 695
Stream<ConceptMap> matchResult = tx.query().match(query.asUpdate().match());
AtomicInteger answerCount = new AtomicInteger();
printCancellableResult(matchResult, x -> {
answerCount.getAndIncrement();
printer.conceptMap(x, tx);
});
Stream<ConceptMap> result = tx.query().update(query.asUpdate());
printCancellableResult(result, x -> printer.conceptMap(x, tx));
if (answerCount.get() > 0) hasUncommittedChanges = true;
Copy link
Member

Choose a reason for hiding this comment

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

aren't we going to print everything twice now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes. image

});
if (answerCount.get() > 0) {
tx.query().delete(query.asDelete()).get();
printer.info("Concepts have been deleted");
Copy link
Member

Choose a reason for hiding this comment

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

I think you should just change this to Deleted from <count> matched answers

@@ -0,0 +1,23 @@
package com.vaticle.typedb.console;
Copy link
Member

Choose a reason for hiding this comment

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

forgot license

Copy link
Member

@flyingsilverfin flyingsilverfin left a comment

Choose a reason for hiding this comment

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

Good stuff!

@alexjpwalker alexjpwalker merged commit 5869661 into typedb:master Nov 2, 2021
@alexjpwalker alexjpwalker deleted the tx-ux branch November 2, 2021 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Console prompt should indicate uncommitted changes Print the concepts that are being deleted
2 participants