Skip to content

Commit

Permalink
chore: remove events table (#1829)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaiss committed Sep 23, 2018
1 parent 1e91959 commit b337226
Show file tree
Hide file tree
Showing 24 changed files with 21 additions and 261 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -4,6 +4,7 @@ UNRELEASED CHANGES:
* Add ability to define the default email address used for support
* Fix confirm email sent when signup_double_optin is false
* Fix now() without timezone functions
* Remove notion of events

RELEASED VERSIONS:

Expand Down
2 changes: 0 additions & 2 deletions app/Console/Commands/ImportCSV.php
Expand Up @@ -154,7 +154,5 @@ private function csvToContact($data, $account_id, $gender_id)
}

$contact->updateGravatar();

$contact->logEvent('contact', $contact->id, 'create');
}
}
8 changes: 0 additions & 8 deletions app/Http/Controllers/ActivitiesController.php
Expand Up @@ -72,7 +72,6 @@ public function store(ActivitiesRequest $request, Contact $contact)
// New attendees
foreach ($specifiedContactsObj as $newContact) {
$newContact->activities()->attach($activity, ['account_id' => $request->user()->account_id]);
$newContact->logEvent('activity', $activity->id, 'create');
$newContact->calculateActivitiesStatistics();
}

Expand Down Expand Up @@ -140,11 +139,6 @@ public function update(ActivitiesRequest $request, Activity $activity, Contact $
// Has an existing attendee been removed?
if (! array_key_exists($existingContact->id, $specifiedContactsObj)) {
$existingContact->activities()->detach($activity);
$existingContact->logEvent('activity', $activity->id, 'delete');
} else {
// Otherwise we're updating an activity that someone's
// already a part of
$existingContact->logEvent('activity', $activity->id, 'update');
}

// Remove this ID from our list of contacts as we don't
Expand All @@ -157,7 +151,6 @@ public function update(ActivitiesRequest $request, Activity $activity, Contact $
// New attendees
foreach ($specifiedContactsObj as $newContact) {
$newContact->activities()->save($activity);
$newContact->logEvent('activity', $activity->id, 'create');
}

return redirect()->route('people.show', $contact)
Expand All @@ -176,7 +169,6 @@ public function destroy(Activity $activity, Contact $contact)
$activity->deleteJournalEntry();

foreach ($activity->contacts as $contactActivity) {
$contactActivity->events()->forObject($activity)->get()->each->delete();
$contactActivity->calculateActivitiesStatistics();
}

Expand Down
7 changes: 0 additions & 7 deletions app/Http/Controllers/Api/ApiActivityController.php
Expand Up @@ -88,7 +88,6 @@ public function store(Request $request)
$contact = Contact::where('account_id', auth()->user()->account_id)
->findOrFail($attendeeID);
$contact->activities()->save($activity);
$contact->logEvent('activity', $activity->id, 'create');
$contact->calculateActivitiesStatistics();
}

Expand Down Expand Up @@ -143,11 +142,6 @@ public function update(Request $request, $activityId)
// Has an existing attendee been removed?
if (! in_array($contact->id, $attendeesID)) {
$contact->activities()->detach($activity);
$contact->logEvent('activity', $activity->id, 'delete');
} else {
// Otherwise we're updating an activity that someone's
// already a part of
$contact->logEvent('activity', $activity->id, 'update');
}

// Remove this ID from our list of contacts as we don't
Expand All @@ -163,7 +157,6 @@ public function update(Request $request, $activityId)
$contact = Contact::where('account_id', auth()->user()->account_id)
->findOrFail($attendeeID);
$contact->activities()->save($activity);
$contact->logEvent('activity', $activity->id, 'create');
}

return new ActivityResource($activity);
Expand Down
3 changes: 0 additions & 3 deletions app/Http/Controllers/Api/ApiContactController.php
Expand Up @@ -181,7 +181,6 @@ public function store(Request $request)
}

$contact->setAvatarColor();
$contact->logEvent('contact', $contact->id, 'create');

return new ContactResource($contact);
}
Expand Down Expand Up @@ -272,8 +271,6 @@ public function update(Request $request, $contactId)
$specialDate = $contact->setSpecialDateFromAge('deceased_date', $request->input('deceased_date_age'));
}

$contact->logEvent('contact', $contact->id, 'update');

return new ContactResource($contact);
}

Expand Down
4 changes: 0 additions & 4 deletions app/Http/Controllers/Contacts/CallsController.php
Expand Up @@ -28,8 +28,6 @@ public function store(CallsRequest $request, Contact $contact)
]
);

$contact->logEvent('call', $call->id, 'create');

$contact->updateLastCalledInfo($call);

return redirect()->route('people.show', $contact)
Expand All @@ -51,8 +49,6 @@ public function destroy(Contact $contact, Call $call)

$call->delete();

$contact->events()->forObject($call)->get()->each->delete();

if ($contact->calls()->count() == 0) {
$contact->last_talked_to = null;
$contact->save();
Expand Down
8 changes: 1 addition & 7 deletions app/Http/Controllers/Contacts/DebtController.php
Expand Up @@ -43,7 +43,7 @@ public function create(Contact $contact)
*/
public function store(DebtRequest $request, Contact $contact)
{
$debt = $contact->debts()->create(
$contact->debts()->create(
$request->only([
'in_debt',
'amount',
Expand All @@ -55,8 +55,6 @@ public function store(DebtRequest $request, Contact $contact)
]
);

$contact->logEvent('debt', $debt->id, 'create');

return redirect()->route('people.show', $contact)
->with('success', trans('people.debt_add_success'));
}
Expand Down Expand Up @@ -109,8 +107,6 @@ public function update(DebtRequest $request, Contact $contact, Debt $debt)
]
);

$contact->logEvent('debt', $debt->id, 'update');

return redirect()->route('people.show', $contact)
->with('success', trans('people.debt_edit_success'));
}
Expand All @@ -126,8 +122,6 @@ public function destroy(Contact $contact, Debt $debt)
{
$debt->delete();

$contact->events()->forObject($debt)->get()->each->delete();

return redirect()->route('people.show', $contact)
->with('success', trans('people.debt_delete_success'));
}
Expand Down
3 changes: 0 additions & 3 deletions app/Http/Controllers/Contacts/GiftsController.php
Expand Up @@ -140,7 +140,6 @@ public function update(GiftsRequest $request, Contact $contact, Gift $gift)
public function destroy(Contact $contact, Gift $gift)
{
$gift->delete();
$contact->events()->forObject($gift)->get()->each->delete();
}

/**
Expand Down Expand Up @@ -179,8 +178,6 @@ public function updateOrCreate(GiftsRequest $request, Contact $contact, Gift $gi
$gift->save();
}

$contact->logEvent('gift', $gift->id, 'create');

return $gift;
}
}
4 changes: 0 additions & 4 deletions app/Http/Controllers/Contacts/IntroductionsController.php
Expand Up @@ -65,8 +65,6 @@ public function update(IntroductionsRequest $request, Contact $contact)

$contact->save();

$contact->logEvent('contact', $contact->id, 'update');

return redirect()->route('people.show', $contact)
->with('success', trans('people.introductions_update_success'));
}
Expand All @@ -82,8 +80,6 @@ public function destroy(Contact $contact, Gift $gift)
{
$gift->delete();

$contact->events()->forObject($gift)->get()->each->delete();

return redirect()->route('people.show', $contact)
->with('success', trans('people.gifts_delete_success'));
}
Expand Down
12 changes: 1 addition & 11 deletions app/Http/Controllers/Contacts/NotesController.php
Expand Up @@ -42,14 +42,10 @@ public function get(Contact $contact)
*/
public function store(NotesRequest $request, Contact $contact)
{
$note = $contact->notes()->create([
return $contact->notes()->create([
'account_id' => auth()->user()->account_id,
'body' => $request->get('body'),
]);

$contact->logEvent('note', $note->id, 'create');

return $note;
}

public function toggle(NoteToggleRequest $request, Contact $contact, Note $note)
Expand All @@ -63,8 +59,6 @@ public function toggle(NoteToggleRequest $request, Contact $contact, Note $note)
$note->favorited_at = now();
}

$contact->logEvent('note', $note->id, 'update');

$note->save();
}

Expand All @@ -85,8 +79,6 @@ public function update(NotesRequest $request, Contact $contact, Note $note)
+ ['account_id' => $contact->account_id]
);

$contact->logEvent('note', $note->id, 'update');

return $note;
}

Expand All @@ -100,7 +92,5 @@ public function update(NotesRequest $request, Contact $contact, Note $note)
public function destroy(Contact $contact, Note $note)
{
$note->delete();

$contact->events()->forObject($note)->get()->each->delete();
}
}
6 changes: 0 additions & 6 deletions app/Http/Controllers/Contacts/RemindersController.php
Expand Up @@ -56,8 +56,6 @@ public function store(RemindersRequest $request, Contact $contact)

$reminder->scheduleNotifications();

$contact->logEvent('reminder', $reminder->id, 'create');

return redirect()->route('people.show', $contact)
->with('success', trans('people.reminders_create_success'));
}
Expand Down Expand Up @@ -112,8 +110,6 @@ public function update(RemindersRequest $request, Contact $contact, Reminder $re
$reminder->purgeNotifications();
$reminder->scheduleNotifications();

$contact->logEvent('reminder', $reminder->id, 'update');

return redirect()->route('people.show', $contact)
->with('success', trans('people.reminders_update_success'));
}
Expand All @@ -133,8 +129,6 @@ public function destroy(Contact $contact, Reminder $reminder)
$reminder->purgeNotifications();
$reminder->delete();

$contact->events()->forObject($reminder)->get()->each->delete();

return redirect()->route('people.show', $contact)
->with('success', trans('people.reminders_delete_success'));
}
Expand Down
10 changes: 1 addition & 9 deletions app/Http/Controllers/Contacts/TasksController.php
Expand Up @@ -38,15 +38,11 @@ public function get(Contact $contact)
*/
public function store(TasksRequest $request, Contact $contact)
{
$task = $contact->tasks()->create([
return $contact->tasks()->create([
'account_id' => auth()->user()->account_id,
'title' => $request->get('title'),
'description' => ($request->get('description') == '' ? null : $request->get('description')),
]);

$contact->logEvent('task', $task->id, 'create');

return $task;
}

/**
Expand All @@ -60,8 +56,6 @@ public function update(TasksRequest $request, Contact $contact, Task $task)
'completed' => $request->get('completed'),
]);

$contact->logEvent('task', $task->id, 'update');

return $task;
}

Expand All @@ -76,8 +70,6 @@ public function toggle(TaskToggleRequest $request, Contact $contact, Task $task)
$task->completed_at = now();
}

$contact->logEvent('task', $task->id, 'update');

$task->save();
}

Expand Down
4 changes: 0 additions & 4 deletions app/Http/Controllers/ContactsController.php
Expand Up @@ -148,8 +148,6 @@ public function store(Request $request)
$contact->setAvatarColor();
$contact->save();

$contact->logEvent('contact', $contact->id, 'create');

// Did the user press "Save" or "Submit and add another person"
if (! is_null($request->get('save'))) {
return redirect()->route('people.show', $contact);
Expand Down Expand Up @@ -347,8 +345,6 @@ public function update(Request $request, Contact $contact)
break;
}

$contact->logEvent('contact', $contact->id, 'update');

dispatch(new ResizeAvatars($contact));

$contact->updateGravatar();
Expand Down
10 changes: 0 additions & 10 deletions app/Models/Account/Account.php
Expand Up @@ -112,16 +112,6 @@ public function gifts()
return $this->hasMany(Gift::class);
}

/**
* Get the event records associated with the account.
*
* @return HasMany
*/
public function events()
{
return $this->hasMany(Event::class)->orderBy('created_at', 'desc');
}

/**
* Get the note records associated with the account.
*
Expand Down
54 changes: 0 additions & 54 deletions app/Models/Account/Event.php

This file was deleted.

0 comments on commit b337226

Please sign in to comment.