Permalink
Browse files

added tag count generation

  • Loading branch information...
1 parent 51c45af commit 1085adbf8657015b706797b1aa0300f7cd3a53e5 @rb2k committed Jun 2, 2009
Showing with 8 additions and 3 deletions.
  1. +8 −3 main.rb
View
11 main.rb
@@ -72,12 +72,17 @@
#check if there's already a tag with that name
if (DB_ENKI[:tags].filter(:name => tag_row[:name]).count==0)
print "[NEW]"
- DB_ENKI[:tags].insert(:name => tag_row[:name])
+ DB_ENKI[:tags].insert(:name => tag_row[:name], :taggings_count=>1)
end
#inserting the newly found tag into the taggings table
my_tag_id = DB_ENKI[:tags].filter(:name => tag_row[:name]).first[:id]
- DB_ENKI[:taggings].insert(:tag_id => my_tag_id, :taggable_id => index)
- print " | "
+ current_count = DB_ENKI[:tags].filter(:name => tag_row[:name]).first[:taggings_count]
+ new_count = current_count.to_i + 1
+ #updating count
+ DB_ENKI[:tags].filter(:name => tag_row[:name]).update(:taggings_count => new_count)
+
+ DB_ENKI[:taggings].insert(:tag_id => my_tag_id, :taggable_id => index)
+ print " (#{new_count}) | "
end
print "\n"

0 comments on commit 1085adb

Please sign in to comment.