MT#15477 topup_log resultset

+removed timestamp inflation fixup code from
all resultsets
+resultset renamed to topup_logS

Change-Id: Ic97aad9ea2c75e67e93a4ad6e48e55395786511a
changes/18/2818/5
Rene Krenn 10 years ago
parent 33142b4570
commit 09a386f82f

@ -170,6 +170,20 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"before_topup_log",
"NGCP::Schema::Result::topup_logs",
{ 'foreign.profile_before_id' => 'self.id' },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"after_topup_log",
"NGCP::Schema::Result::topup_logs",
{ 'foreign.profile_after_id' => 'self.id' },
{ cascade_copy => 0, cascade_delete => 0 },
);
sub TO_JSON {
my ($self) = @_;
return {

@ -140,9 +140,9 @@ __PACKAGE__->add_columns(
"call_code",
{ data_type => "char", is_nullable => 0, size => 3 },
"init_time",
{ data_type => "decimal", is_nullable => 0, size => [13, 3] },
{ data_type => "decimal", is_nullable => 0, size => [13, 3], inflate_datetime => 'epoch_milli' },
"start_time",
{ data_type => "decimal", is_nullable => 0, size => [13, 3] },
{ data_type => "decimal", is_nullable => 0, size => [13, 3], inflate_datetime => 'epoch_milli' },
"duration",
{ data_type => "decimal", is_nullable => 0, size => [13, 3] },
"call_id",
@ -241,14 +241,6 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id");
for my $col (qw/init_time start_time/) {
if(__PACKAGE__->has_column($col)) {
__PACKAGE__->remove_column($col);
__PACKAGE__->add_column($col =>
{ data_type => "decimal", is_nullable => 0, size => [13, 3], inflate_datetime => 'epoch_milli' }
);
}
}
__PACKAGE__->belongs_to(
"source_customer_billing_zones_history",
"NGCP::Schema::Result::billing_zones_history",

@ -96,6 +96,20 @@ __PACKAGE__->belongs_to(
},
);
__PACKAGE__->has_many(
"before_topup_log",
"NGCP::Schema::Result::topup_logs",
{ 'foreign.contract_balance_before_id' => 'self.id' },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"after_topup_log",
"NGCP::Schema::Result::topup_logs",
{ 'foreign.contract_balance_after_id' => 'self.id' },
{ cascade_copy => 0, cascade_delete => 0 },
);
sub TO_JSON {
my ($self) = @_;
return {

@ -265,6 +265,13 @@ __PACKAGE__->belongs_to(
},
);
__PACKAGE__->has_many(
"topup_log",
"NGCP::Schema::Result::topup_logs",
{ 'foreign.contract_id' => 'self.id' },
{ cascade_copy => 0, cascade_delete => 0 },
);
sub TO_JSON {
my ($self) = @_;
return {

@ -34,7 +34,7 @@ __PACKAGE__->add_columns(
is_nullable => 0,
},
"timestamp",
{ data_type => "decimal", is_nullable => 0, size => [13, 3] },
{ data_type => "decimal", is_nullable => 0, size => [13, 3], inflate_datetime => 'epoch_milli' },
"username",
{ data_type => "varchar", is_nullable => 1, size => 127 },
"content_format",
@ -50,15 +50,6 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id");
for my $col (qw/timestamp/) {
if(__PACKAGE__->has_column($col)) {
__PACKAGE__->remove_column($col);
__PACKAGE__->add_column($col =>
{ data_type => "decimal", is_nullable => 0, size => [13, 3], inflate_datetime => 'epoch_milli' }
);
}
}
sub TO_JSON {
my ($self) = @_;
return {

@ -27,7 +27,7 @@ __PACKAGE__->add_columns(
"callee",
{ data_type => "varchar", is_nullable => 0, size => 255 },
"start_time",
{ data_type => "decimal", is_nullable => 0, size => [13,3] },
{ data_type => "decimal", is_nullable => 0, size => [13,3], inflate_datetime => 'epoch_milli' },
"duration",
{ data_type => "decimal", is_nullable => 0, size => [13,3] },
"source",
@ -43,15 +43,6 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id");
for my $col (qw/start_time/) {
if(__PACKAGE__->has_column($col)) {
__PACKAGE__->remove_column($col);
__PACKAGE__->add_column($col =>
{ data_type => "decimal", is_nullable => 0, size => [13, 3], inflate_datetime => 'epoch_milli' }
);
}
}
__PACKAGE__->add_unique_constraint("mcid_callid_idx", ["call_id"]);
__PACKAGE__->belongs_to(

@ -21,7 +21,7 @@ __PACKAGE__->add_columns(
is_nullable => 0,
},
"timestamp",
{ data_type => "decimal", is_nullable => 0, size => [17, 6] },
{ data_type => "decimal", is_nullable => 0, size => [17, 6], inflate_datetime => 'epoch_micro' },
"protocol",
{
data_type => "enum",
@ -74,15 +74,6 @@ __PACKAGE__->has_many(
__PACKAGE__->set_primary_key("id");
for my $col (qw/timestamp/) {
if(__PACKAGE__->has_column($col)) {
__PACKAGE__->remove_column($col);
__PACKAGE__->add_column($col =>
{ data_type => "decimal", is_nullable => 0, size => [17, 6], inflate_datetime => 'epoch_micro' }
);
}
}
sub TO_JSON {
my ($self) = @_;
return {

@ -175,6 +175,20 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"before_topup_log",
"NGCP::Schema::Result::topup_log",
{ 'foreign.package_before_id' => 'self.id' },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"after_topup_log",
"NGCP::Schema::Result::topup_log",
{ 'foreign.package_after_id' => 'self.id' },
{ cascade_copy => 0, cascade_delete => 0 },
);
sub _join_condition {
my ($args,$discriminator) = @_;
return { #[{

@ -61,6 +61,13 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"topup_log",
"NGCP::Schema::Result::topup_logs",
{ 'foreign.subscriber_id' => 'self.id' },
{ cascade_copy => 0, cascade_delete => 0 },
);
sub TO_JSON {
my ($self) = @_;
return {

@ -0,0 +1,196 @@
package NGCP::Schema::Result::topup_logs;
use Scalar::Util qw(blessed);
use parent 'DBIx::Class::Core';
our $VERSION = '2.007';
__PACKAGE__->load_components(
"InflateColumn::DateTime",
"Helper::Row::ToJSON",
"+NGCP::Schema::InflateColumn::DateTime::EpochMilli");
__PACKAGE__->table("billing.topup_log");
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"username",
{ data_type => "varchar", is_nullable => 1, size => 127 },
"timestamp",
{ data_type => "decimal", is_nullable => 0, size => [13, 3], inflate_datetime => 'epoch_milli' },
"type",
{
data_type => "enum",
extra => { list => ["cash", "voucher"] },
is_nullable => 0,
},
"outcome",
{
data_type => "enum",
extra => { list => ["ok", "failed"] },
is_nullable => 0,
},
"message",
{ data_type => "varchar", is_nullable => 1, size => 255 },
"subscriber_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 1,
},
"contract_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 1,
},
"amount",
{ data_type => "double precision", default_value => 0, is_nullable => 1 },
"voucher_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 1,
},
"cash_balance_before",
{ data_type => "double precision", default_value => 0, is_nullable => 1 },
"cash_balance_after",
{ data_type => "double precision", default_value => 0, is_nullable => 1 },
"package_before_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 1,
},
"package_after_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 1,
},
"profile_before_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 1,
},
"profile_after_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 1,
},
"lock_level_before",
{ data_type => "tinyint", extra => { unsigned => 1 }, is_nullable => 1 },
"lock_level_after",
{ data_type => "tinyint", extra => { unsigned => 1 }, is_nullable => 1 },
"contract_balance_before_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 1,
},
"contract_balance_after_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 1,
},
"request_token",
{ data_type => "varchar", is_nullable => 1, size => 255 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to(
"subscriber",
"NGCP::Schema::Result::voip_subscribers",
{ "foreign.id" => "self.subscriber_id" },
{ is_deferrable => 1, join_type => "LEFT", on_delete => "SET NULL", on_update => "CASCADE" },
);
__PACKAGE__->belongs_to(
"contract",
"NGCP::Schema::Result::contracts",
{ "foreign.id" => "self.contract_id" },
{ is_deferrable => 1, join_type => "LEFT", on_delete => "SET NULL", on_update => "CASCADE" },
);
__PACKAGE__->belongs_to(
"voucher",
"NGCP::Schema::Result::vouchers",
{ "foreign.id" => "self.voucher_id" },
{ is_deferrable => 1, join_type => "LEFT", on_delete => "SET NULL", on_update => "CASCADE" },
);
__PACKAGE__->belongs_to(
"old_package",
"NGCP::Schema::Result::profile_packages",
{ "foreign.id" => "self.package_before_id" },
{ is_deferrable => 1, join_type => "LEFT", on_delete => "SET NULL", on_update => "CASCADE" },
);
__PACKAGE__->belongs_to(
"new_package",
"NGCP::Schema::Result::profile_packages",
{ "foreign.id" => "self.package_after_id" },
{ is_deferrable => 1, join_type => "LEFT", on_delete => "SET NULL", on_update => "CASCADE" },
);
__PACKAGE__->belongs_to(
"old_profile",
"NGCP::Schema::Result::billing_profiles",
{ "foreign.id" => "self.profile_before_id" },
{ is_deferrable => 1, join_type => "LEFT", on_delete => "SET NULL", on_update => "CASCADE" },
);
__PACKAGE__->belongs_to(
"new_profile",
"NGCP::Schema::Result::billing_profiles",
{ "foreign.id" => "self.profile_after_id" },
{ is_deferrable => 1, join_type => "LEFT", on_delete => "SET NULL", on_update => "CASCADE" },
);
__PACKAGE__->belongs_to(
"old_contract_balance",
"NGCP::Schema::Result::contract_balances",
{ "foreign.id" => "self.contract_balance_before_id" },
{ is_deferrable => 1, join_type => "LEFT", on_delete => "SET NULL", on_update => "CASCADE" },
);
__PACKAGE__->belongs_to(
"new_contract_balance",
"NGCP::Schema::Result::contract_balances",
{ "foreign.id" => "self.contract_balance_after_id" },
{ is_deferrable => 1, join_type => "LEFT", on_delete => "SET NULL", on_update => "CASCADE" },
);
sub TO_JSON {
my ($self) = @_;
return {
map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method }
};
}
1;

@ -62,14 +62,15 @@ __PACKAGE__->belongs_to(
},
);
for my $col (qw/origtime/) {
if(__PACKAGE__->has_column($col)) {
__PACKAGE__->remove_column($col);
__PACKAGE__->add_column($col =>
{ data_type => "varchar", is_nullable => 0, inflate_datetime => 'epoch_string' }
);
}
}
#is_nullable => 0 is changed here! why?
#for my $col (qw/origtime/) {
# if(__PACKAGE__->has_column($col)) {
# __PACKAGE__->remove_column($col);
# __PACKAGE__->add_column($col =>
# { data_type => "varchar", is_nullable => 0, inflate_datetime => 'epoch_string' }
# );
# }
#}
sub TO_JSON {
my ($self) = @_;

@ -121,6 +121,13 @@ __PACKAGE__->belongs_to(
},
);
__PACKAGE__->has_many(
"topup_log",
"NGCP::Schema::Result::topup_logs",
{ 'foreign.voucher_id' => 'self.id' },
{ cascade_copy => 0, cascade_delete => 0 },
);
sub TO_JSON {
my ($self) = @_;
return {

Loading…
Cancel
Save