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

Fix/data changes #4477

Merged
merged 12 commits into from
May 29, 2019
12 changes: 5 additions & 7 deletions app/dashboard/templates/dashboard/users.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<div class="d-flex flex-column py-1 bg-lightblue">
<img class="rounded-circle shadow-sm mx-auto mt-n5 mb-3 bg-white" width="113" height="113" :src="`/dynamic/avatar/${ user.handle }`"/>
<h5 class="text-center card-user_name">
[[ user.data.name || user.handle ]]
[[ user.name || user.handle ]]
<span v-if="user.verification">
<img src="{% static 'v2/images/badge-verify.svg' %}" width="15" height="15" title="Verified user" alt="verify badget">
</span>
Expand All @@ -153,23 +153,21 @@ <h5 class="text-center card-user_name">
</template>
</div>
<div class="text-center my-1 font-smaller-1">
<a :href="`${ user.data.html_url }?tab=repositories`" target="_blank" rel="noopener noreferrer" >
<a :href="`https://github.com/${ user.handle }`" target="_blank" rel="noopener noreferrer" >
<i class="fab fa-github"></i>
</a>
<a :href="`${ user.data.blog }`" target="_blank" rel="noopener noreferrer" v-if="user.data.blog">
<a :href="`${ user.blog }`" target="_blank" rel="noopener noreferrer" v-if="user.blog">
<i class="fas fa-home"></i>
</a>
<a :href="`mailto:${ user.data.email }`" v-if="user.data.email">
<i class="far fa-envelope"></i>
</a>
<a :href="`https://www.linkedin.com/in/${ user.linkedin_url }`" v-if="user.linkedin_url">
<i class="fab fa-linkedin-in"></i>
</a>
</div>
<div class="text-center" id="job_status" v-if="user.show_job_status">
<a :href="`${media_url}${user.resume}`" download data-toggle="tooltip" title="Download resume">
<a v-if="user.resume && user.job_search_status !== 'N'" :href="`${media_url}${user.resume}`" download data-toggle="tooltip" title="Download resume">
<i class="fa fa-briefcase mr-2" aria-hidden="true"></i> [[ user.job_status ]]
</a>
<span v-else><i class="fa fa-briefcase mr-2" aria-hidden="true"></i> [[ user.job_status ]]</span>
</div>
<div class="text-center">
<span v-if="user.position_contributor > 0"><b>#[[ user.position_contributor ]]</b> contributor</span> <span v-if="user.position_funder > 0"><b>#[[ user.position_funder ]]</b> funder</span>
Expand Down
50 changes: 23 additions & 27 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,24 +776,26 @@ def users_fetch(request):
else:
network = 'rinkeby'

user_list = Profile.objects.prefetch_related('fulfilled', 'leaderboard_ranks', 'feedbacks_got').order_by(order_by)
profile_list = Profile.objects.prefetch_related(
'fulfilled', 'leaderboard_ranks', 'feedbacks_got'
).exclude(hide_profile=True).order_by(order_by)

if q:
user_list = user_list.filter(Q(handle__icontains=q) | Q(keywords__icontains=q))
profile_list = profile_list.filter(Q(handle__icontains=q) | Q(keywords__icontains=q))

if skills:
user_list = user_list.filter(keywords__icontains=skills)
profile_list = profile_list.filter(keywords__icontains=skills)

if len(bounties_completed) == 2:
user_list = user_list.annotate(
profile_list = profile_list.annotate(
count=Count('fulfilled', filter=Q(fulfilled__bounty__network=network, fulfilled__accepted=True))
).filter(
count__gte=bounties_completed[0],
count__lte=bounties_completed[1],
)

if len(leaderboard_rank) == 2:
user_list = user_list.filter(
profile_list = profile_list.filter(
leaderboard_ranks__isnull=False,
leaderboard_ranks__leaderboard='quarterly_earners',
leaderboard_ranks__rank__gte=leaderboard_rank[0],
Expand All @@ -802,51 +804,45 @@ def users_fetch(request):
)

if rating != 0:
user_list = user_list.annotate(
profile_list = profile_list.annotate(
average_rating=Avg('feedbacks_got__rating', filter=Q(feedbacks_got__bounty__network=network))
).filter(
average_rating__gte=rating
)

if organisation:
user_list = user_list.filter(
profile_list = profile_list.filter(
fulfilled__bounty__network=network,
fulfilled__bounty__accepted=True,
fulfilled__bounty__github_url__icontains=organisation
).distinct()

params = dict()
all_pages = Paginator(user_list, limit)
all_pages = Paginator(profile_list, limit)
all_users = []
for user in all_pages.page(page):
profile_json = {}
profile_json = user.to_standard_dict()
if user.avatar_baseavatar_related.exists():
user_avatar = user.avatar_baseavatar_related.first()
profile_json['avatar_id'] = user_avatar.pk
profile_json['avatar_url'] = user_avatar.avatar_url
count_work_completed = Activity.objects.filter(profile=user, activity_type='work_done').count()
count_work_in_progress = Activity.objects.filter(profile=user, activity_type='start_work').count()
previously_worked_with = 0
if profile:
previously_worked_with = BountyFulfillment.objects.filter(
bounty__bounty_owner_github_username__iexact=profile.handle,
fulfiller_github_username__iexact=user.handle,
bounty__network=network,
bounty__accepted=True
).count()

profile_json = {k: getattr(user, k) for k in
danlipert marked this conversation as resolved.
Show resolved Hide resolved
['id', 'actions_count', 'created_on', 'handle', 'hide_profile',
'show_job_status', 'job_location', 'job_salary', 'job_search_status',
'job_type', 'linkedin_url', 'resume', 'remote', 'keywords',
'organizations', 'is_org']}
profile_json['job_status'] = user.job_status_verbose if user.job_search_status else None
profile_json['position_contributor'] = user.get_contributor_leaderboard_index()
profile_json['position_funder'] = user.get_funder_leaderboard_index()
profile_json['work_done'] = count_work_completed
profile_json['work_inprogress'] = count_work_in_progress
profile_json['previously_worked'] = previously_worked_with > 0

profile_json['job_status'] = user.job_status_verbose if user.job_search_status else None
profile_json['verification'] = user.get_my_verified_check
profile_json['avg_rating'] = user.get_average_star_rating
# profile_json['bounties'] = user.get_quarterly_stats
profile_json['is_org'] = user.is_org
if user.avatar_baseavatar_related.exists():
user_avatar = user.avatar_baseavatar_related.first()
profile_json['avatar_id'] = user_avatar.pk
profile_json['avatar_url'] = user_avatar.avatar_url
if user.data:
user_data = user.data
profile_json['blog'] = user_data['blog']

all_users.append(profile_json)
# dumping and loading the json here quickly passes serialization issues - definitely can be a better solution
Expand Down