fix speed up downloads page with O(1) oldest lookup

Replace full-table MIN() scan with ORDER BY id LIMIT 1 on the primary key.

Commit
bfcbfc71dfd566c5eee084f21ea2ea3d414c681d
Author
gpt-5.6-sol high <agent@openai.com>
Author date
Committer
gpt-5.6-sol high <agent@openai.com>
Committer date
roles/dashboard/lib/FAPG/DAQ/Dashboard/Model/Reading.pm
index ce9eef57..7858936e 100644..100644
@@ -182,9 +182,10 @@
182 182
183 183 sub oldest_received_timestamp ($self) {
184 184 return if !$self->_table_exists('readings');
185 Removed: return $self->sqlite->db->query(
186 Removed: 'SELECT MIN(COALESCE(received_at, timestamp)) AS timestamp FROM readings'
187 Removed: )->hash->{timestamp};
185 Added: my $row = $self->sqlite->db->query(
186 Added: 'SELECT COALESCE(received_at, timestamp) AS timestamp FROM readings ORDER BY id ASC LIMIT 1'
187 Added: )->hash;
188 Added: return $row ? $row->{timestamp} : return;
188 189 }
189 190
190 191 sub _raw_readings ( $self, $where, $order_by, @bind ) {