Skip to content

Commit c27a2d4

Browse files
committed
make created be only set from us
Metabase reports come with a "creation" time. Some of the test reporters are sending us reports from hours or days in the past. Since we use this created time to create feeds, we need to know when we received the report, not when it was created on the user's machine. That probably means we should rename this column to "reported" or "submitted" or "received", but for now this will be fine Fixes #19
1 parent b34389d commit c27a2d4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/CPAN/Testers/Schema/Result/TestReport.pm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ primary_column 'id', {
4646
The ISO8601 date/time of when the report was inserted into the database.
4747
Will default to the current time.
4848
49+
The JSON report also contains a C<created> field. This is the date/time
50+
that the report was created on the reporter's machine.
51+
4952
=cut
5053

5154
column created => {
@@ -98,12 +101,16 @@ object and should not be called directly.
98101
This is overridden to provide sane defaults for the C<id> and C<created>
99102
fields.
100103
104+
B<NOTE:> You should not supply a C<created> unless you are creating
105+
reports in the past. Reports created in the past will be hidden from
106+
many feeds, and may cause failures to not be reported to authors.
107+
101108
=cut
102109

103110
sub new( $class, $attrs ) {
104111
$attrs->{report}{id} = $attrs->{id} ||= Data::UUID->new->create_str;
105112
$attrs->{created} ||= DateTime->now( time_zone => 'UTC' );
106-
$attrs->{report}{created} = $attrs->{created}->datetime . 'Z';
113+
$attrs->{report}{created} ||= $attrs->{created}->datetime . 'Z';
107114
return $class->next::method( $attrs );
108115
};
109116

0 commit comments

Comments
 (0)