Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fbbc9d0
WIP Add group map.
edwh Sep 16, 2024
2e74640
WIP Add group map.
edwh Sep 23, 2024
cd2fca7
WIP Add group map.
edwh Sep 23, 2024
208a0eb
Remove GroupsTableFilters.
edwh Oct 7, 2024
a5229d7
Lose All Groups tab, modal group info popup
edwh Oct 28, 2024
15def3c
Show group map/table on network page.
edwh Oct 28, 2024
6873286
Some map improvements.
edwh Nov 4, 2024
c434f1b
Speed up devices by caching category powered flag.
edwh Nov 4, 2024
fd6316f
Speed up fetch of groups by adding parameter to suppress stats info.
edwh Nov 4, 2024
83f1c59
Merge branch 'develop' into RES-1995_map_of_groups
edwh Nov 4, 2024
1f439b6
Test fixes.
edwh Nov 4, 2024
f28ac37
Test fixes.
edwh Nov 4, 2024
d4c0e07
Revert "Bump elliptic from 6.5.4 to 6.6.0"
edwh Nov 4, 2024
c9b9367
Revert "Bump webpack from 5.76.1 to 5.95.0"
edwh Nov 4, 2024
cc1073d
Revert "Bump dompurify from 2.3.8 to 2.5.7"
edwh Nov 4, 2024
a7c7ba8
Revert "Bump send, browser-sync and express"
edwh Nov 4, 2024
85331eb
Revert "Bump @sentry/browser and @sentry/vue"
edwh Nov 4, 2024
f980671
Merge branch 'develop' into RES-1995_map_of_groups
edwh Nov 12, 2024
fd49946
Review feedback.
edwh Nov 12, 2024
9d7bf56
Speedups
edwh Nov 12, 2024
900700d
Merge branch 'develop' into RES-1995_map_of_groups
edwh Nov 18, 2024
fed4079
Merge issues.
edwh Nov 18, 2024
a303ca3
Map - add loading indicator
edwh Nov 18, 2024
a3a42fc
Add group map searchbox
edwh Nov 18, 2024
3c03870
Not loading own groups.
edwh Nov 18, 2024
77958f2
Test fixes.
edwh Nov 18, 2024
ca83cf0
Test fixes.
edwh Nov 25, 2024
0105020
Test fixes.
edwh Nov 25, 2024
8f580a5
Test fixes.
edwh Nov 25, 2024
d1c919b
WIP: move group image into group object.
edwh Nov 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,11 @@ public function uWasteDiverted()
{
$wasteDiverted = 0;

if ($this->isFixed() && $this->deviceCategory->isUnpowered()) {
$unpowered = \Cache::remember('category-unpowered-' . $this->category, 60, function() {
return $this->deviceCategory->isUnpowered();
});

if ($this->isFixed() && $unpowered) {
if ($this->estimate > 0) {
$wasteDiverted = $this->estimate;
} else {
Expand Down
107 changes: 104 additions & 3 deletions app/Http/Controllers/API/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,42 @@ public static function getGroupList()
* type="boolean"
* )
* ),
* @OA\Parameter(
* name="includeNextEvent",
* description="Include the next event for the group. This makes the call slower. Default false.",
* required=false,
* in="query",
* @OA\Schema(
* type="boolean"
* )
* ),
* @OA\Response(
* response=200,
* description="Successful operation",
* @OA\JsonContent(
* @OA\Property(
* property="data",
* title="data",
* description="An array of group names",
* description="An array of basic group info",
* type="array",
* @OA\Items(
* type="object",
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="name", type="string", example="Group Name"),
* @OA\Property(
* property="lat",
* title="lat",
* description="Latitude of the group.",
* format="float",
* example="50.8113243"
* ),
* @OA\Property(
* property="lng",
* title="lng",
* description="Longitude of the group.",
* format="float",
* example="-1.0788839"
* ),
* )
* )
* )
Expand All @@ -265,8 +288,8 @@ public static function listNamesv2(Request $request) {
'includeArchived' => ['string', 'in:true,false'],
]);

// We only return the group id and name, for speed.
$query = Group::select('idgroups', 'name', 'archived_at');
// We only return a small number of attributes, for speed.
$query = Group::select('idgroups', 'name', 'latitude', 'longitude', 'archived_at');

if (!$request->has('includeArchived') || $request->get('includeArchived') == 'false') {
$query = $query->whereNull('archived_at');
Expand All @@ -279,6 +302,8 @@ public static function listNamesv2(Request $request) {
$ret[] = [
'id' => $group->idgroups,
'name' => $group->name,
'lat' => $group->latitude,
'lng' => $group->longitude,
'archived_at' => $group->archived_at ? Carbon::parse($group->archived_at)->toIso8601String() : null
];
}
Expand All @@ -288,6 +313,82 @@ public static function listNamesv2(Request $request) {
];
}

/**
* @OA\Get(
* path="/api/v2/groups/summary",
* operationId="getGroupSummariesv2",
* tags={"Groups"},
* summary="Get list of groups with summary information",
* @OA\Parameter(
* name="archived",
* description="Include archived groups",
* required=false,
* in="path",
* @OA\Schema(
* type="boolean"
* )
* ),
* @OA\Parameter(
* name="includeNextEvent",
* description="Include the next event for the group. This makes the call slower. Default false.",
* required=false,
* in="query",
* @OA\Schema(
* type="boolean"
* )
* ),
* @OA\Parameter(
* name="includeCounts",
* description="Include the counts of hosts and restarters. This makes the call slower. Default false.",
* required=false,
* in="query",
* @OA\Schema(
* type="boolean"
* )
* ),
* @OA\Parameter(
* name="includeCounts",
* description="Include impact stats. This makes the call slower. Default true.",
* required=false,
* in="query",
* @OA\Schema(
* type="boolean"
* )
* ),
* @OA\Response(
* response=200,
* description="Successful operation",
* @OA\JsonContent(
* @OA\Property(
* property="data",
* title="data",
* description="An array of events",
* type="array",
* @OA\Items(
* @OA\Schema(
* ref="#/components/schemas/GroupSummary"
* ),
* )
* )
* )
* ),
* )
*/

public static function listSummaryv2(Request $request) {
$request->validate([
'archived' => ['string', 'in:true,false'],
]);

$query = Group::all();

$groups = $query->all();

return [
'data' => \App\Http\Resources\GroupSummaryCollection::make($groups)
];
}

/**
* @OA\Get(
* path="/api/v2/groups/tags",
Expand Down
45 changes: 33 additions & 12 deletions app/Http/Controllers/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,13 @@ private function indexVariations($tab, $network)
//Get current logged in user
$user = Auth::user();

// Get all groups
$groups = Group::with(['networks'])
->orderBy('name', 'ASC')
->get();

// Get all group tags
$all_group_tags = GroupTags::all();
$networks = Network::all();

// Look for groups we have joined, not just been invited to. We have to explicitly test on deleted_at because
// the normal filtering out of soft deletes won't happen for joins.
$your_groups =array_column(Group::with(['networks'])
$your_groups = array_column(Group::with(['networks'])
->join('users_groups', 'users_groups.group', '=', 'groups.idgroups')
->leftJoin('events', 'events.group', '=', 'groups.idgroups')
->where('users_groups.user', $user->id)
Expand All @@ -66,13 +61,40 @@ private function indexVariations($tab, $network)
->get()
->toArray(), 'idgroups');

// We pass a high limit to the groups nearby; there is a distance limit which will normally kick in first.
$groups_near_you = array_column($user->groupsNearby(1000), 'idgroups');
$nearby_groups = [];
$min_lat = 90;
$max_lat = -90;
$min_lng = 180;
$max_lng = -180;

if ($user->latitude || $user->longitude || $user->country_code) {
// We pass a high limit to the groups nearby; there is a distance limit which will normally kick in first.
$nearby_groups = $user->groupsNearby(1000);

// Now find the lat/lng bounding box which contains these groups.
foreach ($nearby_groups as $group) {
if ($group->latitude < $min_lat) {
$min_lat = $group->latitude;
}
if ($group->latitude > $max_lat) {
$max_lat = $group->latitude;
}
if ($group->longitude < $min_lng) {
$min_lng = $group->longitude;
}
if ($group->longitude > $max_lng) {
$max_lng = $group->longitude;
}
}
}

return view('group.index', [
'groups' => GroupController::expandGroups($groups, $your_groups, $groups_near_you),
'your_groups' => $your_groups,
'nearby_groups' => [ [ $min_lat, $min_lng ], [ $max_lat, $max_lng ] ],
'your_area' => $user->location,
'tab' => $tab,
'your_lat' => $user->latitude,
'your_lng' => $user->longitude,
'tab' => (!$tab || $tab === 'mine') ? 'mine' : 'other',
'network' => $network,
'networks' => $networks,
'all_group_tags' => $all_group_tags,
Expand Down Expand Up @@ -484,7 +506,7 @@ public function delete($id)
}
}

public static function expandGroups($groups, $your_groupids, $nearby_groupids)
public static function expandGroups($groups, $your_groupids)
{
$ret = [];
$user = Auth::user();
Expand Down Expand Up @@ -530,7 +552,6 @@ public static function expandGroups($groups, $your_groupids, $nearby_groupids)
'networks' => \Illuminate\Support\Arr::pluck($group->networks, 'id'),
'group_tags' => $group->group_tags()->get()->pluck('id'),
'following' => in_array($group->idgroups, $your_groupids),
'nearby' => in_array($group->idgroups, $nearby_groupids),
'archived_at' => $group->archived_at ? Carbon::parse($group->archived_at)->toIso8601String() : null
];
}
Expand Down
29 changes: 29 additions & 0 deletions app/Http/Controllers/NetworkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,38 @@ public function show(Network $network)
$groupsForAssociating = $network->groupsNotIn()->sortBy('name');
}

// Find the lat/lng bounding box for all groups in this network.
$minLat = $minLng = $maxLat = $maxLng = null;

foreach ($network->groups as $group) {
$lat = $group->latitude;
$lng = $group->longitude;

if (is_null($minLat) || $lat < $minLat) {
$minLat = $lat;
}

if (is_null($minLng) || $lng < $minLng) {
$minLng = $lng;
}

if (is_null($maxLat) || $lat > $maxLat) {
$maxLat = $lat;
}

if (is_null($maxLng) || $lng > $maxLng) {
$maxLng = $lng;
}
}


return view('networks.show', [
'network' => $network,
'groupsForAssociating' => $groupsForAssociating,
'mapBounds' => [
[ $minLat, $minLng ],
[ $maxLat, $maxLng ],
],
]);
}

Expand Down
10 changes: 6 additions & 4 deletions app/Http/Resources/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,11 @@ class Group extends JsonResource
*/
public function toArray($request)
{
$stats = $this->resource->getGroupStats();
$stats['events'] = $stats['parties'];
unset($stats['parties']);
if ($request->get('includeStats', true)) {
$stats = $this->resource->getGroupStats();
$stats['events'] = $stats['parties'];
unset($stats['parties']);
}

$networkData = gettype($this->network_data) == 'string' ? json_decode($this->network_data, true) : $this->network_data;

Expand All @@ -288,7 +290,7 @@ public function toArray($request)
$ret = [
'id' => $this->idgroups,
'name' => $this->name,
'image' => $this->groupImage && is_object($this->groupImage) && is_object($this->groupImage->image) ? $this->groupImage->image->path : null,
'image' => $this->image,
'website' => $this->website,
'phone' => $this->phone,
'description' => $this->free_text,
Expand Down
Loading