Skip to content
Snippets Groups Projects
Verified Commit d414bdf2 authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Nove attributy streamu a zaznamu

parent aa29f6ba
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,7 @@ __PACKAGE__->add_columns( ...@@ -20,6 +20,7 @@ __PACKAGE__->add_columns(
begin begin
end end
is_active is_active
is_indexed
is_protected is_protected
stream_id stream_id
publish_user_id publish_user_id
......
...@@ -19,6 +19,7 @@ __PACKAGE__->add_columns( ...@@ -19,6 +19,7 @@ __PACKAGE__->add_columns(
qw( qw(
is_active is_active
is_public is_public
is_live
key key
name name
description description
......
...@@ -14,14 +14,6 @@ __PACKAGE__->add_columns(qw( ...@@ -14,14 +14,6 @@ __PACKAGE__->add_columns(qw(
publish_user_name publish_user_name
)); ));
sub is_live {
my $self = shift;
my $max_age = shift // 60;
return 0 if ! $self->publish_last_age;
return $self->publish_last_age < $max_age ? 1 : 0;
}
sub is_writeable { sub is_writeable {
my $self = shift; my $self = shift;
my $acl = shift // 0; my $acl = shift // 0;
......
...@@ -69,6 +69,7 @@ create table "records" ( ...@@ -69,6 +69,7 @@ create table "records" (
"id" integer not null default nextval('uid_seq'), "id" integer not null default nextval('uid_seq'),
"begin" timestamp(0) not null default now(), "begin" timestamp(0) not null default now(),
"end" timestamp(0), "end" timestamp(0),
"deleted" timestamp(0),
"is_active" bool not null default true, "is_active" bool not null default true,
"is_protected" bool not null default false, "is_protected" bool not null default false,
"stream_id" integer not null, "stream_id" integer not null,
...@@ -94,3 +95,28 @@ from "records" ...@@ -94,3 +95,28 @@ from "records"
left join "users" on ("records"."publish_user_id" = "users"."id") left join "users" on ("records"."publish_user_id" = "users"."id")
join "streams" on ("records"."stream_id" = "streams"."id") join "streams" on ("records"."stream_id" = "streams"."id")
; ;
-- 6 up
drop view "records_view";
drop view "streams_view";
alter table "streams" add "is_live" boolean not null default 'f';
alter table "records" add "is_indexed" boolean not null default 'f';
create view "streams_view" as
select "streams".*,
extract(epoch from now()-"publish_last") as "publish_last_age",
"users"."name" as "publish_user_name"
from "streams"
left join "users" on ("streams"."publish_user_id" = "users"."id")
;
create view "records_view" as
select "records".*,
"streams"."key" as "stream_key",
"streams"."name" as "stream_name",
"streams"."is_public" as "stream_is_public",
"users"."name" as "publish_user_name"
from "records"
left join "users" on ("records"."publish_user_id" = "users"."id")
join "streams" on ("records"."stream_id" = "streams"."id")
;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment