-
Notifications
You must be signed in to change notification settings - Fork 379
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
System comments #2032
Conversation
web/api/v6/report_server.thrift
Outdated
@@ -85,6 +85,11 @@ enum ExtendedReportDataType { | |||
FIXIT = 20, | |||
} | |||
|
|||
enum CommentKind { | |||
GENERAL, // User based comments. |
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.
User-given
web/config/system_comment_map.json
Outdated
@@ -0,0 +1,6 @@ | |||
{ |
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.
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 |
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.
unrelated diff in patch, also doesn't not having a line break at the end violate pycodestyle?
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. 😍 |
bc16dd6
to
57f5c80
Compare
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.
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.
web/api/v6/report_server.thrift
Outdated
@@ -85,6 +85,11 @@ enum ExtendedReportDataType { | |||
FIXIT = 20, | |||
} | |||
|
|||
enum CommentKind { | |||
GENERAL, // User-given comments. |
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 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' |
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.
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%", |
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.
Do we need to store the whole text, couldn't we create some more dense representation?
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 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.
57f5c80
to
e604684
Compare
e604684
to
07f69c0
Compare
fdbc3fa
to
d172bbe
Compare
|
||
|
||
def upgrade(): | ||
op.add_column('comments', sa.Column('kind', sa.Enum(u'user', |
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.
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.
d172bbe
to
91be1a5
Compare
@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 = |
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.
domElement.getElementsByClassName(className); | ||
|
||
for (var i = 0; i < domStatuses.length; i++) { | ||
var domStatus = domStatuses[i]; |
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.
@@ -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); |
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.
Issue found: 'CC_SERVICE' is not defined. (no-undef)
message : comment.message, | ||
sender : sender | ||
})); | ||
if (comment.kind === CC_OBJECTS.CommentKind.SYSTEM) { |
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.
Issue found: 'CC_OBJECTS' is not defined. (no-undef)
@@ -93,6 +93,11 @@ enum ExtendedReportDataType { | |||
FIXIT = 20, | |||
} | |||
|
|||
enum CommentKind { |
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'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): |
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.
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): |
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.
Please add function docstring.
|
||
sys_comment = comment_kind_str(ttypes.CommentKind.SYSTEM) | ||
if comment.kind == sys_comment: | ||
elements = shlex.split(message) |
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.
why do we need the shlex.split here?
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.
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 |
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.
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") |
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.
Maybe a comment about the default value here would be nice. '0' means a comment type by the user tight?
91be1a5
to
7bf2713
Compare
7bf2713
to
67dcdd0
Compare
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.
Please increase thrift api version
Show system comments at bugs.
67dcdd0
to
d7b2a56
Compare
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 |
Oho, this is amazing, thank you! |
Show system comments at bugs.
Screenshot: