@@ -87,25 +87,28 @@ private function parsePeriod(string $period): void
87
87
*/
88
88
private function findGlobalProjection (): Projection |null
89
89
{
90
- return Projection::firstWhere ([
91
- ['projection_name ' , $ this ->projectionName ],
92
- ['key ' , $ this ->hasKey () ? $ this ->key () : null ],
93
- ['period ' , '* ' ],
94
- ['start_date ' , null ],
95
- ]);
90
+ return Projection::whereRaw ('projection_name = ? ' , [$ this ->projectionName ])
91
+ ->where ([
92
+ ['key ' , $ this ->hasKey () ? $ this ->key () : null ],
93
+ ['period ' , '* ' ],
94
+ ['start_date ' , null ],
95
+ ])
96
+ ->first ();
96
97
}
97
98
98
99
/**
99
100
* Finds the projection if it exists.
100
101
*/
101
102
private function findProjection (string $ period ): Projection |null
102
103
{
103
- return Projection::firstWhere ([
104
- ['projection_name ' , $ this ->projectionName ],
105
- ['key ' , $ this ->hasKey () ? $ this ->key () : null ],
106
- ['period ' , $ period ],
107
- ['start_date ' , app (TimeSeries::class)->resolveFloorDate ($ this ->projectedModel ->created_at , $ period )],
108
- ]);
104
+ return Projection::whereRaw ('projection_name = ? ' , [$ this ->projectionName ])
105
+ ->where ([
106
+ ['key ' , $ this ->hasKey () ? $ this ->key () : null ],
107
+ ['period ' , $ period ],
108
+ ['start_date ' , app (TimeSeries::class)->resolveFloorDate ($ this ->projectedModel ->updated_at , $ period ),
109
+ ],
110
+ ])
111
+ ->first ();
109
112
}
110
113
111
114
/**
@@ -117,7 +120,7 @@ private function createProjection(string $period): void
117
120
'projection_name ' => $ this ->projectionName ,
118
121
'key ' => $ this ->hasKey () ? $ this ->key () : null ,
119
122
'period ' => $ period ,
120
- 'start_date ' => app (TimeSeries::class)->resolveFloorDate ($ this ->projectedModel ->created_at , $ period ),
123
+ 'start_date ' => app (TimeSeries::class)->resolveFloorDate ($ this ->projectedModel ->updated_at , $ period ),
121
124
'content ' => $ this ->mergeProjectedContent ((new $ this ->projectionName ())->defaultContent (), $ period ),
122
125
]);
123
126
}
0 commit comments