Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed Jul 10, 2023
1 parent c36e953 commit e3e7db1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
5 changes: 2 additions & 3 deletions app/Http/Controllers/API/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public static function getGroupsByUsersNetworks(Request $request)
// New Collection Instance
$collection = collect([]);

$countries = array_flip(\App\Helpers\Fixometer::getAllCountries());

foreach ($groups as $group) {
// If we have a bounding box, check that the group is within it.
if (! $bbox || (
Expand All @@ -102,7 +100,8 @@ public static function getGroupsByUsersNetworks(Request $request)
'timezone' => $group->timezone,
'location' => [
'value' => $group->location,
'country' => Fixometer::translateCountry($group->country_code, $countries),
'country' => Fixometer::getCountryFromCountryCode($group->country_code),
'country_code' => $group->country_code,
'latitude' => $group->latitude,
'longitude' => $group->longitude,
'area' => $group->area,
Expand Down
5 changes: 2 additions & 3 deletions app/Http/Controllers/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,6 @@ public static function expandGroups($groups, $your_groupids, $nearby_groupids)
$user = Auth::user();

if ($groups) {
$countries = array_flip(Fixometer::getAllCountries('en'));

foreach ($groups as $group) {
$group_image = $group->groupImage;

Expand Down Expand Up @@ -513,7 +511,8 @@ public static function expandGroups($groups, $your_groupids, $nearby_groupids)
asset('uploads/mid_'.$group_image->image->path) : null,
'location' => [
'location' => rtrim($group->location),
'country' => Fixometer::translateCountry($group->country_code, $countries),
'country' => Fixometer::getCountryFromCountryCode($group->country_code),
'country_code' => $group->country_code,
'distance' => $distance,
],
'next_event' => $event ? $event->event_date_local : null,
Expand Down
10 changes: 9 additions & 1 deletion database/migrations/2023_06_12_153317_country_codes.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public function up()
*/
public function down()
{
//
Schema::table('groups', function (Blueprint $table) {
$table->dropColumn('country_code');
});

Schema::table('users', function (Blueprint $table) {
$table->renameColumn('country_code', 'country');
});

DB::update(DB::raw("UPDATE users SET country = 'GBR' WHERE country = 'GB'"));
}
};
4 changes: 4 additions & 0 deletions tests/Feature/Networks/NetworkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public function admins_can_associate_group_to_network()
$group = Group::factory()->create([
'latitude' => 51.5074,
'longitude' => -0.1278,
'country_code' => 'GB',
'country' => 'United Kingdom',
]);

$network = Network::factory()->create();
Expand Down Expand Up @@ -131,6 +133,8 @@ public function admins_can_associate_group_to_network()
$this->assertEquals(1, count($groups));
$this->assertEquals($group->idgroups, $groups[0]['id']);
$this->assertEquals($group->name, $groups[0]['name']);
$this->assertEquals($group->country, $groups[0]['location']['country']);
$this->assertEquals($group->country_code, $groups[0]['location']['country_code']);

// Check that the event is listed.
$this->assertEquals(1, count($groups[0]['past_parties']));
Expand Down

0 comments on commit e3e7db1

Please sign in to comment.