| 1 | package Rapi::Blog::DB::ResultSet::PreauthActionEvent; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Moo; | ||
| 7 | extends 'DBIx::Class::ResultSet'; | ||
| 8 | |||
| 9 | use RapidApp::Util ':all'; | ||
| 10 | use Rapi::Blog::Util; | ||
| 11 | |||
| 12 | sub schema { (shift)->result_source->schema } | ||
| 13 | |||
| 14 | sub create_with_request { | ||
| 15 | my ($self, $request, $cr) = @_; | ||
| 16 | $cr ||= {}; | ||
| 17 | |||
| 18 | die "->create_with_hit(): hit/id already set!" if ($cr->{hit_id} || $cr->{hit}); | ||
| 19 | |||
| 20 | my $Hit = $self->schema->resultset('Hit')->create_from_request({},$request); | ||
| 21 | $self->create_with_hit($Hit,$cr) | ||
| 22 | } | ||
| 23 | |||
| 24 | |||
| 25 | sub create_with_hit { | ||
| 26 | my ($self, $Hit, $cr) = @_; | ||
| 27 | $cr ||= {}; | ||
| 28 | |||
| 29 | die "->create_with_hit(): hit/id already set!" if ($cr->{hit_id} || $cr->{hit}); | ||
| 30 | |||
| 31 | $cr->{hit} = $Hit; | ||
| 32 | $cr->{ts} ||= $Hit->get_column('ts'); | ||
| 33 | |||
| 34 | $self->create( $cr ) | ||
| 35 | } | ||
| 36 | |||
| 37 | |||
| 38 | 1; |