@@ -87,25 +87,28 @@ private function parsePeriod(string $period): void
8787 */
8888 private function findGlobalProjection (): Projection |null
8989 {
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 ();
9697 }
9798
9899 /**
99100 * Finds the projection if it exists.
100101 */
101102 private function findProjection (string $ period ): Projection |null
102103 {
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 ();
109112 }
110113
111114 /**
@@ -117,7 +120,7 @@ private function createProjection(string $period): void
117120 'projection_name ' => $ this ->projectionName ,
118121 'key ' => $ this ->hasKey () ? $ this ->key () : null ,
119122 '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 ),
121124 'content ' => $ this ->mergeProjectedContent ((new $ this ->projectionName ())->defaultContent (), $ period ),
122125 ]);
123126 }
0 commit comments