Skip to content

Commit

Permalink
Added table to store some usage statistics
Browse files Browse the repository at this point in the history
Address #44
  • Loading branch information
melmothx committed May 6, 2016
1 parent 88fe710 commit 8151f15
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/AmuseWikiFarm/Schema.pm
Expand Up @@ -40,7 +40,7 @@ and provide a dbic.yaml file with something like this:
=cut

our $VERSION = 16;
our $VERSION = 17;

__PACKAGE__->load_components('Schema::Config');

Expand Down
19 changes: 17 additions & 2 deletions lib/AmuseWikiFarm/Schema/Result/Site.pm
Expand Up @@ -649,6 +649,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 title_stats
Type: has_many
Related object: L<AmuseWikiFarm::Schema::Result::TitleStat>
=cut

__PACKAGE__->has_many(
"title_stats",
"AmuseWikiFarm::Schema::Result::TitleStat",
{ "foreign.site_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 titles
Type: has_many
Expand Down Expand Up @@ -705,8 +720,8 @@ Composing rels: L</user_sites> -> user
__PACKAGE__->many_to_many("users", "user_sites", "user");


# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-04-29 11:47:18
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aCt6iFhlfMFmNs60/R6L1A
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-05-06 10:04:20
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tubBmbLiu3V94WGDt0BNyA

=head2 other_sites
Expand Down
19 changes: 17 additions & 2 deletions lib/AmuseWikiFarm/Schema/Result/Title.pm
Expand Up @@ -343,6 +343,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 title_stats
Type: has_many
Related object: L<AmuseWikiFarm::Schema::Result::TitleStat>
=cut

__PACKAGE__->has_many(
"title_stats",
"AmuseWikiFarm::Schema::Result::TitleStat",
{ "foreign.title_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 categories
Type: many_to_many
Expand All @@ -354,8 +369,8 @@ Composing rels: L</title_categories> -> category
__PACKAGE__->many_to_many("categories", "title_categories", "category");


# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-02-02 09:44:57
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uxsQ/gYpgxMzvo6EvwP7bA
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-05-06 10:04:21
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FT20w1zat/1quXGg5X/OYw

__PACKAGE__->has_many(
translations => "AmuseWikiFarm::Schema::Result::Title",
Expand Down
138 changes: 138 additions & 0 deletions lib/AmuseWikiFarm/Schema/Result/TitleStat.pm
@@ -0,0 +1,138 @@
use utf8;
package AmuseWikiFarm::Schema::Result::TitleStat;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

=head1 NAME
AmuseWikiFarm::Schema::Result::TitleStat - Usage statistics
=cut

use strict;
use warnings;

use Moose;
use MooseX::NonMoose;
use MooseX::MarkAsMethods autoclean => 1;
extends 'DBIx::Class::Core';

=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=item * L<DBIx::Class::PassphraseColumn>
=back
=cut

__PACKAGE__->load_components("InflateColumn::DateTime", "PassphraseColumn");

=head1 TABLE: C<title_stat>
=cut

__PACKAGE__->table("title_stat");

=head1 ACCESSORS
=head2 title_stat_id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 site_id
data_type: 'varchar'
is_foreign_key: 1
is_nullable: 0
size: 16
=head2 title_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 accessed
data_type: 'datetime'
is_nullable: 0
=head2 notes
data_type: 'text'
is_nullable: 1
=cut

__PACKAGE__->add_columns(
"title_stat_id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"site_id",
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 16 },
"title_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"accessed",
{ data_type => "datetime", is_nullable => 0 },
"notes",
{ data_type => "text", is_nullable => 1 },
);

=head1 PRIMARY KEY
=over 4
=item * L</title_stat_id>
=back
=cut

__PACKAGE__->set_primary_key("title_stat_id");

=head1 RELATIONS
=head2 site
Type: belongs_to
Related object: L<AmuseWikiFarm::Schema::Result::Site>
=cut

__PACKAGE__->belongs_to(
"site",
"AmuseWikiFarm::Schema::Result::Site",
{ id => "site_id" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);

=head2 title
Type: belongs_to
Related object: L<AmuseWikiFarm::Schema::Result::Title>
=cut

__PACKAGE__->belongs_to(
"title",
"AmuseWikiFarm::Schema::Result::Title",
{ id => "title_id" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);


# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-05-06 10:04:21
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:utoiskpjQd8Xg2KPtgPo8Q


# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable;
1;
14 changes: 13 additions & 1 deletion sql/sqlite.sql
Expand Up @@ -290,6 +290,17 @@ CREATE TABLE site_link (
ON DELETE CASCADE ON UPDATE CASCADE
);

CREATE TABLE title_stat (
title_stat_id INTEGER PRIMARY KEY AUTOINCREMENT,
site_id VARCHAR(16) NOT NULL REFERENCES site(id)
ON DELETE CASCADE ON UPDATE CASCADE,
title_id INTEGER NOT NULL REFERENCES title(id)
ON DELETE CASCADE ON UPDATE CASCADE,
accessed DATETIME NOT NULL,
notes TEXT
);


CREATE TABLE table_comments (
table_name VARCHAR(255),
comment_text TEXT
Expand Down Expand Up @@ -321,6 +332,7 @@ INSERT INTO table_comments (table_name, comment_text)
('category', 'Text categories'),
('category_description', 'Category descriptions'),
('attachment', 'Attachment to texts'),
('site_link', 'Site links');
('site_link', 'Site links'),
('title_stat', 'Usage statistics');


0 comments on commit 8151f15

Please sign in to comment.