Skip to content

Commit

Permalink
Merge branch 'fix-946-296' of github.com:CuriousLearner/web into fix-…
Browse files Browse the repository at this point in the history
…946-296

* 'fix-946-296' of github.com:CuriousLearner/web:
  Slack Welcomebot on AWS Lambda (gitcoinco#1017)
  default to 'any' being checked
  Add user tracking to rollbar js config
  fixes gitcoinco#1040 (gitcoinco#1043)
  2 days at a time
  max time
  gives staff the ability to remove users from a bounty (gitcoinco#1042)
  one more try
  slower
  new d3 viz
  show nodes over time on graph
  • Loading branch information
CuriousLearner committed May 1, 2018
2 parents b6b5b0e + a9178d3 commit eeba1d8
Show file tree
Hide file tree
Showing 16 changed files with 359 additions and 160 deletions.
9 changes: 9 additions & 0 deletions app/app/templates/shared/rollbar.html
Expand Up @@ -26,6 +26,15 @@
environment: "{{ env }}"
}
};

{% if github_handle %}
_rollbarConfig.payload.person = {
id: {{ user.id }},
username: "{{ github_handle }}",
email: "{{ user.email }}"
};
{% endif %}

// Rollbar Snippet
!function (r) { function e(n) { if (o[n]) return o[n].exports; var t = o[n] = { exports: {}, id: n, loaded: !1 }; return r[n].call(t.exports, t, t.exports, e), t.loaded = !0, t.exports } var o = {}; return e.m = r, e.c = o, e.p = "", e(0) }([function (r, e, o) { "use strict"; var n = o(1), t = o(4); _rollbarConfig = _rollbarConfig || {}, _rollbarConfig.rollbarJsUrl = _rollbarConfig.rollbarJsUrl || "https://cdnjs.cloudflare.com/ajax/libs/rollbar.js/2.3.9/rollbar.min.js", _rollbarConfig.async = void 0 === _rollbarConfig.async || _rollbarConfig.async; var a = n.setupShim(window, _rollbarConfig), l = t(_rollbarConfig); window.rollbar = n.Rollbar, a.loadFull(window, document, !_rollbarConfig.async, _rollbarConfig, l) }, function (r, e, o) { "use strict"; function n(r) { return function () { try { return r.apply(this, arguments) } catch (r) { try { console.error("[Rollbar]: Internal error", r) } catch (r) { } } } } function t(r, e) { this.options = r, this._rollbarOldOnError = null; var o = s++; this.shimId = function () { return o }, "undefined" != typeof window && window._rollbarShims && (window._rollbarShims[o] = { handler: e, messages: [] }) } function a(r, e) { if (r) { var o = e.globalAlias || "Rollbar"; if ("object" == typeof r[o]) return r[o]; r._rollbarShims = {}, r._rollbarWrappedError = null; var t = new p(e); return n(function () { e.captureUncaught && (t._rollbarOldOnError = r.onerror, i.captureUncaughtExceptions(r, t, !0), i.wrapGlobals(r, t, !0)), e.captureUnhandledRejections && i.captureUnhandledRejections(r, t, !0); var n = e.autoInstrument; return e.enabled !== !1 && (void 0 === n || n === !0 || "object" == typeof n && n.network) && r.addEventListener && (r.addEventListener("load", t.captureLoad.bind(t)), r.addEventListener("DOMContentLoaded", t.captureDomContentLoaded.bind(t))), r[o] = t, t })() } } function l(r) { return n(function () { var e = this, o = Array.prototype.slice.call(arguments, 0), n = { shim: e, method: r, args: o, ts: new Date }; window._rollbarShims[this.shimId()].messages.push(n) }) } var i = o(2), s = 0, d = o(3), c = function (r, e) { return new t(r, e) }, p = d.bind(null, c); t.prototype.loadFull = function (r, e, o, t, a) { var l = function () { var e; if (void 0 === r._rollbarDidLoad) { e = new Error("rollbar.js did not load"); for (var o, n, t, l, i = 0; o = r._rollbarShims[i++];)for (o = o.messages || []; n = o.shift();)for (t = n.args || [], i = 0; i < t.length; ++i)if (l = t[i], "function" == typeof l) { l(e); break } } "function" == typeof a && a(e) }, i = !1, s = e.createElement("script"), d = e.getElementsByTagName("script")[0], c = d.parentNode; s.crossOrigin = "", s.src = t.rollbarJsUrl, o || (s.async = !0), s.onload = s.onreadystatechange = n(function () { if (!(i || this.readyState && "loaded" !== this.readyState && "complete" !== this.readyState)) { s.onload = s.onreadystatechange = null; try { c.removeChild(s) } catch (r) { } i = !0, l() } }), c.insertBefore(s, d) }, t.prototype.wrap = function (r, e, o) { try { var n; if (n = "function" == typeof e ? e : function () { return e || {} }, "function" != typeof r) return r; if (r._isWrap) return r; if (!r._rollbar_wrapped && (r._rollbar_wrapped = function () { o && "function" == typeof o && o.apply(this, arguments); try { return r.apply(this, arguments) } catch (o) { var e = o; throw "string" == typeof e && (e = new String(e)), e._rollbarContext = n() || {}, e._rollbarContext._wrappedSource = r.toString(), window._rollbarWrappedError = e, e } }, r._rollbar_wrapped._isWrap = !0, r.hasOwnProperty)) for (var t in r) r.hasOwnProperty(t) && (r._rollbar_wrapped[t] = r[t]); return r._rollbar_wrapped } catch (e) { return r } }; for (var u = "log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleUnhandledRejection,captureEvent,captureDomContentLoaded,captureLoad".split(","), f = 0; f < u.length; ++f)t.prototype[u[f]] = l(u[f]); r.exports = { setupShim: a, Rollbar: p } }, function (r, e) { "use strict"; function o(r, e, o) { if (r) { var t; "function" == typeof e._rollbarOldOnError ? t = e._rollbarOldOnError : r.onerror && !r.onerror.belongsToShim && (t = r.onerror, e._rollbarOldOnError = t); var a = function () { var o = Array.prototype.slice.call(arguments, 0); n(r, e, t, o) }; a.belongsToShim = o, r.onerror = a } } function n(r, e, o, n) { r._rollbarWrappedError && (n[4] || (n[4] = r._rollbarWrappedError), n[5] || (n[5] = r._rollbarWrappedError._rollbarContext), r._rollbarWrappedError = null), e.handleUncaughtException.apply(e, n), o && o.apply(r, n) } function t(r, e, o) { if (r) { "function" == typeof r._rollbarURH && r._rollbarURH.belongsToShim && r.removeEventListener("unhandledrejection", r._rollbarURH); var n = function (r) { var o, n, t; try { o = r.reason } catch (r) { o = void 0 } try { n = r.promise } catch (r) { n = "[unhandledrejection] error getting `promise` from event" } try { t = r.detail, !o && t && (o = t.reason, n = t.promise) } catch (r) { t = "[unhandledrejection] error getting `detail` from event" } o || (o = "[unhandledrejection] error getting `reason` from event"), e && e.handleUnhandledRejection && e.handleUnhandledRejection(o, n) }; n.belongsToShim = o, r._rollbarURH = n, r.addEventListener("unhandledrejection", n) } } function a(r, e, o) { if (r) { var n, t, a = "EventTarget,Window,Node,ApplicationCache,AudioTrackList,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(","); for (n = 0; n < a.length; ++n)t = a[n], r[t] && r[t].prototype && l(e, r[t].prototype, o) } } function l(r, e, o) { if (e.hasOwnProperty && e.hasOwnProperty("addEventListener")) { for (var n = e.addEventListener; n._rollbarOldAdd && n.belongsToShim;)n = n._rollbarOldAdd; var t = function (e, o, t) { n.call(this, e, r.wrap(o), t) }; t._rollbarOldAdd = n, t.belongsToShim = o, e.addEventListener = t; for (var a = e.removeEventListener; a._rollbarOldRemove && a.belongsToShim;)a = a._rollbarOldRemove; var l = function (r, e, o) { a.call(this, r, e && e._rollbar_wrapped || e, o) }; l._rollbarOldRemove = a, l.belongsToShim = o, e.removeEventListener = l } } r.exports = { captureUncaughtExceptions: o, captureUnhandledRejections: t, wrapGlobals: a } }, function (r, e) { "use strict"; function o(r, e) { this.impl = r(e, this), this.options = e, n(o.prototype) } function n(r) { for (var e = function (r) { return function () { var e = Array.prototype.slice.call(arguments, 0); if (this.impl[r]) return this.impl[r].apply(this.impl, e) } }, o = "log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleUnhandledRejection,_createItem,wrap,loadFull,shimId,captureEvent,captureDomContentLoaded,captureLoad".split(","), n = 0; n < o.length; n++)r[o[n]] = e(o[n]) } o.prototype._swapAndProcessMessages = function (r, e) { this.impl = r(this.options); for (var o, n, t; o = e.shift();)n = o.method, t = o.args, this[n] && "function" == typeof this[n] && ("captureDomContentLoaded" === n || "captureLoad" === n ? this[n].apply(this, [t[0], o.ts]) : this[n].apply(this, t)); return this }, r.exports = o }, function (r, e) { "use strict"; r.exports = function (r) { return function (e) { if (!e && !window._rollbarInitialized) { r = r || {}; for (var o, n, t = r.globalAlias || "Rollbar", a = window.rollbar, l = function (r) { return new a(r) }, i = 0; o = window._rollbarShims[i++];)n || (n = o.handler), o.handler._swapAndProcessMessages(l, o.messages); window[t] = n, window._rollbarInitialized = !0 } } } }]);
// End Rollbar Snippet
Expand Down
2 changes: 1 addition & 1 deletion app/assets/v2/js/pages/bounty_details.js
Expand Up @@ -724,7 +724,7 @@ var render_activity = function(result) {
created_on: _interested.created,
age: timeDifference(new Date(result['now']), new Date(_interested.created)),
status: 'started',
uninterest_possible: isBountyOwner(result)
uninterest_possible: isBountyOwner(result) || document.isStaff
});
});
}
Expand Down
15 changes: 6 additions & 9 deletions app/dashboard/notifications.py
Expand Up @@ -736,7 +736,7 @@ def maybe_notify_bounty_user_removed_to_slack(bounty, username):

#todo: DRY with expiration_start_work
num_days_back_to_warn = 3
num_days_back_to_delete_interest = 10
num_days_back_to_delete_interest = 6


def maybe_notify_user_removed_github(bounty, username, last_heard_from_user_days=None):
Expand All @@ -749,9 +749,9 @@ def maybe_notify_user_removed_github(bounty, username, last_heard_from_user_days

status_header = get_status_header(bounty)

msg = f"""{status_header}@{username} has been removed from this issue due to inactivity ({last_heard_from_user_days} days) on the github thread. @{username} if you believe this was done in error, please <a href={bounty.url}>go to the bounty</a> and click 'start work' again.
* [x] warning 1 ({num_days_back_to_warn} days)
* [x] warning 2 ({num_days_back_to_warn * 2} days)
msg = f"""{status_header}@{username} has been removed for inactivity and [the issue]({bounty.url}) has been returned to an ‘Open’ Status. Let us know if you believe this has been done in error!
* [x] warning ({num_days_back_to_warn} days)
* [x] auto removal ({num_days_back_to_delete_interest} days)
"""

Expand All @@ -763,11 +763,8 @@ def maybe_warn_user_removed_github(bounty, username, last_heard_from_user_days):
bounty.network != settings.ENABLE_NOTIFICATIONS_ON_NETWORK):
return False

first_warning = 'x'
second_warning = 'x' if last_heard_from_user_days > num_days_back_to_warn else ' '
msg = f"""@{username} are you still working on this issue?
* [{first_warning}] warning 1 ({num_days_back_to_warn} days)
* [{second_warning}] warning 2 ({num_days_back_to_warn * 2} days)
msg = f"""@{username} Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!
* [x] warning ({num_days_back_to_warn} days)
* [ ] auto removal ({num_days_back_to_delete_interest} days)
"""

Expand Down
1 change: 1 addition & 0 deletions app/dashboard/templates/bounty_details.html
Expand Up @@ -295,6 +295,7 @@ <h5 class="bounty-heading">{% trans "Funder" %}</h5>
document.issueURL = '{{issueURL}}';
document.issueNetwork = '{{network}}';
document.issue_stdbounties_id = '{{stdbounties_id}}';
document.isStaff = '{{is_staff}}';
</script>

<!-- jQuery -->
Expand Down
4 changes: 2 additions & 2 deletions app/dashboard/templates/shared/sidebar_search.html
Expand Up @@ -24,7 +24,7 @@
</div>
<div class="col-12 options">
<div class="form__radio option">
<input name="idx_status" id="status_open" type="radio" value="open" val-ui='Open' />
<input name="idx_status" id="status_open" type="radio" value="open" val-ui='Open' checked />
<label class="filter-label" for=status_open>1 {% trans "Open" %}</label>
</div>

Expand Down Expand Up @@ -54,7 +54,7 @@
</div>

<div class="form__radio option">
<input name="idx_status" id="any_status" type="radio" value="any" checked />
<input name="idx_status" id="any_status" type="radio" value="any" />
<label class="filter-label" for=any_status>{% trans "Any" %}</label>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/dashboard/views.py
Expand Up @@ -289,7 +289,7 @@ def uninterested(request, bounty_id, profile_id):
return JsonResponse({'errors': ['Bounty doesn\'t exist!']},
status=401)

if not bounty.is_funder(request.user.username.lower()):
if not bounty.is_funder(request.user.username.lower()) and not request.user.is_staff:
return JsonResponse(
{'error': 'Only bounty funders are allowed to remove users!'},
status=401)
Expand Down Expand Up @@ -675,6 +675,7 @@ def bounty_details(request, ghuser='', ghrepo='', ghissue=0, stdbounties_id=None
'is_github_token_valid': is_github_token_valid(_access_token),
'github_auth_url': get_auth_url(request.path),
"newsletter_headline": _("Be the first to know about new funded issues."),
'is_staff': request.user.is_staff,
}

if issue_url:
Expand Down
16 changes: 11 additions & 5 deletions app/dataviz/d3_views.py
@@ -1,6 +1,7 @@
import json
import math
import random
import time

from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required
Expand Down Expand Up @@ -532,6 +533,7 @@ def viz_graph(request, _type, template='graph'):
source = bounty.org_name
if source:
for fulfillment in bounty.fulfillments.all():
created = fulfillment.created_on.strftime("%s")
if _type != 'fulfillments_accepted_only' or fulfillment.accepted:
target = fulfillment.fulfiller_github_username.lower()
if hide_pii:
Expand All @@ -540,7 +542,7 @@ def viz_graph(request, _type, template='graph'):
types[target] = 'target_accepted' if fulfillment.accepted else 'target'
names[source] = None
names[target] = None
edges.append((source, target, weight))
edges.append((source, target, weight, created))

value = values.get(source, 0)
value += weight
Expand All @@ -550,7 +552,8 @@ def viz_graph(request, _type, template='graph'):
values[target] = value

for tip in Tip.objects.filter(network='mainnet'):
weight = bounty.value_in_usdt
weight = tip.value_in_usdt
created = tip.created_on.strftime("%s")
if weight:
source = tip.username.lower()
if hide_pii:
Expand All @@ -565,11 +568,12 @@ def viz_graph(request, _type, template='graph'):
if source not in types.keys():
types[target] = 'target'
names[target] = None
edges.append((source, target, weight))
edges.append((source, target, weight, created))


if _type in ['what_future_could_look_like', 'all']:
last_node = None
created = 1525147679
nodes = Profile.objects.exclude(github_access_token='').all()
for profile in nodes:
node = profile.handle.lower()
Expand All @@ -585,7 +589,7 @@ def viz_graph(request, _type, template='graph'):
target = nodes.order_by('?').first().handle.lower()
if hide_pii:
target = helper_hide_pii(target)
edges.append((target, node, weight))
edges.append((target, node, weight, created))
last_node = node


Expand All @@ -600,7 +604,7 @@ def viz_graph(request, _type, template='graph'):
value = int(math.sqrt(math.sqrt(values.get(name, 1))))
output['nodes'].append({"name": name, 'value': value, 'type': types.get(name), 'avatar': avatars.get(name)})
for edge in edges:
source, target, weight = edge
source, target, weight, created = edge
weight = math.sqrt(weight)
if names.get(source) and names.get(target):
source = names[source]
Expand All @@ -610,6 +614,7 @@ def viz_graph(request, _type, template='graph'):
'target': target,
'value': value,
'weight': weight,
'created': created,
})

return JsonResponse(output)
Expand All @@ -620,6 +625,7 @@ def viz_graph(request, _type, template='graph'):
'viz_type': _type,
'type_options': _type_options,
'page_route': page_route,
'max_time': int(time.time()),
}
return TemplateResponse(request, f'dataviz/{template}.html', params)

Expand Down

0 comments on commit eeba1d8

Please sign in to comment.