Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:languages:perl:CPAN-D
perl-DBIx-Class-Report
perl-DBIx-Class-Report.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File perl-DBIx-Class-Report.spec of Package perl-DBIx-Class-Report
# # spec file for package perl-DBIx-Class-Report # # Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: perl-DBIx-Class-Report Version: 0.03 Release: 0 %define cpan_name DBIx-Class-Report Summary: Ad-Hoc reporting from DBIx::Class License: Artistic-2.0 Group: Development/Libraries/Perl Url: https://metacpan.org/release/%{cpan_name} Source0: https://cpan.metacpan.org/authors/id/O/OV/OVID/%{cpan_name}-%{version}.tar.gz BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(DBD::SQLite) >= 1.42 BuildRequires: perl(DBIx::Class) >= 0.08210 BuildRequires: perl(DBIx::Class::Schema::Loader) >= 0.07037 BuildRequires: perl(Moose) >= 2 BuildRequires: perl(Test::Most) >= 0.33 BuildRequires: perl(namespace::autoclean) >= 0.20 Requires: perl(DBIx::Class) >= 0.08210 Requires: perl(Moose) >= 2 Requires: perl(namespace::autoclean) >= 0.20 %{perl_requires} %description *NOTE:* Experimental ALPHA code. Sometimes it's nice to be able to run ad-hoc SQL and get back a DBIx::Class resultset. We can use DBIx::Class::ResultSource::View, but that requires we hard-code our SQL ahead of time. 'DBIx::Class::Report' allows you to create your SQL on the fly and generate ad-hoc, read-only dbic resultsets which act just like normal dbic objects. my $sql = <<'SQL'; SELECT var.name, ce.event_type, count(*) FROM tracking_conversion_event ce JOIN tracking_visitor visitor ON visitor.tracking_visitor_id = ce.tracking_visitor_id JOIN tracking_version_variant curr ON curr.tracking_version_variant_id = visitor.tracking_version_variant_id JOIN tracking_version ver ON ver.tracking_version_id = curr.tracking_version_id JOIN tracking_variant var ON var.tracking_variant_id = curr.tracking_variant_id WHERE ver.tracking_id = ? AND ver.version = ? GROUP BY 1, 2 SQL my $events_per_name = DBIx::Class::Report->new( schema => $schema, sql => $sql, columns => [qw/name event_type total/], methods => { tracking_version => sub { my $self = shift; return $self->result_source->schema->resultset('TrackingVersion')->find($self->tracking_version_id); }, tracking_variant => sub { my $self = shift; return $self->result_source->schema->resultset('TrackingVersion')->find($self->tracking_variant_id); }, ); my $resultset = $events_per_name->fetch( $tracking_id, $version ); say $resultset->count; # yeah, it behaves just like a normal dbic resultset while ( my $result = $resultset->next ) { say $result->name; say $result->event_type; say $result->total; } Note that the 'methods' key installs methods in each returned result object. This allows us to neatly similate inflation or anthing else we need from a standard result object. %prep %setup -q -n %{cpan_name}-%{version} %build PERL_USE_UNSAFE_INC=1 perl Makefile.PL INSTALLDIRS=vendor make %{?_smp_mflags} %check make test %install %perl_make_install %perl_process_packlist %perl_gen_filelist %files -f %{name}.files %defattr(-,root,root,755) %doc Changes README %changelog
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor