Skip to content

Commit 0a72290

Browse files
authored
Merge pull request #685 from hhaccessibility/drop-user-location
Drop user location
2 parents 4e9d5f4 + a4bd9db commit 0a72290

6 files changed

Lines changed: 30 additions & 25 deletions

File tree

app/app/AnswerRepository.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ public static function commitAnswersForLocation(string $location_id)
262262
$location->universal_rating = null;
263263
$location->ratings_cache = null;
264264
$location->save();
265-
// invalidate the personalized rating cache for this location.
266-
DB::table('user_location')->where('location_id', '=', $location_id)->delete();
267265
}
268266
AnswerRepository::destroyUncommittedChanges();
269267
}

app/app/Http/Controllers/InternalFeaturesController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public function deleteUser(Request $request)
4040
DB::table('review_comment')->where('answered_by_user_id', '=', $user->id)->delete();
4141
DB::table('location')->where('creator_user_id', '=', $user->id)->update(['creator_user_id' => null]);
4242
DB::table('location')->where('owner_user_id', '=', $user->id)->update(['owner_user_id' => null]);
43+
DB::table('suggestion')->where('user_id', '=', $user->id)->delete();
44+
DB::table('image')->where('uploader_user_id', '=', $user_id)->delete();
4345
DB::table('user')->where('id', '=', $user->id)->delete();
4446
});
4547
return Redirect::to('users');

app/app/Http/Controllers/ProfileController.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,6 @@ public function save(Request $request)
130130
$questions_updated = true;
131131
}
132132
}
133-
if ($questions_updated) {
134-
/*
135-
If the accessibility needs changed,
136-
the personalized ratings need to be recalculated.
137-
*/
138-
$user->personalizedRatings()->detach();
139-
}
140133

141134
$user->save();
142135

app/app/Location.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ public function tags()
5252
return $this->belongsToMany('App\LocationTag');
5353
}
5454

55-
public function personalizedRatings()
56-
{
57-
return $this->hasMany('App\UserLocation');
58-
}
59-
6055
public function comments()
6156
{
6257
return $this->hasMany(ReviewComment::class);

app/app/User.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,7 @@ public function requiredQuestions()
8181
{
8282
return $this->belongsToMany(Question::class, 'user_question');
8383
}
84-
85-
/**
86-
personalizedRatings reteurns an Eloquent query object that
87-
can be used to get the personalized ratings for various locations.
8884

89-
This is used as a cache for speeding up display of many locations while signed in.
90-
*/
91-
public function personalizedRatings()
92-
{
93-
return $this->belongsToMany(Location::class, 'user_location');
94-
}
95-
9685
public static function generateSaltedHash($password)
9786
{
9887
return Hash::make($password);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
use Illuminate\Support\Facades\DB;
7+
8+
class DropUserLocationTable extends Migration
9+
{
10+
public function up()
11+
{
12+
Schema::dropIfExists('user_location');
13+
}
14+
15+
public function down()
16+
{
17+
Schema::create('user_location', function (Blueprint $table) {
18+
$table->increments('id');
19+
$table->string('user_id', 36);
20+
$table->foreign('user_id')->references('id')->on('user');
21+
$table->string('location_id', 36);
22+
$table->foreign('location_id')->references('id')->on('location');
23+
$table->double('personalized_rating', 11, 8);
24+
$table->datetime('when_submitted');
25+
$table->unique(array('location_id', 'user_id'));
26+
});
27+
}
28+
}

0 commit comments

Comments
 (0)