• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Freegle / Iznik / 11933

10 May 2026 06:13AM UTC coverage: 72.889% (+0.05%) from 72.843%
11933

push

circleci

web-flow
Merge pull request #405 from Freegle/feat/batch-migrate-non-email-jobs

feat(batch): migrate non-email cron scripts to Laravel artisan commands

13854 of 20887 branches covered (66.33%)

Branch coverage included in aggregate %.

789 of 1004 new or added lines in 21 files covered. (78.59%)

36 existing lines in 3 files now uncovered.

102807 of 139167 relevant lines covered (73.87%)

22.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.04
/iznik-batch/app/Services/CommunityEventService.php
1
<?php
2

3
namespace App\Services;
4

5
use Illuminate\Support\Facades\DB;
6

7
class CommunityEventService
8
{
9
    public function findByExternalId(string $externalId): ?object
8✔
10
    {
11
        return DB::table('communityevents')->where('externalid', $externalId)->first();
8✔
12
    }
13

14
    public function createEvent(
5✔
15
        ?int $userId,
16
        string $title,
17
        string $location,
18
        ?string $contactName,
19
        ?string $contactPhone,
20
        ?string $contactEmail,
21
        ?string $contactUrl,
22
        ?string $description,
23
        ?string $externalId = null
24
    ): int {
25
        DB::table('communityevents')->insert([
5✔
26
            'userid'       => $userId,
5✔
27
            'pending'      => 1,
5✔
28
            'title'        => $title,
5✔
29
            'location'     => $location,
5✔
30
            'contactname'  => $contactName,
5✔
31
            'contactphone' => $contactPhone,
5✔
32
            'contactemail' => $contactEmail,
5✔
33
            'contacturl'   => $contactUrl,
5✔
34
            'description'  => $description,
5✔
35
            'externalid'   => $externalId,
5✔
36
        ]);
5✔
37

38
        return (int) DB::getPdo()->lastInsertId();
5✔
39
    }
40

41
    public function updateEvent(int $id, array $attributes): void
2✔
42
    {
43
        DB::table('communityevents')->where('id', $id)->update($attributes);
2✔
44
    }
45

46
    public function addDate(int $eventId, string $start, string $end): void
6✔
47
    {
48
        if (strtotime($end) < strtotime($start)) {
6✔
NEW
49
            $end = date('Y-m-d H:i:s', strtotime($start) + 3600);
×
50
        }
51

52
        DB::table('communityevents_dates')->insert([
6✔
53
            'eventid' => $eventId,
6✔
54
            'start'   => $start,
6✔
55
            'end'     => $end,
6✔
56
        ]);
6✔
57
    }
58

59
    public function removeDates(int $eventId): void
2✔
60
    {
61
        DB::table('communityevents_dates')->where('eventid', $eventId)->delete();
2✔
62
    }
63

64
    public function addGroup(int $eventId, int $groupId): void
4✔
65
    {
66
        DB::table('communityevents_groups')->insertOrIgnore([
4✔
67
            'eventid' => $eventId,
4✔
68
            'groupid' => $groupId,
4✔
69
        ]);
4✔
70
        // V1 also creates a Newsfeed entry and pushes notifications to group mods here,
71
        // but events are pending=1 so they're not visible to users until a mod approves them.
72
        // Those side effects are omitted; the mod will see the event in their pending queue.
73
    }
74

75
    public function markDeleted(int $eventId): void
2✔
76
    {
77
        DB::table('communityevents')->where('id', $eventId)->update(['deleted' => 1]);
2✔
78
    }
79

80
    public function getUpcomingByExternalIdPrefix(string $prefix, string $fromDate): array
11✔
81
    {
82
        return DB::table('communityevents')
11✔
83
            ->join('communityevents_dates', 'communityevents.id', '=', 'communityevents_dates.eventid')
11✔
84
            ->where('communityevents.externalid', 'LIKE', $prefix . '%')
11✔
85
            ->where('communityevents_dates.start', '>=', $fromDate)
11✔
86
            ->select('communityevents.id', 'communityevents.externalid')
11✔
87
            ->get()
11✔
88
            ->toArray();
11✔
89
    }
90

91
    public function getUpcomingByExternalIdSubstring(string $substring, string $fromDate): array
5✔
92
    {
93
        return DB::table('communityevents')
5✔
94
            ->join('communityevents_dates', 'communityevents.id', '=', 'communityevents_dates.eventid')
5✔
95
            ->where('communityevents.externalid', 'LIKE', '%' . $substring . '%')
5✔
96
            ->where('communityevents_dates.start', '>=', $fromDate)
5✔
97
            ->select('communityevents.id', 'communityevents.externalid')
5✔
98
            ->get()
5✔
99
            ->toArray();
5✔
100
    }
101
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc