Skip to content

[WIP][WOC] feedback implementation (continuation of #1464) #3424

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

Closed
wants to merge 18 commits into from
Closed

[WIP][WOC] feedback implementation (continuation of #1464) #3424

wants to merge 18 commits into from

Conversation

kuhnchris
Copy link
Contributor

Description

User-Feedback implementation

Checklist
Affected core subsystem(s)

ui, db, backend, frontend, tips, bounty

Refers/Fixes

Refs: #1464

Testing and Sign-off

/

Contributor
  • Read and followed the Contributor Guidelines
  • Tested all changes locally
  • Verified existing functionality
  • Ran make test and everything passed!
Reviewer
  • Affirm contributor guidelines have been followed and requested changes made
  • CI tests and linting pass
  • No conflicts (migrations, files, etc)
  • Regression tested against staging
Funder
  • Validated requested changes were made to specification
  • Bounty payout released to the contributor

@@ -45,7 +59,7 @@ window.onload = function() {
var notificationEmail = data.notificationEmail;
var githubPRLink = data.githubPRLink;
var hoursWorked = data.hoursWorked;

debugger;

Choose a reason for hiding this comment

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

Expected indentation of 8 spaces but found 2 tabs. (indent)
Unexpected 'debugger' statement. (no-debugger)

}
},
review: {
rating: data.rating?data.rating:-1,

Choose a reason for hiding this comment

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

Infix operators must be spaced. (space-infix-ops)

},
review: {
rating: data.rating?data.rating:-1,
comment: data.review?data.review:"No comment given.",

Choose a reason for hiding this comment

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

Infix operators must be spaced. (space-infix-ops)
Strings must use singlequote. (quotes)

review: {
rating: data.rating?data.rating:-1,
comment: data.review?data.review:"No comment given.",
reviewType: "worker"

Choose a reason for hiding this comment

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

Strings must use singlequote. (quotes)

user_profile = sync_profile(fulfillment.fulfiller_github_username)

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

@@ -999,6 +999,21 @@ def submitted(self):
"""Exclude results that have not been submitted."""
return self.exclude(fulfiller_address='0x0000000000000000000000000000000000000000')

class BountyComment(SuperModel):

Choose a reason for hiding this comment

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

E302 expected 2 blank lines, found 1

@@ -999,6 +999,21 @@ def submitted(self):
"""Exclude results that have not been submitted."""
return self.exclude(fulfiller_address='0x0000000000000000000000000000000000000000')

class BountyComment(SuperModel):
fulfillment = models.ForeignKey(BountyFulfillment, related_name='comments', on_delete=models.CASCADE)

Choose a reason for hiding this comment

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

F821 undefined name 'BountyFulfillment'

rating = models.IntegerField(null=True, blank=True)
commentsender = models.ForeignKey('dashboard.Profile', related_name='comments_given', on_delete=models.CASCADE)
commentreceiver = models.ForeignKey('dashboard.Profile', related_name='comments_received', on_delete=models.CASCADE)

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

Copy link
Member

@thelostone-mc thelostone-mc left a comment

Choose a reason for hiding this comment

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

Let a few minor comments. Could you fix up the sticker comments and also throw in a working demo ?

.rating {
width:160px;
}
.rating span { float:right; position:relative; }
Copy link
Member

Choose a reason for hiding this comment

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

Empty line between css rules :P

$('.rating input').click(function() {
$('.rating span').removeClass('checked');
$(this).parent().addClass('checked');
});
Copy link
Member

Choose a reason for hiding this comment

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

Arrow functions :P

$('input:radio').change(
function() {
var userRating = this.value;
});
Copy link
Member

Choose a reason for hiding this comment

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

Is this variable used anywhere?

@kuhnchris
Copy link
Contributor Author

wait, wait, this is FAR from being finished. This is a WIP and WOC ;-)
I'll ping you if I need a review on this, OK @thelostone-mc ? :-)

@owocki
Copy link
Contributor

owocki commented Jan 7, 2019

excited for this :)

@kuhnchris
Copy link
Contributor Author

Same, but ETHDenver has prio 1 ;-)

@@ -68,6 +69,9 @@ class UserActionAdmin(admin.ModelAdmin):
search_fields = ['action', 'ip_address', 'metadata', 'profile__handle']
ordering = ['-id']

class FeedbackAdmin(admin.ModelAdmin):

Choose a reason for hiding this comment

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

E302 expected 2 blank lines, found 1

@@ -68,6 +69,9 @@ class UserActionAdmin(admin.ModelAdmin):
search_fields = ['action', 'ip_address', 'metadata', 'profile__handle']
ordering = ['-id']

class FeedbackAdmin(admin.ModelAdmin):
search_fields = ['sender_profile','receiver_profile','bounty','feedbackType']

Choose a reason for hiding this comment

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

E231 missing whitespace after ','

return (did_change, latest_old_bounty, new_bounty)
return (did_change, latest_old_bounty, latest_old_bounty)
except SemaphoreExists:
return (did_change, latest_old_bounty, latest_old_bounty)

def create_new_feedback(new_bounty, feedback_dict):

Choose a reason for hiding this comment

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

E302 expected 2 blank lines, found 1

return (did_change, latest_old_bounty, new_bounty)
return (did_change, latest_old_bounty, latest_old_bounty)
except SemaphoreExists:
return (did_change, latest_old_bounty, latest_old_bounty)

def create_new_feedback(new_bounty, feedback_dict):
feedbackType = feedback_dict.get('feedbackType','???')

Choose a reason for hiding this comment

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

E231 missing whitespace after ','

@@ -2778,3 +2777,33 @@ class BlockedUser(SuperModel):
def __str__(self):
"""Return the string representation of a Bounty."""
return f'<BlockedUser: {self.handle}>'

class FeedbackEntry(SuperModel):

Choose a reason for hiding this comment

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

E302 expected 2 blank lines, found 1

@@ -361,6 +361,7 @@ def get_bounty(bounty_enum, network):
'token': token,
'fulfillments': fulfillments,
'network': network,
'review': bounty_data.get('review',{}),

Choose a reason for hiding this comment

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

E231 missing whitespace after ','

@SaptakS
Copy link
Contributor

SaptakS commented Jan 15, 2019

@kuhnchris can you please fix the linting issue so that travis passes?

@kuhnchris
Copy link
Contributor Author

as repeatedly mentioned: this is not finished.
Yes, I will fix linting, but please let me finish the task first and then do the linting, else we'd do that douzens of times.

return (did_change, latest_old_bounty, new_bounty)
return (did_change, latest_old_bounty, latest_old_bounty)
except SemaphoreExists:
return (did_change, latest_old_bounty, latest_old_bounty)

def create_new_feedback(new_bounty, feedback_dict):
Copy link
Contributor

Choose a reason for hiding this comment

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

ever considered putting this logic into model ? models looks anemic and you create 'create' method in helpers while it can belong to Feedback itself

@classmethod
worker_feedback(cls,bounty,...)
  return cls()

@classmethod
other_worker_feedback(cls,bounty,...) 
  return cls()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, considered that already. The main thing was to get it working, since we are having a IPFS bridge here and it wasn't working very well. especially because we do not simply provide the IPFS later on to the create functions, but actually parse them and return a DIFFERENT json structure than the one we pass into IPFS. Hence those methods are still from the "trying to get this to work" era.

@codecov
Copy link

codecov bot commented Jan 20, 2019

Codecov Report

Merging #3424 into master will decrease coverage by 0.02%.
The diff coverage is 35%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3424      +/-   ##
==========================================
- Coverage   29.73%   29.71%   -0.03%     
==========================================
  Files         185      185              
  Lines       14574    14610      +36     
  Branches     1929     1931       +2     
==========================================
+ Hits         4334     4341       +7     
- Misses      10101    10130      +29     
  Partials      139      139
Impacted Files Coverage Δ
app/dashboard/utils.py 35.46% <ø> (ø) ⬆️
...ard/management/commands/create_activity_records.py 0% <0%> (ø) ⬆️
app/dashboard/admin.py 71.05% <100%> (+1.05%) ⬆️
app/dashboard/helpers.py 16% <8.69%> (-0.62%) ⬇️
app/dashboard/models.py 53.09% <88.88%> (+0.22%) ⬆️
app/dashboard/embed.py 28.16% <0%> (-3.45%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2796f57...370237c. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 20, 2019

Codecov Report

Merging #3424 into master will decrease coverage by 0.06%.
The diff coverage is 42.85%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3424      +/-   ##
=========================================
- Coverage   29.76%   29.7%   -0.07%     
=========================================
  Files         193     201       +8     
  Lines       15045   15658     +613     
  Branches     1971    2056      +85     
=========================================
+ Hits         4478    4651     +173     
- Misses      10415   10850     +435     
- Partials      152     157       +5
Impacted Files Coverage Δ
app/app/context.py 57.5% <ø> (ø) ⬆️
app/app/urls.py 90% <100%> (+0.2%) ⬆️
app/app/settings.py 78.43% <33.33%> (+0.35%) ⬆️
app/economy/models.py 57.14% <0%> (-20.64%) ⬇️
app/grants/admin.py 41.97% <0%> (-5.49%) ⬇️
app/dashboard/helpers.py 15.77% <0%> (-0.75%) ⬇️
app/marketing/views.py 12.26% <0%> (-0.72%) ⬇️
app/grants/views.py 12.7% <0%> (-0.68%) ⬇️
app/retail/utils.py 11.43% <0%> (-0.54%) ⬇️
app/kudos/views.py 22.04% <0%> (-0.35%) ⬇️
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 978e30b...fe013c9. Read the comment docs.

@PixelantDesign
Copy link
Contributor

Hi @kuhnchris any updates here? :)

@kuhnchris
Copy link
Contributor Author

Yeah, as we discussed - making a video/recording to show you and finishing it up ;-)

Copy link
Contributor

@danlipert danlipert left a comment

Choose a reason for hiding this comment

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

This is looking good @kuhnchris ! I've got a couple suggestions, as well as some questions (and @thelostone-mc has some unanswered questions too). Lets get those addressed, as well as removing the leftover logging statements and style issues. Would also love to see some tests if you've got time! Thanks!

@@ -109,6 +109,7 @@
# dashboard views
re_path(r'^onboard/(?P<flow>\w+)/$', dashboard.views.onboard, name='onboard'),
re_path(r'^onboard/contributor/avatar/?$', dashboard.views.onboard_avatar, name='onboard_avatar'),
url(r'^postComment/', dashboard.views.postComment, name='postComment'),
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about changing the naming here to just comment since the post is implied as we're creating a comment resource?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, can do.

@@ -333,7 +333,9 @@ def handle_bounty_fulfillments(fulfillments, new_bounty, old_bounty):
except Exception as e:
logger.error(f'{e} during new fulfillment creation for {new_bounty}')
continue
return new_bounty.fulfillments.all()

if new_bounty:
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the goal of this check on new_bounty?

@@ -624,18 +649,25 @@ def record_bounty_activity(event_name, old_bounty, new_bounty, _fulfillment=None
'increased_bounty',
'worker_rejected',
'bounty_changed']
logger.info(f"record_bounty_activity > profile at start: {user_profile}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets remove these extra logging statements before we merge this PR 👍

@@ -728,6 +760,8 @@ def process_bounty_changes(old_bounty, new_bounty):
# record a useraction for this
record_user_action(event_name, old_bounty, new_bounty)
record_bounty_activity(event_name, old_bounty, new_bounty)
# check for review{} in here, create review object, wheeee.
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this comment referring to?

)
rating = models.SmallIntegerField(blank=True, default=0)
comment = models.TextField(default='', blank=True)
feedbackType = models.TextField(default='', blank=True, max_length=20)
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like there are only two types of feedback: approver and worker. If thats the case, what do you think about using the choices argument here to add a bit of validation and make the admin interface that much nicer? :)

@@ -300,6 +301,42 @@ def new_interest(request, bounty_id):
})


@require_POST
def postComment(request):
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets use lowercase with underscores style here to match with PEP 8: https://www.python.org/dev/peps/pep-0008/#naming-conventions. Also, since this function handles a POST request as evidenced by the decorator, maybe we should just call it comment or maybe new_comment. What do you think?

'sender_profile': profile_id,
'receiver_profile': bountyObj.fulfillments.last().profile,
'rating': feedback_dict.get('rating', '-1'),
'comment': feedback_dict.get('comment', 'No comment.'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I worry about potential script injection issues here due to the untrusted data: OWASP Wiki.

However, maybe santizing that is beyond the scope of V1 of this feature. Lets add a note to make sure we don't forget that this data is untrusted and unsanitized 👍

@owocki
Copy link
Contributor

owocki commented Feb 8, 2019

hey @kuhnchris how goes? ETHDenver is next week.. so hoping to get this in this upcoming monday's deploy. need anything from us? did u see @danlipert 's code comments?

@thelostone-mc
Copy link
Member

Closing as we've got the latest at #3709

thelostone-mc added a commit that referenced this pull request Mar 7, 2019
feedback implementation (continuation of #3424)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants