Adding flatpak_repo to the possible fields in applications.

This is done so people can choose between flathub stables or
nightly external repositories.
This commit is contained in:
sergiotarxz 2022-03-24 23:57:09 +01:00
parent ea7c5b7471
commit fb50274fd3
7 changed files with 92 additions and 26 deletions

View File

@ -5,6 +5,8 @@ use v5.30.0;
use strict; use strict;
use warnings; use warnings;
use Data::Dumper;
use Params::ValidationCompiler qw/validation_for/; use Params::ValidationCompiler qw/validation_for/;
use Types::Standard qw/HasMethods InstanceOf Str HashRef/; use Types::Standard qw/HasMethods InstanceOf Str HashRef/;
@ -42,7 +44,7 @@ use Types::Standard qw/HasMethods InstanceOf Str HashRef/;
INSERT INTO applications INSERT INTO applications
(name, description, url, (name, description, url,
developer, price, git_repo, developer, price, git_repo,
flatpak_builder_file, verified) flatpak_builder_file, flatpak_repo, verified)
VALUES (?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
RETURNING uuid; RETURNING uuid;
EOF EOF
@ -51,7 +53,8 @@ EOF
$application->name, $application->description, $application->name, $application->description,
$application->url, $application->developer->uuid, $application->url, $application->developer->uuid,
$application->price, $application->git_repo, $application->price, $application->git_repo,
$application->flatpak_builder_file, $application->verified $application->flatpak_builder_file, $application->flatpak_repo,
$application->verified
); );
my $uuid = $result->{uuid}; my $uuid = $result->{uuid};
my $new_application = $self->recover_by_uuid( uuid => $uuid ); my $new_application = $self->recover_by_uuid( uuid => $uuid );
@ -86,7 +89,7 @@ EOF
SELECT uuid, date_creation, name, SELECT uuid, date_creation, name,
description, url, developer, description, url, developer,
price, git_repo, flatpak_builder_file, price, git_repo, flatpak_builder_file,
verified flatpak_repo, verified
FROM applications FROM applications
WHERE developer = ?; WHERE developer = ?;
EOF EOF
@ -112,7 +115,7 @@ EOF
SELECT uuid, date_creation, name, SELECT uuid, date_creation, name,
description, url, developer, description, url, developer,
price, git_repo, flatpak_builder_file, price, git_repo, flatpak_builder_file,
verified flatpak_repo, verified
FROM applications FROM applications
WHERE uuid = ? WHERE uuid = ?
EOF EOF
@ -148,6 +151,7 @@ sub _dbh {
return $self->{dbh}; return $self->{dbh};
} }
1; 1;
=encoding utf8 =encoding utf8
=head1 NAME =head1 NAME

View File

@ -46,13 +46,14 @@ my @migrations = (
price INTEGER NOT NULL, price INTEGER NOT NULL,
git_repo TEXT NOT NULL, git_repo TEXT NOT NULL,
flatpak_builder_file TEXT NOT NULL, flatpak_builder_file TEXT NOT NULL,
flatpak_repo TEXT NOT NULL,
verified BOOL DEFAULT false, verified BOOL DEFAULT false,
PRIMARY KEY (uuid), PRIMARY KEY (uuid),
FOREIGN KEY (developer) REFERENCES developers (uuid) FOREIGN KEY (developer) REFERENCES developers (uuid)
);', );',
'CREATE TABLE releases ( 'CREATE TABLE releases (
uuid UUID NOT NULL DEFAULT gen_random_uuid(), uuid UUID NOT NULL DEFAULT gen_random_uuid(),
date timestamp DEFAULT NOW(), date_creation timestamp DEFAULT NOW(),
application UUID NOT NULL, application UUID NOT NULL,
tag TEXT NOT NULL, tag TEXT NOT NULL,
name TEXT NOT NULL, name TEXT NOT NULL,

View File

@ -5,6 +5,7 @@ use strict;
use warnings; use warnings;
use Data::Dumper; use Data::Dumper;
use Carp qw/cluck/;
use Params::ValidationCompiler qw/validation_for/; use Params::ValidationCompiler qw/validation_for/;
use Types::Standard qw/Str InstanceOf Bool Num HasMethods/; use Types::Standard qw/Str InstanceOf Bool Num HasMethods/;
@ -26,6 +27,7 @@ use DateTime;
price => { type => Num }, price => { type => Num },
git_repo => { type => Str }, git_repo => { type => Str },
flatpak_builder_file => { type => Str }, flatpak_builder_file => { type => Str },
flatpak_repo => { type => Str },
verified => { type => Bool }, verified => { type => Bool },
} }
); );
@ -163,6 +165,20 @@ use DateTime;
} }
} }
{
my $validator =
validation_for( params => [ { type => Str, optional => 1 } ] );
sub flatpak_repo {
my $self = shift;
if (@_) {
my ($new_flatpak_repo) = $validator->(@_);
$self->{flatpak_repo} = $new_flatpak_repo;
}
return $self->{flatpak_repo};
}
}
{ {
my $validator = my $validator =
validation_for( params => [ { type => Bool, optional => 1 } ] ); validation_for( params => [ { type => Bool, optional => 1 } ] );
@ -318,6 +334,14 @@ Allows to retrieve and set the application's git_repo.
Allows to retrieve and set the application's flatpak_builder_file. Allows to retrieve and set the application's flatpak_builder_file.
=head2 flatpak_repo
my $flatpak_repo = $application->flatpak_repo;
$application->flatpak_repo($flatpak_repo);
Allows to retrieve and set the application's flatpak_repo.
=head2 verified =head2 verified
my $verified = $application->verified; my $verified = $application->verified;

View File

@ -88,6 +88,9 @@ BEGIN {
'https://git.desfronificator.example.com/larry/desfronificator.git'; 'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file = my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml'; './resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0; my $app_verified = 0;
my $developer = Peace::Model::Developer->new( my $developer = Peace::Model::Developer->new(
@ -108,16 +111,18 @@ BEGIN {
price => $app_price, price => $app_price,
git_repo => $app_git_repo, git_repo => $app_git_repo,
flatpak_builder_file => $app_flatpak_builder_file, flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified, verified => $app_verified,
developer => $developer, developer => $developer,
), ),
Peace::Model::Application->new( Peace::Model::Application->new(
name => $app_name0, name => $app_name1,
description => $app_description, description => $app_description,
url => $app_url, url => $app_url,
price => $app_price, price => $app_price,
git_repo => $app_git_repo, git_repo => $app_git_repo,
flatpak_builder_file => $app_flatpak_builder_file, flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified, verified => $app_verified,
developer => $developer, developer => $developer,
), ),

View File

@ -31,9 +31,12 @@ BEGIN {
my $app_description = 'Desfronifies the files.'; my $app_description = 'Desfronifies the files.';
my $app_url = 'https://desfronificator.example.com'; my $app_url = 'https://desfronificator.example.com';
my $app_price = '4.20'; my $app_price = '4.20';
my $app_git_repo = 'https://git.desfronificator.example.com/larry/desfronificator.git'; my $app_git_repo =
'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file = my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml'; './resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0; my $app_verified = 0;
my $developer = Peace::Model::Developer->new( my $developer = Peace::Model::Developer->new(
secret_bcrypt => $secret_bcrypt, secret_bcrypt => $secret_bcrypt,
@ -52,6 +55,7 @@ BEGIN {
url => $app_url, url => $app_url,
price => $app_price, price => $app_price,
flatpak_builder_file => $app_flatpak_builder_file, flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified, verified => $app_verified,
git_repo => $app_git_repo, git_repo => $app_git_repo,
); );
@ -76,9 +80,12 @@ BEGIN {
my $app_description = 'Desfronifies the files.'; my $app_description = 'Desfronifies the files.';
my $app_url = 'desfronificator.example.com'; my $app_url = 'desfronificator.example.com';
my $app_price = '4.20'; my $app_price = '4.20';
my $app_git_repo = 'https://git.desfronificator.example.com/larry/desfronificator.git'; my $app_git_repo =
'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file = my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml'; './resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0; my $app_verified = 0;
my $dbh = DBI->connect( 'DBI:Mock:', '', '' ); my $dbh = DBI->connect( 'DBI:Mock:', '', '' );
my $developer = Peace::Model::Developer->new( my $developer = Peace::Model::Developer->new(
@ -105,6 +112,7 @@ BEGIN {
url => $app_url, url => $app_url,
price => $app_price, price => $app_price,
flatpak_builder_file => $app_flatpak_builder_file, flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified, verified => $app_verified,
git_repo => $app_git_repo, git_repo => $app_git_repo,
dbh => $dbh, dbh => $dbh,

View File

@ -23,7 +23,7 @@ BEGIN {
INSERT INTO applications INSERT INTO applications
(name, description, url, (name, description, url,
developer, price, git_repo, developer, price, git_repo,
flatpak_builder_file, verified) flatpak_builder_file, flatpak_repo, verified)
VALUES (?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
RETURNING uuid; RETURNING uuid;
EOF EOF
@ -47,6 +47,8 @@ EOF
'https://git.desfronificator.example.com/larry/desfronificator.git'; 'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file = my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml'; './resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0; my $app_verified = 0;
my $developer = Peace::Model::Developer->new( my $developer = Peace::Model::Developer->new(
uuid => $uuid, uuid => $uuid,
@ -64,6 +66,7 @@ EOF
url => $app_url, url => $app_url,
price => $app_price, price => $app_price,
flatpak_builder_file => $app_flatpak_builder_file, flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified, verified => $app_verified,
git_repo => $app_git_repo, git_repo => $app_git_repo,
); );
@ -78,7 +81,7 @@ EOF
SELECT uuid, date_creation, name, SELECT uuid, date_creation, name,
description, url, developer, description, url, developer,
price, git_repo, flatpak_builder_file, price, git_repo, flatpak_builder_file,
verified flatpak_repo, verified
FROM applications FROM applications
WHERE uuid = ? WHERE uuid = ?
EOF EOF
@ -92,7 +95,8 @@ EOF
'name', 'description', 'name', 'description',
'url', 'developer', 'url', 'developer',
'price', 'git_repo', 'price', 'git_repo',
'flatpak_builder_file', 'verified', 'flatpak_builder_file', 'flatpak_repo',
'verified',
], ],
[ [
$uuid, $uuid,
@ -104,6 +108,7 @@ EOF
$app_price, $app_price,
$app_git_repo, $app_git_repo,
$app_flatpak_builder_file, $app_flatpak_builder_file,
$app_flatpak_repo,
$app_verified $app_verified
] ]
], ],
@ -136,6 +141,8 @@ EOF
'https://git.desfronificator.example.com/larry/desfronificator.git'; 'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file = my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml'; './resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0; my $app_verified = 0;
my $developer = Peace::Model::Developer->new( my $developer = Peace::Model::Developer->new(
uuid => $uuid, uuid => $uuid,
@ -153,7 +160,7 @@ EOF
SELECT uuid, date_creation, name, SELECT uuid, date_creation, name,
description, url, developer, description, url, developer,
price, git_repo, flatpak_builder_file, price, git_repo, flatpak_builder_file,
verified flatpak_repo, verified
FROM applications FROM applications
WHERE uuid = ? WHERE uuid = ?
EOF EOF
@ -167,7 +174,8 @@ EOF
'name', 'description', 'name', 'description',
'url', 'developer', 'url', 'developer',
'price', 'git_repo', 'price', 'git_repo',
'flatpak_builder_file', 'verified', 'flatpak_builder_file', 'flatpak_repo',
'verified',
], ],
[ [
$uuid, $uuid,
@ -179,6 +187,7 @@ EOF
$app_price, $app_price,
$app_git_repo, $app_git_repo,
$app_flatpak_builder_file, $app_flatpak_builder_file,
$app_flatpak_repo,
$app_verified $app_verified
] ]
], ],
@ -196,7 +205,7 @@ EOF
SELECT uuid, date_creation, name, SELECT uuid, date_creation, name,
description, url, developer, description, url, developer,
price, git_repo, flatpak_builder_file, price, git_repo, flatpak_builder_file,
verified flatpak_repo, verified
FROM applications FROM applications
WHERE developer = ?; WHERE developer = ?;
EOF EOF
@ -231,6 +240,8 @@ EOF
'https://git.desfronificator.example.com/larry/desfronificator.git'; 'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file = my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml'; './resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0; my $app_verified = 0;
my $iso8601 = DateTime::Format::Pg->new; my $iso8601 = DateTime::Format::Pg->new;
$dbh->{mock_add_resultset} = { $dbh->{mock_add_resultset} = {
@ -241,14 +252,21 @@ EOF
'name', 'description', 'name', 'description',
'url', 'price', 'url', 'price',
'git_repo', 'flatpak_builder_file', 'git_repo', 'flatpak_builder_file',
'verified', 'developer' 'flatpak_repo', 'verified',
'developer'
], ],
[ [
$app_uuid, $iso8601->format_datetime($app_date_creation), $app_uuid,
$app_name, $app_description, $iso8601->format_datetime($app_date_creation),
$app_url, $app_price, $app_name,
$app_git_repo, $app_flatpak_builder_file, $app_description,
$app_verified, $developer->uuid, $app_url,
$app_price,
$app_git_repo,
$app_flatpak_builder_file,
$app_flatpak_repo,
$app_verified,
$developer->uuid,
], ],
] ]
}; };

View File

@ -34,6 +34,8 @@ BEGIN {
'https://git.desfronificator.example.com/larry/desfronificator.git'; 'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file = my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml'; './resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0; my $app_verified = 0;
my $app_developer = Peace::Model::Developer->new( my $app_developer = Peace::Model::Developer->new(
secret_bcrypt => $developer_secret_bcrypt, secret_bcrypt => $developer_secret_bcrypt,
@ -51,6 +53,7 @@ BEGIN {
url => $app_url, url => $app_url,
price => $app_price, price => $app_price,
flatpak_builder_file => $app_flatpak_builder_file, flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified, verified => $app_verified,
git_repo => $app_git_repo, git_repo => $app_git_repo,
); );
@ -89,6 +92,8 @@ BEGIN {
'https://git.desfronificator.example.com/larry/desfronificator.git'; 'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file = my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml'; './resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0; my $app_verified = 0;
my $app_developer = Peace::Model::Developer->new( my $app_developer = Peace::Model::Developer->new(
secret_bcrypt => $developer_secret_bcrypt, secret_bcrypt => $developer_secret_bcrypt,
@ -106,6 +111,7 @@ BEGIN {
url => $app_url, url => $app_url,
price => $app_price, price => $app_price,
flatpak_builder_file => $app_flatpak_builder_file, flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified, verified => $app_verified,
git_repo => $app_git_repo, git_repo => $app_git_repo,
); );