api/v0: remove old model's remnants

This commit is contained in:
Lucas Gabriel Vuotto 2025-05-03 13:37:54 +00:00
parent 291775bb04
commit ad46c6ba85
11 changed files with 1 additions and 750 deletions

View file

@ -1,15 +1,12 @@
package Pooru::API::V0; package Pooru::API::V0;
use Mojo::Base "Mojolicious", -signatures; use Mojo::Base "Mojolicious", -signatures;
use DBD::SQLite::Constants ":dbd_sqlite_string_mode"; use DBI;
use DBIx::Migration; use DBIx::Migration;
use Pooru::Schema;
use Pooru::API::V0::Model::Media; use Pooru::API::V0::Model::Media;
use Pooru::API::V0::Model::Tags; use Pooru::API::V0::Model::Tags;
use DBI;
use constant { use constant {
"Pooru::API::V0::Model::Media::ROWS" => 12, "Pooru::API::V0::Model::Media::ROWS" => 12,
"Pooru::API::V0::Model::Media::SIMILAR_ROWS" => 6, "Pooru::API::V0::Model::Media::SIMILAR_ROWS" => 6,
@ -17,33 +14,6 @@ use constant {
"Pooru::API::V0::Model::Tags::SEARCH_ROWS" => 15, "Pooru::API::V0::Model::Tags::SEARCH_ROWS" => 15,
}; };
sub _search_opts ()
{
return {
Media => {
order_by => {-desc => "id"},
rows => 12,
},
TagCountView => {
order_by => [
{-desc => [qw(count kind_id)]},
{-asc => "name"},
],
rows => 1000,
},
TaggedMediaView_media => {
order_by => {-desc => "media_id"},
rows => 12,
},
TaggedMediaView_tags => {
order_by => [
{-desc => "tag_kind_id"},
{-asc => "tag_name"},
],
rows => 1000,
},
};
}
sub startup ($self) sub startup ($self)
{ {
@ -52,24 +22,6 @@ sub startup ($self)
my $config = $self->plugin("Config"); my $config = $self->plugin("Config");
$self->secrets($config->{secrets}); $self->secrets($config->{secrets});
$self->helper(schema => sub {
state $schema = Pooru::Schema->connect(
$config->{dsn},
undef,
undef,
{
sqlite_string_mode =>
DBD_SQLITE_STRING_MODE_UNICODE_STRICT,
on_connect_call => "use_foreign_keys",
}
);
});
$self->helper(pager => sub ($, $rs) {
return map +($_ => ($rs->pager->$_ and int($rs->pager->$_))),
qw(first_page previous_page current_page next_page
last_page);
});
DBIx::Migration->new({ DBIx::Migration->new({
dsn => $config->{dsn}, dsn => $config->{dsn},
dir => $self->app->home->child("migrations")->to_string, dir => $self->app->home->child("migrations")->to_string,

View file

@ -3,7 +3,6 @@ use Mojo::Base "Mojolicious::Controller", -signatures;
use List::Util qw(uniq); use List::Util qw(uniq);
my %search_opts = Pooru::API::V0::_search_opts->%*;
sub _list_no_tags ($self, $page) sub _list_no_tags ($self, $page)
{ {

View file

@ -1,7 +1,6 @@
package Pooru::API::V0::Controller::Tags; package Pooru::API::V0::Controller::Tags;
use Mojo::Base "Mojolicious::Controller", -signatures; use Mojo::Base "Mojolicious::Controller", -signatures;
my %search_opts = Pooru::API::V0::_search_opts->%*;
sub list ($self) sub list ($self)
{ {

View file

@ -1,96 +0,0 @@
use utf8;
package Pooru::Schema::Result::Kind;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Pooru::Schema::Result::Kind
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 TABLE: C<kind>
=cut
__PACKAGE__->table("kind");
=head1 ACCESSORS
=head2 id
data_type: 'text'
is_nullable: 0
size: 32
=head2 name
data_type: 'text'
is_nullable: 0
size: 256
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "text", is_nullable => 0, size => 32 },
"name",
{ data_type => "text", is_nullable => 0, size => 256 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<name_unique>
=over 4
=item * L</name>
=back
=cut
__PACKAGE__->add_unique_constraint("name_unique", ["name"]);
=head1 RELATIONS
=head2 tags
Type: has_many
Related object: L<Pooru::Schema::Result::Tag>
=cut
__PACKAGE__->has_many(
"tags",
"Pooru::Schema::Result::Tag",
{ "foreign.kind_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
# Created by DBIx::Class::Schema::Loader v0.07052 @ 2025-04-26 09:36:47
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ePfTpTOWY1H3Bky/bjA3iA
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View file

@ -1,136 +0,0 @@
use utf8;
package Pooru::Schema::Result::Media;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Pooru::Schema::Result::Media
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 TABLE: C<media>
=cut
__PACKAGE__->table("media");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 storage_id
data_type: 'text'
is_nullable: 0
size: 64
=head2 filename
data_type: 'text'
is_nullable: 0
size: 256
=head2 content_type
data_type: 'text'
is_nullable: 1
size: 256
=head2 upload_datetime
data_type: 'text'
default_value: current_timestamp
is_nullable: 1
size: 32
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"storage_id",
{ data_type => "text", is_nullable => 0, size => 64 },
"filename",
{ data_type => "text", is_nullable => 0, size => 256 },
"content_type",
{ data_type => "text", is_nullable => 1, size => 256 },
"upload_datetime",
{
data_type => "text",
default_value => \"current_timestamp",
is_nullable => 1,
size => 32,
},
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<storage_id_unique>
=over 4
=item * L</storage_id>
=back
=cut
__PACKAGE__->add_unique_constraint("storage_id_unique", ["storage_id"]);
=head1 RELATIONS
=head2 media_tags
Type: has_many
Related object: L<Pooru::Schema::Result::MediaTag>
=cut
__PACKAGE__->has_many(
"media_tags",
"Pooru::Schema::Result::MediaTag",
{ "foreign.media_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 tags
Type: many_to_many
Composing rels: L</media_tags> -> tag
=cut
__PACKAGE__->many_to_many("tags", "media_tags", "tag");
# Created by DBIx::Class::Schema::Loader v0.07052 @ 2025-04-26 09:36:47
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ODG4pqImG0JNc1YpUIVNFA
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View file

@ -1,99 +0,0 @@
use utf8;
package Pooru::Schema::Result::MediaTag;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Pooru::Schema::Result::MediaTag
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 TABLE: C<media_tag>
=cut
__PACKAGE__->table("media_tag");
=head1 ACCESSORS
=head2 media_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 tag_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=cut
__PACKAGE__->add_columns(
"media_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"tag_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
);
=head1 PRIMARY KEY
=over 4
=item * L</media_id>
=item * L</tag_id>
=back
=cut
__PACKAGE__->set_primary_key("media_id", "tag_id");
=head1 RELATIONS
=head2 media
Type: belongs_to
Related object: L<Pooru::Schema::Result::Media>
=cut
__PACKAGE__->belongs_to(
"media",
"Pooru::Schema::Result::Media",
{ id => "media_id" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
);
=head2 tag
Type: belongs_to
Related object: L<Pooru::Schema::Result::Tag>
=cut
__PACKAGE__->belongs_to(
"tag",
"Pooru::Schema::Result::Tag",
{ id => "tag_id" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
);
# Created by DBIx::Class::Schema::Loader v0.07052 @ 2025-04-26 09:36:47
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vtbD/Q3h2FEwALyG3IAaEg
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View file

@ -1,157 +0,0 @@
use utf8;
package Pooru::Schema::Result::Tag;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Pooru::Schema::Result::Tag
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 TABLE: C<tag>
=cut
__PACKAGE__->table("tag");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 name
data_type: 'text'
is_nullable: 0
size: 256
=head2 kind_id
data_type: 'text'
is_foreign_key: 1
is_nullable: 1
size: 32
=head2 display
data_type: 'text '
is_nullable: 1
size: 289
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"name",
{ data_type => "text", is_nullable => 0, size => 256 },
"kind_id",
{ data_type => "text", is_foreign_key => 1, is_nullable => 1, size => 32 },
"display",
{ data_type => "text ", is_nullable => 1, size => 289 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<display_unique>
=over 4
=item * L</display>
=back
=cut
__PACKAGE__->add_unique_constraint("display_unique", ["display"]);
=head2 C<name_kind_id_unique>
=over 4
=item * L</name>
=item * L</kind_id>
=back
=cut
__PACKAGE__->add_unique_constraint("name_kind_id_unique", ["name", "kind_id"]);
=head1 RELATIONS
=head2 kind
Type: belongs_to
Related object: L<Pooru::Schema::Result::Kind>
=cut
__PACKAGE__->belongs_to(
"kind",
"Pooru::Schema::Result::Kind",
{ id => "kind_id" },
{
is_deferrable => 0,
join_type => "LEFT",
on_delete => "NO ACTION",
on_update => "CASCADE",
},
);
=head2 media_tags
Type: has_many
Related object: L<Pooru::Schema::Result::MediaTag>
=cut
__PACKAGE__->has_many(
"media_tags",
"Pooru::Schema::Result::MediaTag",
{ "foreign.tag_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 medias
Type: many_to_many
Composing rels: L</media_tags> -> media
=cut
__PACKAGE__->many_to_many("medias", "media_tags", "media");
# Created by DBIx::Class::Schema::Loader v0.07052 @ 2025-04-26 09:36:47
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:XopZiRzgoNJuweuyFj9elA
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View file

@ -1,76 +0,0 @@
use utf8;
package Pooru::Schema::Result::TagCountView;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Pooru::Schema::Result::TagCountView
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->table_class("DBIx::Class::ResultSource::View");
=head1 TABLE: C<tag_count_view>
=cut
__PACKAGE__->table("tag_count_view");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_nullable: 1
=head2 name
data_type: 'text'
is_nullable: 1
size: 256
=head2 kind_id
data_type: 'text'
is_nullable: 1
size: 32
=head2 display
data_type: 'text'
is_nullable: 1
size: 289
=head2 count
data_type: (empty string)
is_nullable: 1
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 1 },
"name",
{ data_type => "text", is_nullable => 1, size => 256 },
"kind_id",
{ data_type => "text", is_nullable => 1, size => 32 },
"display",
{ data_type => "text", is_nullable => 1, size => 289 },
"count",
{ data_type => "", is_nullable => 1 },
);
# Created by DBIx::Class::Schema::Loader v0.07052 @ 2025-04-26 09:36:47
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Z8o5//l7dE0oSJLzDguHFw
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View file

@ -1,115 +0,0 @@
use utf8;
package Pooru::Schema::Result::TaggedMediaView;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Pooru::Schema::Result::TaggedMediaView
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->table_class("DBIx::Class::ResultSource::View");
=head1 TABLE: C<tagged_media_view>
=cut
__PACKAGE__->table("tagged_media_view");
=head1 ACCESSORS
=head2 media_id
data_type: 'integer'
is_nullable: 1
=head2 media_storage_id
data_type: 'text'
is_nullable: 1
size: 64
=head2 media_filename
data_type: 'text'
is_nullable: 1
size: 256
=head2 media_content_type
data_type: 'text'
is_nullable: 1
size: 256
=head2 media_upload_datetime
data_type: 'text'
is_nullable: 1
size: 32
=head2 tag_id
data_type: 'integer'
is_nullable: 1
=head2 tag_name
data_type: 'text'
is_nullable: 1
size: 256
=head2 tag_kind_id
data_type: 'text'
is_nullable: 1
size: 32
=head2 tag_display
data_type: 'text'
is_nullable: 1
size: 289
=head2 tag_count
data_type: (empty string)
is_nullable: 1
=cut
__PACKAGE__->add_columns(
"media_id",
{ data_type => "integer", is_nullable => 1 },
"media_storage_id",
{ data_type => "text", is_nullable => 1, size => 64 },
"media_filename",
{ data_type => "text", is_nullable => 1, size => 256 },
"media_content_type",
{ data_type => "text", is_nullable => 1, size => 256 },
"media_upload_datetime",
{ data_type => "text", is_nullable => 1, size => 32 },
"tag_id",
{ data_type => "integer", is_nullable => 1 },
"tag_name",
{ data_type => "text", is_nullable => 1, size => 256 },
"tag_kind_id",
{ data_type => "text", is_nullable => 1, size => 32 },
"tag_display",
{ data_type => "text", is_nullable => 1, size => 289 },
"tag_count",
{ data_type => "", is_nullable => 1 },
);
# Created by DBIx::Class::Schema::Loader v0.07052 @ 2025-04-26 09:36:47
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yihpYS6ccFg3BurhyxXqIw
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View file

@ -1,10 +0,0 @@
package Pooru::Schema::ResultSet::Media;
use v5.40;
use base "DBIx::Class::ResultSet";
sub random ($self, $rows = 1)
{
return $self->search(undef, {order_by => "random()", rows => $rows});
}
1;

View file

@ -1,10 +0,0 @@
package Pooru::Schema::ResultSet::Tag;
use v5.40;
use base "DBIx::Class::ResultSet";
sub random ($self, $rows = 1)
{
return $self->search(undef, {order_by => "random()", rows => $rows});
}
1;