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

System comments #2032

Merged
merged 1 commit into from
Dec 11, 2019
Merged

System comments #2032

merged 1 commit into from
Dec 11, 2019

Conversation

csordasmarton
Copy link
Contributor

Closes #746

Show system comments at bugs.

Screenshot:
image

@csordasmarton csordasmarton added enhancement 🌟 database 🗄️ Issues related to the database schema. GUI 🎨 labels Apr 3, 2019
@csordasmarton csordasmarton added this to the release 6.10.0 milestone Apr 3, 2019
@@ -85,6 +85,11 @@ enum ExtendedReportDataType {
FIXIT = 20,
}

enum CommentKind {
GENERAL, // User based comments.
Copy link
Contributor

Choose a reason for hiding this comment

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

User-given

@@ -0,0 +1,6 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we call this file differently? system_comment_kinds? system_comment_expansion? "Map" is too generic for a config file name.

@@ -564,4 +564,4 @@ def addFileRecord(session, filepath, content_hash):
.filter(File.content_hash == content_hash,
File.filepath == filepath).one_or_none()

return file_record.id if file_record else None
return file_record.id if file_record else None
Copy link
Contributor

Choose a reason for hiding this comment

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

unrelated diff in patch, also doesn't not having a line break at the end violate pycodestyle?

@whisperity
Copy link
Contributor

It'd be even fancier if the "blips" could also be turned into icons (like how bug path elements have an icon, or how the blips of moments on GitHub on this patch also have icons), but that's just continuing to polish it fancy...

I really like the whole "bus schedule" looks to it. 😍

@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@Ericsson Ericsson deleted a comment Apr 4, 2019
@gyorb gyorb removed this from the release 6.10.0 milestone Apr 13, 2019
Copy link
Contributor

@gyorb gyorb left a comment

Choose a reason for hiding this comment

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

Will this blow up our database size? How many entries are generated for a typical store?

Turning some checker profiles on and off could result in a lot of detection status changes.

@@ -85,6 +85,11 @@ enum ExtendedReportDataType {
FIXIT = 20,
}

enum CommentKind {
GENERAL, // User-given comments.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rename this to USER, GENERAL is a bit too general ;)

@@ -313,6 +314,20 @@ def extended_data_db_to_api(erd):
fileId=erd.file_id)


def comment_kind_str(status):
if status == ttypes.CommentKind.GENERAL:
return 'general'
Copy link
Contributor

Choose a reason for hiding this comment

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

The same here user

@@ -0,0 +1,6 @@
{
"rev_st_changed": "%author% changed review status from <b class=\"old-review-status\">{0}</b> to <b class=\"new-review-status\">{1}</b> %date%",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to store the whole text, couldn't we create some more dense representation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are not store the whole text in the database we just store the type of the system comment and the arguments: rev_st_changed Unreviewed Confirmed. We are using this file only to display the comment in the gui.

@Ericsson Ericsson deleted a comment Nov 28, 2019
@gyorb gyorb requested a review from dkrupp December 3, 2019 10:16
@csordasmarton csordasmarton force-pushed the system_comments branch 2 times, most recently from fdbc3fa to d172bbe Compare December 7, 2019 10:38


def upgrade():
op.add_column('comments', sa.Column('kind', sa.Enum(u'user',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will fail on postgresql. We can fix this by using the following instructions: https://stackoverflow.com/questions/37848815/sqlalchemy-postgresql-enum-does-not-create-type-on-db-migrate.

comment_kind_name = 'comment_kind'
enum_values = (u'user', u'system')

commnet_kind_column = sa.Column('kind', sa.Enum(*enum_values,
                                                name=comment_kind_name),
                                server_default=u'user',
                                nullable=False)
def upgrade():
    ctx = op.get_context()
    dialect = ctx.dialect.name

    if dialect == 'postgresql':
        from sqlalchemy.dialects import postgresql
        comment_kind = postgresql.ENUM(*enum_values, name=comment_kind_name)
        comment_kind.create(op.get_bind())

        op.add_column('comments', commnet_kind_column)
    elif dialect == 'sqlite':
        op.add_column('comments', commnet_kind_column)
def downgrade():
    op.drop_column('comments', 'kind')

    ctx = op.get_context()
    dialect = ctx.dialect.name

    if dialect == 'postgresql':
        from sqlalchemy.dialects import postgresql
        comment_kind = postgresql.ENUM(*enum_values, name=comment_kind_name)
        comment_kind.drop(op.get_bind())

But as we discussed it personally we will use integers instead of enums to avoid this kind of hacks.

@csordasmarton
Copy link
Contributor Author

@gyorb I have refactored the migration script to use Integer instead of Enum.

} catch (ex) { util.handleThriftException(ex); }

that._message.set('content',
newContent.replace(/(?:\r\n|\r|\n)/g, '<br>'));
that._message.innerHTML =
Copy link
Contributor

Choose a reason for hiding this comment

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

domElement.getElementsByClassName(className);

for (var i = 0; i < domStatuses.length; i++) {
var domStatus = domStatuses[i];
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -108,7 +107,7 @@ function (declare, dom, style, topic, Memory, Observable, ConfirmDialog,
content : 'Are you sure you want to delete this?',
onExecute : function () {
try {
CC_SERVICE.removeComment(that.cId);
CC_SERVICE.removeComment(that.commentData.id);
Copy link
Contributor

Choose a reason for hiding this comment

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

message : comment.message,
sender : sender
}));
if (comment.kind === CC_OBJECTS.CommentKind.SYSTEM) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -93,6 +93,11 @@ enum ExtendedReportDataType {
FIXIT = 20,
}

enum CommentKind {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking maybe it would be better if we introduce some prefix for the thrift types.
There are conversion functions which convert from CommentKind to CommentKind one of them is a thrift enum and the other is a local enum it is hard to follow which type is used where and what is converted to what.

@@ -469,6 +477,20 @@ def extended_data_db_to_api(erd):
fileId=erd.file_id)


def comment_kind_str(status):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any string involved in this conversion? Just another enum value is returned.
I'm thinking would it be better to tie this conversion functions closer to the CommentKind local enum type?
With some other name which makes the conversion more explicit to_thrift_type, from_thrift_type.

A function docstring would be nice for the conversion functions.

@@ -653,6 +675,17 @@ def sort_run_data_query(query, sort_mode):
return query


def escape_whitespaces(s, whitespaces=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add function docstring.


sys_comment = comment_kind_str(ttypes.CommentKind.SYSTEM)
if comment.kind == sys_comment:
elements = shlex.split(message)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need the shlex.split here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before we store a system comment in the database, we will escape the white spaces (escape_whitespaces). We are using shlex here to split this escaped string properly.

@@ -2441,6 +2520,7 @@ def checker_is_unavailable(checker_name):
detection_status = 'new'
detected_at = run_history_time

old_status = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to set the default value here? The variable is used only inside the if block below I did not found any other references.

@@ -360,12 +360,16 @@ class Comment(Base):
bug_hash = Column(String, nullable=False, index=True)
author = Column(String, nullable=False)
message = Column(Binary, nullable=False)
kind = Column(Integer,
nullable=False,
server_default="0")
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a comment about the default value here would be nice. '0' means a comment type by the user tight?

Copy link
Contributor

@gyorb gyorb left a comment

Choose a reason for hiding this comment

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

Please increase thrift api version

Show system comments at bugs.
@gyorb
Copy link
Contributor

gyorb commented Dec 10, 2019

Codacy Here is an overview of what got changed by this pull request:

Issues
======
+ Solved 6
- Added 6
           

Complexity increasing per file
==============================
- web/server/codechecker_server/migrations/report/versions/6cb6a3a41967_system_comments.py  1
- web/tests/functional/comment/test_comment.py  2
         

Clones added
============
- web/tests/functional/comment/test_comment.py  2
         

See the complete overview on Codacy

@whisperity
Copy link
Contributor

Oho, this is amazing, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database 🗄️ Issues related to the database schema. enhancement 🌟 GUI 🎨
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show system comments for bugs [30h]
3 participants