This file contains 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
def update_audio_marker | |
transaction do | |
marker = available_markers.order(:date).lock(true).try(:first) | |
if marker | |
marker.complete_markers += 1 | |
marker.calculate | |
marker.save! | |
end | |
end | |
end |
This file contains 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
money_development=> explain analyse insert into audio_markers (user_id, total_markers, date) SELECT users.id, count(*) as count, '2012-10-15' FROM users INNER JOIN portfels ON portfels.user_id = users.id where portfels.status = 6 and portfels.valid_til is not null group by users.id; | |
QUERY PLAN | |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
Insert on audio_markers (cost=844.24..844.27 rows=1 width=12) (actual time=4.175..4.175 rows=0 loops=1) | |
-> Subquery Scan on "*SELECT*" (cost=844.24..844.27 rows=1 width=12) (actual time=4.107..4.111 rows=2 loops=1) | |
-> HashAggregate (cost=844.24..844.25 rows=1 width=4) (actual time=4.079..4.079 rows=2 loops=1) | |
-> Nested Loop (cost=227.27..844.24 rows=1 width=4) (actual |
This file contains 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
module.exports = function(ws) { | |
ws.onopen = function() { | |
ws.send('biff'); | |
}; | |
ws.onmessage = function(m) { | |
console.log(m); | |
}; | |
}; |
This file contains 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
gem 'piet' |
This file contains 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
User.find_by_sql("insert into usercalcs (username, amount, created_at, updated_at, flag) select u.username::integer, sum(t.amount) as tr_sum, '#{t}', '#{t}', 0 from users u join archive_transfers t on u.username = t.receiver_id where t.status = 2 and t.currency = 1 and t.created_at between '#{s}' and '#{e}' group by u.username") |
This file contains 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
= cache todo do | |
= todo_li_tag todo do | |
.nubbin{"data-behavior" => "nubbin hover_content"} | |
.spacer | |
= link_to_trash [ @project, todo ], confirm: "Are you sure?" | |
= link_to_remote_edit "Edit", [ :edit, @project, todo ] unless todo.completed? | |
%div{class: ["#{'complete' if todo.completed}"]} | |
%span.wrapper | |
= todo_check_box_tag todo |
This file contains 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
def subtree_ids_sql(depth) | |
tree_sql = <<-SQL | |
WITH RECURSIVE search_tree(id, path, depth) AS ( | |
SELECT id, ARRAY[id], 1 | |
FROM users | |
WHERE id = #{id} | |
UNION ALL | |
SELECT users.id, path || users.id, search_tree.depth + 1 | |
FROM search_tree | |
JOIN users ON users.parent_id = search_tree.id |
This file contains 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
# coding: utf-8 | |
# app/models/api/user/registration.rb | |
module Api::User::Registration | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods |
This file contains 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
#coding: utf-8 | |
module WalletOperations | |
def add(target, amount) | |
res = false | |
if (eval("#{self.class.name.constantize}::TARGETS").include? target) && (amount.to_i > 0) | |
sql = <<-SQL | |
UPDATE #{self.class.table_name} SET "#{target.to_s}" = "#{target.to_s}" + #{amount}, updated_at = now() WHERE id = #{self.id} | |
SQL | |
ActiveRecord::Base.connection.execute(sql) | |
res = true |
This file contains 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
module CML2 | |
# Includes to ProductCategory model | |
module ProductCategory | |
def import node_set | |
::ProductCategory.delete_all | |
::ProductCategory.import_categories \ | |
node_set.xpath('/КоммерческаяИнформация/Классификатор/Группы') | |
end |
OlderNewer