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

DOT-1535 nearby groups radius #401

Merged
merged 7 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/Http/Controllers/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ private function indexVariations($tab, $network)
->select($group_atts)
->get();

//Make sure we don't show the same groups in nearest to you
$your_groups_uniques = $your_groups->pluck('idgroups')->toArray();
$groups_near_you = $user->groupsNearby(10);
// We pass a high limit to the groups nearby; there is a distance limit which will normally kick in first.
$groups_near_you = $user->groupsNearby(1000);

return view('group.index', [
'your_groups' => $this->expandGroups($your_groups),
'your_groups_uniques' => $your_groups_uniques,
'groups_near_you' => $this->expandGroups($groups_near_you),
'groups' => $this->expandGroups($groups),
'your_area' => $user->location,
Expand Down Expand Up @@ -830,6 +828,7 @@ private function expandGroups($groups)
'networks' => Arr::pluck($group->networks, 'id'),
'country' => $group->country,
'group_tags' => $group->group_tags()->get()->pluck('id'),
'distance' => $group->distance
];
}
}
Expand Down
9 changes: 9 additions & 0 deletions resources/js/components/GroupsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
<b class="text-uppercase d-none d-lg-block">{{ __('groups.groups_title2') }}</b>
</template>
<div v-if="nearbyGroups && nearbyGroups.length">
<p class="mt-1">
{{ nearestGroups }}
<a href="/profile/edit" class="small">{{ __('groups.nearest_groups_change') }}</a>.
</p>
<GroupsTable
:groups="nearbyGroups"
class="mt-3"
Expand Down Expand Up @@ -167,6 +171,11 @@ export default {
return g.nearby
})
},
nearestGroups() {
return this.$lang.get('groups.nearest_groups', {
location: this.yourArea
})
}
},
watch: {
currentTab(newVal) {
Expand Down
9 changes: 8 additions & 1 deletion resources/js/components/GroupsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</template>
<template slot="cell(location)" slot-scope="data">
<div class="d-none d-md-block">
{{ data.item.location.location }}
{{ data.item.location.location }} <span class="text-muted small" v-if="data.item.location.distance">{{ distance(data.item.location.distance )}} km</span>
<br />
<span class="small text-muted">{{ data.item.location.country }}</span>
</div>
Expand Down Expand Up @@ -308,6 +308,13 @@ export default {
this.$store.dispatch('groups/unfollow', {
idgroups: idgroups
})
},
distance(dist ) {
if (dist < 5) {
return Math.round(dist * 10) / 10
} else {
return Math.round(dist)
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion resources/lang/en/groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@
'quick_access' => 'Groups you create or follow appear below for quick access.',
'no_groups_mine' => '<b>If you can\'t see any here yet, why not <a href="/group/nearby">follow your nearest group</a> to hear about their upcoming repair events?</b>',
'no_groups_nearest_no_location' => '<b><p>You do not currently have a town/city set. You can set one in <a href="/profile/edit">your profile</a>.</p><p>You can also <a href="/group/all">view all groups</a>.</p></b>',
'no_groups_nearest_with_location' => '<b><p>It doesn\'t look like there are any groups listed near you yet.</p><p>Would you like to start or add a group? Have a look at <a href="https://talk.restarters.net/t/how-to-power-up-community-repair-with-restarters-net/1228/2">our resources</a>.</p></b>',
'no_groups_nearest_with_location' => '<p>There are no groups within 50 km of your location. You can <a href="/group/all">see all groups here</a>. Or why not start your own? <a href="https://talk.restarters.net/t/how-to-run-a-repair-event-the-restart-party-kit/324">Learn what running your own repair event involves.</a></p>',
'nearest_groups' => 'These are the groups that are within 50 km of :location',
'nearest_groups_change' => '(change)',
'group_count' => 'There is <b>:count group</b>.|There are <b>:count groups</b>.',
'search_name_placeholder' => 'Search name...',
'search_location_placeholder' => 'Search location...',
Expand Down
24 changes: 0 additions & 24 deletions resources/views/partials/tables/head-groups.blade.php

This file was deleted.

36 changes: 0 additions & 36 deletions resources/views/partials/tables/row-groups.blade.php

This file was deleted.