Created
August 24, 2011 15:40
-
-
Save durango/1168333 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# What I expect... | |
~ (0.000454) SELECT `id`, `message`, `date_posted`, `last_edited`, `last_edited_by`, `player_id`, `forum_board_id`, `forum_topic_id` FROM `forum_replies` WHERE `forum_topic_id` IN (3, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 57, 54, 51, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36) ORDER BY `id` DESC | |
~ (0.000309) SELECT `id`, `name`, `user_id`, `active`, `age`, `level`, `life`, `strength`, `dexterity`, `intelligence`, `luck`, `bank`, `exp`, `energy`, `gender`, `wins`, `losses`, `stales`, `clan`, `last_killed`, `last_killedby`, `date_created`, `last_macro`, `macro_points`, `energy_refills`, `points`, `char_class`, `last_active`, `guild_id`, `forum_topic_id`, `forum_reply_id` FROM `players` WHERE `id` IN (1,2) LIMIT 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ (0.000454) SELECT `id`, `message`, `date_posted`, `last_edited`, `last_edited_by`, `player_id`, `forum_board_id`, `forum_topic_id` FROM `forum_replies` WHERE `forum_topic_id` IN (3, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 57, 54, 51, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36) ORDER BY `id` DESC | |
~ (0.000309) SELECT `id`, `name`, `user_id`, `active`, `age`, `level`, `life`, `strength`, `dexterity`, `intelligence`, `luck`, `bank`, `exp`, `energy`, `gender`, `wins`, `losses`, `stales`, `clan`, `last_killed`, `last_killedby`, `date_created`, `last_macro`, `macro_points`, `energy_refills`, `points`, `char_class`, `last_active`, `guild_id`, `forum_topic_id`, `forum_reply_id` FROM `players` WHERE `id` = 1 LIMIT 1 | |
~ (0.000343) SELECT `id`, `name`, `user_id`, `active`, `age`, `level`, `life`, `strength`, `dexterity`, `intelligence`, `luck`, `bank`, `exp`, `energy`, `gender`, `wins`, `losses`, `stales`, `clan`, `last_killed`, `last_killedby`, `date_created`, `last_macro`, `macro_points`, `energy_refills`, `points`, `char_class`, `last_active`, `guild_id`, `forum_topic_id`, `forum_reply_id` FROM `players` WHERE `id` = 2 LIMIT 1 | |
~ (0.000256) SELECT `id`, `macro_answer`, `clothes`, `auth_token` FROM `players` WHERE `id` = 1 ORDER BY `id` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
include DataMapper::Resource | |
attr_accessor :time_difference | |
property :id, Serial | |
property :name, String, :required => true, :length => 1..30, | |
:unique => true, :unique_index => true | |
property :user_id, Integer, :index => [:active_player] | |
property :active, Boolean, :default => false, :index => [:active_player] | |
property :age, Integer, :default => 1 | |
property :level, Integer, :default => 1 | |
property :life, Integer, :default => 1 | |
property :strength, Integer, :default => 4 | |
property :dexterity, Integer, :default => 2 | |
property :intelligence, Integer, :default => 2 | |
property :luck, Integer, :default => 2 | |
property :bank, Integer, :default => 0 | |
property :exp, Integer, :default => 0 | |
property :energy, Integer, :default => 100 | |
property :gender, Boolean, :default => false | |
property :wins, Integer | |
property :losses, Integer | |
property :stales, Integer | |
property :clan, Integer | |
property :last_killed, Integer | |
property :last_killedby, Integer | |
property :date_created, DateTime, :default => Time.now | |
property :last_macro, DateTime | |
property :macro_points, Integer | |
property :macro_answer, Json, :lazy => true | |
property :energy_refills, Integer | |
property :clothes, Json, :lazy => true | |
property :points, Integer | |
property :char_class, Integer, :default => 0 | |
property :last_active, DateTime | |
property :auth_token, Text | |
belongs_to :user, :model => 'User' | |
belongs_to :guild, :required => false | |
has n, :inventory | |
has n, :actions | |
has n, :slots | |
has n, :achievements | |
has n, :guild_invites | |
has n, :guild_donations | |
has n, :forum_topics | |
has n, :forum_replies | |
has n, :items, :through => :inventory | |
has n, :inbox, 'Mailbox', :child_key => :to_id | |
has n, :outbox, 'Mailbox', :child_key => :from_id | |
has n, :forum_edits_reply, 'ForumTopic', :child_key => :last_edited_by | |
has n, :forum_edits_topics, 'ForumReply', :child_key => :last_edited_by | |
has 0..1, :owned_pet, :required => false | |
has 0..1, :guild_rank, 'GuildRank' | |
end | |
class ForumTopic | |
include DataMapper::Resource | |
property :id, Serial | |
property :title, String, :length => 1..40 | |
property :message, Text, :length => 1..10000 | |
property :views, Integer | |
property :date_posted, DateTime, :default => proc { DateTime.now } | |
property :last_updated, DateTime, :default => proc { DateTime.now } | |
property :last_edited, DateTime | |
property :last_edited_by, Integer | |
property :forum_board_id, Integer | |
has n, :forum_replies, :constraint => :destroy | |
has 0..1, :last_edited_from, 'Player' | |
has 0..1, :last_reply, 'ForumReply', :order => [:id.desc] | |
belongs_to :player | |
belongs_to :forum_board | |
after :create do | |
::Cache.incr("topic_count") | |
end | |
after :destroy do | |
::Cache.decr("topic_count") | |
end | |
end | |
class ForumReply | |
include DataMapper::Resource | |
property :id, Serial | |
property :message, Text, :length => 1..10000 | |
property :date_posted, DateTime, :default => proc { DateTime.now } | |
property :last_edited, DateTime | |
property :last_edited_by, Integer | |
has 0..1, :last_edited_from, 'Player' | |
belongs_to :player | |
belongs_to :forum_board | |
belongs_to :forum_topic | |
after :create do |post| | |
::Cache.incr("reply_count") | |
@topic = ForumTopic.get(post.forum_topic_id) | |
@topic.update(:last_updated => proc { DateTime.now }) | |
end | |
after :destroy do | |
::Cache.decr("reply_count") | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%h2 | |
%a(href = '/forum') Forum Index | |
» | |
%a(href = "/forum/view/#{@forum.id}")= @forum.name | |
%br/ | |
= @pager | |
%br/ | |
%table(align = 'center' width = '95%' cellspacing = '0' cellpadding = '0' class = 'forum') | |
%tr | |
%th(width = '50%' align = 'left') Subject | |
%th(width = '20%' align = 'left') Author | |
%th(width = '10%' align = 'left') Views | |
%th(width = '20%' align = 'left') Last Poster | |
- if @topics.nil? | |
%tr | |
%td(colspan = '5' align = 'center') There are currently no topics in here. | |
- @topics.each do |topic| | |
%tr | |
%td | |
%a(href = "/forum/thread/#{topic.id}/")= topic.title | |
%td | |
%a(href = "/profile/#{topic.player_id}/")= topic.player.name | |
%td= topic.views.to_i | |
%td | |
- if topic.last_reply.nil? | |
N/A | |
- else | |
%a(href = "/forum/thread/#{topic.id}/last" title = "#{topic.last_reply.message}") | |
Re: | |
= topic.title | |
%br/ | |
by | |
%a(href = "/profile/#{topic.last_reply.player.id}/")= topic.last_reply.player.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment