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
WITH q AS ( | |
SELECT id, | |
root_id, | |
version, | |
lag(version) OVER (PARTITION BY root_id ORDER BY root_id, version) as prev_version, | |
lead(version) OVER (PARTITION BY root_id ORDER BY root_id, version) as next_version, | |
latest | |
FROM trades | |
ORDER BY root_id, version | |
) |
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
UPDATE trades SET latest = false where root_id = 'foo' AND version = 5; -- Client 1 | |
UPDATE trades SET latest = false where root_id = 'foo' AND version = 5; -- Client 2 | |
INSERT INTO trades (latest, root_id, version) VALUES (true, 'foo', 6); -- Client 1 | |
INSERT INTO trades (latest, root_id, version) VALUES (true, 'foo', 6); -- Client 2, UNIQUENESS CONSTRAINT ERROR! |
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
BEGIN; | |
UPDATE trades SET latest = false where root_id = 'foo' AND version = 5; | |
INSERT INTO trades (latest, root_id, version) VALUES (true, 'foo', 6); | |
COMMIT; |
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
CREATE TABLE trades | |
( | |
id SERIAL NOT NULL CONSTRAINT trades_pkey PRIMARY KEY, | |
latest BOOLEAN NOT NULL, | |
root_id TEXT NOT NULL, | |
version INTEGER NOT NULL, | |
price INT | |
); |
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
CREATE UNIQUE INDEX trades_root_id_and_version ON trades (root_id, version); |
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
React = require 'react' | |
app = require './app' | |
module.exports = (data) -> React.renderToString app(data) |
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 React | |
module Server | |
module Rendering | |
extend ActiveSupport::Concern | |
include ::BeforeRender | |
included do | |
before_render :set_rendered | |
attr_reader :rendered |
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
bundle 'server.js', | |
entries: ["your/entry/file.cjsx"] | |
extensions: ['.coffee', '.cjsx'] | |
builtins: false # already in node | |
commondir: false # already in node | |
detectGlobals: false # already in node | |
browserField: false # already in node | |
standalone: 'render' |
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
gulp.task 'frontend-js', -> | |
bundle 'application.js', | |
entries: ["your/entry/file.cjsx"] # or `.coffee` or whatever | |
extensions: ['.coffee', '.cjsx'] | |
debug: 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
bundle = (name, opts) -> | |
_.extend opts, | |
fullPaths: true | |
cache: {} | |
packageCache: {} | |
b = browserify opts | |
rebundle = -> | |
b.bundle() |
NewerOlder