From 8c7ef664be3292167762955307464aeeeec6bd0e Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Tue, 10 Feb 2015 18:43:19 +0200 Subject: [PATCH] Add a field for user creation time --- db.sql | 4 +++- lib/Gruntmaster/Data/Result/User.pm | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/db.sql b/db.sql index 2ef5105..475138b 100644 --- a/db.sql +++ b/db.sql @@ -9,7 +9,8 @@ CREATE TABLE users ( university TEXT, -- NOT NULL, level TEXT, -- NOT NULL, country TEXT, - lastjob BIGINT + lastjob BIGINT, + since BIGINT DEFAULT CAST(EXTRACT(epoch from now()) AS bigint) ); CREATE TABLE contests ( @@ -119,6 +120,7 @@ INSERT INTO column_comments VALUES ('users', 'passphrase', 'RFC2307-encoded pass INSERT INTO column_comments VALUES ('users', 'name', 'Full name of user'); INSERT INTO column_comments VALUES ('users', 'level', 'Highschool, Undergraduate, Master, Doctorate or Other'); INSERT INTO column_comments VALUES ('users', 'lastjob', 'Unix time when this user last submitted a job'); +INSERT INTO column_comments VALUES ('users', 'since', 'Unix time when this user was created'); INSERT INTO column_comments VALUES ('contests', 'start', 'Unix time when contest starts'); INSERT INTO column_comments VALUES ('contests', 'stop', 'Unix time when contest ends'); diff --git a/lib/Gruntmaster/Data/Result/User.pm b/lib/Gruntmaster/Data/Result/User.pm index 4922354..f961af9 100644 --- a/lib/Gruntmaster/Data/Result/User.pm +++ b/lib/Gruntmaster/Data/Result/User.pm @@ -87,6 +87,14 @@ Highschool, Undergraduate, Master, Doctorate or Other Unix time when this user last submitted a job +=head2 since + + data_type: 'bigint' + default_value: (date_part('epoch'::text, now()))::bigint + is_nullable: 1 + +Unix time when this user was created + =cut __PACKAGE__->add_columns( @@ -112,6 +120,12 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "lastjob", { data_type => "bigint", is_nullable => 1 }, + "since", + { + data_type => "bigint", + default_value => \"(date_part('epoch'::text, now()))::bigint", + is_nullable => 1, + }, ); =head1 PRIMARY KEY @@ -219,8 +233,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-01-29 18:45:35 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rpx697B3St+ICCSbOn4cbQ +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-02-10 18:42:04 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:L/ExLdA0pkJ1DeM+RzlDjw use Class::Method::Modifiers qw/after/; -- 2.39.2