|
171 | 171 | Date::setTestNow('2000-01-01 02:23:59'); // Bucket: 2000-01-01 00:00:00
|
172 | 172 | Datum::record('foo', 'xxxx', 1)->count();
|
173 | 173 | Datum::ingest();
|
174 |
| - expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->period())->count()))->toBe(1); |
| 174 | + expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->value)->count()))->toBe(1); |
175 | 175 |
|
176 | 176 | Date::setTestNow('2000-04-01 02:24:00'); // Bucket: 2000-04-01 00:00:00
|
177 | 177 | Datum::record('foo', 'xxxx', 1)->count();
|
178 | 178 | Datum::ingest();
|
179 |
| - expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->period())->count()))->toBe(2); |
| 179 | + expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->value)->count()))->toBe(2); |
180 | 180 |
|
181 | 181 | Datum::stopRecording();
|
182 | 182 | Date::setTestNow('2000-12-30 23:59:59'); // 1 second before the oldest bucket become irrelevant.
|
183 | 183 | App::make(DatabaseStorage::class)->trim();
|
184 |
| - expect(DB::table('datum_aggregates')->where('period', $period->period())->count())->toBe(2); |
| 184 | + expect(DB::table('datum_aggregates')->where('period', $period->value)->count())->toBe(2); |
185 | 185 |
|
186 | 186 | Date::setTestNow('2000-12-31 00:00:00'); // The second the oldest bucket become irrelevant.
|
187 | 187 | App::make(DatabaseStorage::class)->trim();
|
188 |
| - expect(DB::table('datum_aggregates')->where('period', $period->period())->count())->toBe(1); |
| 188 | + expect(DB::table('datum_aggregates')->where('period', $period->value)->count())->toBe(1); |
189 | 189 | });
|
190 | 190 |
|
191 | 191 | it('trims aggregates once the half year bucket is no longer relevant', function () {
|
|
194 | 194 | Date::setTestNow('2000-01-01 02:23:59'); // Bucket: 2000-01-01 00:00:00
|
195 | 195 | Datum::record('foo', 'xxxx', 1)->count();
|
196 | 196 | Datum::ingest();
|
197 |
| - expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->period())->count()))->toBe(1); |
| 197 | + expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->value)->count()))->toBe(1); |
198 | 198 |
|
199 | 199 | Date::setTestNow('2000-07-01 02:24:00'); // Bucket: 2000-07-01 00:00:00
|
200 | 200 | Datum::record('foo', 'xxxx', 1)->count();
|
201 | 201 | Datum::ingest();
|
202 |
| - expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->period())->count()))->toBe(2); |
| 202 | + expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->value)->count()))->toBe(2); |
203 | 203 |
|
204 | 204 | Datum::stopRecording();
|
205 | 205 | Date::setTestNow('2000-12-30 23:59:59'); // 1 second before the oldest bucket become irrelevant.
|
206 | 206 | App::make(DatabaseStorage::class)->trim();
|
207 |
| - expect(DB::table('datum_aggregates')->where('period', $period->period())->count())->toBe(2); |
| 207 | + expect(DB::table('datum_aggregates')->where('period', $period->value)->count())->toBe(2); |
208 | 208 |
|
209 | 209 | Date::setTestNow('2000-12-31 00:00:00'); // The second the oldest bucket become irrelevant.
|
210 | 210 | App::make(DatabaseStorage::class)->trim();
|
211 |
| - expect(DB::table('datum_aggregates')->where('period', $period->period())->count())->toBe(1); |
| 211 | + expect(DB::table('datum_aggregates')->where('period', $period->value)->count())->toBe(1); |
212 | 212 | });
|
213 | 213 |
|
214 | 214 | it('trims aggregates once the year bucket is no longer relevant', function () {
|
|
217 | 217 | Date::setTestNow('2000-01-01 02:23:59'); // Bucket: 2000-01-01 00:00:00
|
218 | 218 | Datum::record('foo', 'xxxx', 1)->count();
|
219 | 219 | Datum::ingest();
|
220 |
| - expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->period())->count()))->toBe(1); |
| 220 | + expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->value)->count()))->toBe(1); |
221 | 221 |
|
222 | 222 | Date::setTestNow('2001-01-01 02:24:00'); // Bucket: 2000-07-01 00:00:00
|
223 | 223 | Datum::record('foo', 'xxxx', 1)->count();
|
224 | 224 | Datum::ingest();
|
225 |
| - expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->period())->count()))->toBe(2); |
| 225 | + expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->value)->count()))->toBe(2); |
226 | 226 |
|
227 | 227 | Datum::stopRecording();
|
228 | 228 | Date::setTestNow('2009-12-28 23:59:59'); // 1 second before the oldest bucket become irrelevant.
|
229 | 229 | App::make(DatabaseStorage::class)->trim();
|
230 |
| - expect(DB::table('datum_aggregates')->where('period', $period->period())->count())->toBe(2); |
| 230 | + expect(DB::table('datum_aggregates')->where('period', $period->value)->count())->toBe(2); |
231 | 231 |
|
232 | 232 | Date::setTestNow('2009-12-29 00:00:00'); // The second the oldest bucket become irrelevant.
|
233 | 233 | App::make(DatabaseStorage::class)->trim();
|
234 |
| - expect(DB::table('datum_aggregates')->where('period', $period->period())->count())->toBe(1); |
| 234 | + expect(DB::table('datum_aggregates')->where('period', $period->value)->count())->toBe(1); |
235 | 235 | });
|
236 | 236 |
|
237 | 237 | it('trims aggregates once the tax year bucket is no longer relevant', function () {
|
|
240 | 240 | Date::setTestNow('2000-01-01 02:23:59'); // Bucket: 1999-04-01 00:00:00
|
241 | 241 | Datum::record('foo', 'xxxx', 1)->count();
|
242 | 242 | Datum::ingest();
|
243 |
| - expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->period())->count()))->toBe(1); |
| 243 | + expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->value)->count()))->toBe(1); |
244 | 244 |
|
245 | 245 | Date::setTestNow('2001-01-01 02:24:00'); // Bucket: 2000-04-01 00:00:00
|
246 | 246 | Datum::record('foo', 'xxxx', 1)->count();
|
247 | 247 | Datum::ingest();
|
248 |
| - expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->period())->count()))->toBe(2); |
| 248 | + expect(Datum::ignore(fn () => DB::table('datum_aggregates')->where('period', $period->value)->count()))->toBe(2); |
249 | 249 |
|
250 | 250 | Datum::stopRecording();
|
251 | 251 | Date::setTestNow('2009-03-23 23:59:59'); // 1 second before the oldest bucket become irrelevant.
|
252 | 252 | App::make(DatabaseStorage::class)->trim();
|
253 |
| - expect(DB::table('datum_aggregates')->where('period', $period->period())->count())->toBe(2); |
| 253 | + expect(DB::table('datum_aggregates')->where('period', $period->value)->count())->toBe(2); |
254 | 254 |
|
255 | 255 | Date::setTestNow('2009-03-24 00:00:00'); // The second the oldest bucket become irrelevant.
|
256 | 256 | App::make(DatabaseStorage::class)->trim();
|
257 |
| - expect(DB::table('datum_aggregates')->where('period', $period->period())->count())->toBe(1); |
| 257 | + expect(DB::table('datum_aggregates')->where('period', $period->value)->count())->toBe(1); |
258 | 258 | });
|
0 commit comments