UpdatesManagerTests.coffee 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. sinon = require('sinon')
  2. chai = require('chai')
  3. should = chai.should()
  4. expect = chai.expect
  5. modulePath = "../../../../app/js/UpdatesManager.js"
  6. SandboxedModule = require('sandboxed-module')
  7. describe "UpdatesManager", ->
  8. beforeEach ->
  9. @UpdatesManager = SandboxedModule.require modulePath, requires:
  10. "./UpdateCompressor": @UpdateCompressor = {}
  11. "./MongoManager" : @MongoManager = {}
  12. "./RedisManager" : @RedisManager = {}
  13. "./LockManager" : @LockManager = {}
  14. "./WebApiManager": @WebApiManager = {}
  15. "logger-sharelatex": { log: sinon.stub(), error: sinon.stub() }
  16. @doc_id = "doc-id-123"
  17. @project_id = "project-id-123"
  18. @callback = sinon.stub()
  19. describe "compressAndSaveRawUpdates", ->
  20. describe "when there are no raw ops", ->
  21. beforeEach ->
  22. @MongoManager.popLastCompressedUpdate = sinon.stub()
  23. @MongoManager.insertCompressedUpdates = sinon.stub()
  24. @UpdatesManager.compressAndSaveRawUpdates @project_id, @doc_id, [], @callback
  25. it "should not need to access the database", ->
  26. @MongoManager.popLastCompressedUpdate.called.should.equal false
  27. @MongoManager.insertCompressedUpdates.called.should.equal false
  28. it "should call the callback", ->
  29. @callback.called.should.equal true
  30. describe "when there is no compressed history to begin with", ->
  31. beforeEach ->
  32. @rawUpdates = [{ v: 12, op: "mock-op-12" }, { v: 13, op: "mock-op-13" }]
  33. @compressedUpdates = { v: 13, op: "compressed-op-12" }
  34. @MongoManager.popLastCompressedUpdate = sinon.stub().callsArgWith(1, null, null)
  35. @MongoManager.insertCompressedUpdates = sinon.stub().callsArg(3)
  36. @UpdateCompressor.compressRawUpdates = sinon.stub().returns(@compressedUpdates)
  37. @UpdatesManager.compressAndSaveRawUpdates @project_id, @doc_id, @rawUpdates, @callback
  38. it "should try to pop the last compressed op", ->
  39. @MongoManager.popLastCompressedUpdate
  40. .calledWith(@doc_id)
  41. .should.equal true
  42. it "should compress the raw ops", ->
  43. @UpdateCompressor.compressRawUpdates
  44. .calledWith(null, @rawUpdates)
  45. .should.equal true
  46. it "should save the compressed ops", ->
  47. @MongoManager.insertCompressedUpdates
  48. .calledWith(@project_id, @doc_id, @compressedUpdates)
  49. .should.equal true
  50. it "should call the callback", ->
  51. @callback.called.should.equal true
  52. describe "when the raw ops need appending to existing history", ->
  53. beforeEach ->
  54. @lastCompressedUpdate = { v: 11, op: "compressed-op-11" }
  55. @compressedUpdates = { v: 13, op: "compressed-op-12" }
  56. @MongoManager.popLastCompressedUpdate = sinon.stub().callsArgWith(1, null, @lastCompressedUpdate)
  57. @MongoManager.insertCompressedUpdates = sinon.stub().callsArg(3)
  58. @UpdateCompressor.compressRawUpdates = sinon.stub().returns(@compressedUpdates)
  59. describe "when the raw ops start where the existing history ends", ->
  60. beforeEach ->
  61. @rawUpdates = [{ v: 12, op: "mock-op-12" }, { v: 13, op: "mock-op-13" }]
  62. @UpdatesManager.compressAndSaveRawUpdates @project_id, @doc_id, @rawUpdates, @callback
  63. it "should try to pop the last compressed op", ->
  64. @MongoManager.popLastCompressedUpdate
  65. .calledWith(@doc_id)
  66. .should.equal true
  67. it "should compress the last compressed op and the raw ops", ->
  68. @UpdateCompressor.compressRawUpdates
  69. .calledWith(@lastCompressedUpdate, @rawUpdates)
  70. .should.equal true
  71. it "should save the compressed ops", ->
  72. @MongoManager.insertCompressedUpdates
  73. .calledWith(@project_id, @doc_id, @compressedUpdates)
  74. .should.equal true
  75. it "should call the callback", ->
  76. @callback.called.should.equal true
  77. describe "when some raw ops are passed that have already been compressed", ->
  78. beforeEach ->
  79. @rawUpdates = [{ v: 10, op: "mock-op-10" }, { v: 11, op: "mock-op-11"}, { v: 12, op: "mock-op-12" }, { v: 13, op: "mock-op-13" }]
  80. @UpdatesManager.compressAndSaveRawUpdates @project_id, @doc_id, @rawUpdates, @callback
  81. it "should only compress the more recent raw ops", ->
  82. @UpdateCompressor.compressRawUpdates
  83. .calledWith(@lastCompressedUpdate, @rawUpdates.slice(-2))
  84. .should.equal true
  85. describe "when the raw ops do not follow from the last compressed op version", ->
  86. beforeEach ->
  87. @rawUpdates = [{ v: 13, op: "mock-op-13" }]
  88. @UpdatesManager.compressAndSaveRawUpdates @project_id, @doc_id, @rawUpdates, @callback
  89. it "should call the callback with an error", ->
  90. @callback
  91. .calledWith(new Error("Tried to apply raw op at version 13 to last compressed update with version 11"))
  92. .should.equal true
  93. it "should put the popped update back into mongo", ->
  94. @MongoManager.insertCompressedUpdates.calledOnce.should.equal true
  95. @MongoManager.insertCompressedUpdates
  96. .calledWith(@project_id, @doc_id, [@lastCompressedUpdate])
  97. .should.equal true
  98. describe "processUncompressedUpdates", ->
  99. describe "when there is fewer than one batch to send", ->
  100. beforeEach ->
  101. @updates = ["mock-update"]
  102. @RedisManager.getOldestRawUpdates = sinon.stub().callsArgWith(2, null, @updates)
  103. @UpdatesManager.compressAndSaveRawUpdates = sinon.stub().callsArgWith(3)
  104. @RedisManager.deleteOldestRawUpdates = sinon.stub().callsArg(2)
  105. @UpdatesManager.processUncompressedUpdates @project_id, @doc_id, @callback
  106. it "should get the oldest updates", ->
  107. @RedisManager.getOldestRawUpdates
  108. .calledWith(@doc_id, @UpdatesManager.REDIS_READ_BATCH_SIZE)
  109. .should.equal true
  110. it "should compress and save the updates", ->
  111. @UpdatesManager.compressAndSaveRawUpdates
  112. .calledWith(@project_id, @doc_id, @updates)
  113. .should.equal true
  114. it "should delete the batch of uncompressed updates that was just processed", ->
  115. @RedisManager.deleteOldestRawUpdates
  116. .calledWith(@doc_id, @updates.length)
  117. .should.equal true
  118. it "should call the callback", ->
  119. @callback.called.should.equal true
  120. describe "when there are multiple batches to send", ->
  121. beforeEach (done) ->
  122. @UpdatesManager.REDIS_READ_BATCH_SIZE = 2
  123. @updates = ["mock-update-0", "mock-update-1", "mock-update-2", "mock-update-3", "mock-update-4"]
  124. @redisArray = @updates.slice()
  125. @RedisManager.getOldestRawUpdates = (doc_id, batchSize, callback = (error, updates) ->) =>
  126. updates = @redisArray.slice(0, batchSize)
  127. @redisArray = @redisArray.slice(batchSize)
  128. callback null, updates
  129. sinon.spy @RedisManager, "getOldestRawUpdates"
  130. @UpdatesManager.compressAndSaveRawUpdates = sinon.stub().callsArgWith(3)
  131. @RedisManager.deleteOldestRawUpdates = sinon.stub().callsArg(2)
  132. @UpdatesManager.processUncompressedUpdates @project_id, @doc_id, (args...) =>
  133. @callback(args...)
  134. done()
  135. it "should get the oldest updates in three batches ", ->
  136. @RedisManager.getOldestRawUpdates.callCount.should.equal 3
  137. it "should compress and save the updates in batches", ->
  138. @UpdatesManager.compressAndSaveRawUpdates
  139. .calledWith(@project_id, @doc_id, @updates.slice(0,2))
  140. .should.equal true
  141. @UpdatesManager.compressAndSaveRawUpdates
  142. .calledWith(@project_id, @doc_id, @updates.slice(2,4))
  143. .should.equal true
  144. @UpdatesManager.compressAndSaveRawUpdates
  145. .calledWith(@project_id, @doc_id, @updates.slice(4,5))
  146. .should.equal true
  147. it "should delete the batches of uncompressed updates", ->
  148. @RedisManager.deleteOldestRawUpdates.callCount.should.equal 3
  149. it "should call the callback", ->
  150. @callback.called.should.equal true
  151. describe "processCompressedUpdatesWithLock", ->
  152. beforeEach ->
  153. @UpdatesManager.processUncompressedUpdates = sinon.stub().callsArg(2)
  154. @LockManager.runWithLock = sinon.stub().callsArg(2)
  155. @UpdatesManager.processUncompressedUpdatesWithLock @project_id, @doc_id, @callback
  156. it "should run processUncompressedUpdates with the lock", ->
  157. @LockManager.runWithLock
  158. .calledWith(
  159. "HistoryLock:#{@doc_id}"
  160. )
  161. .should.equal true
  162. it "should call the callback", ->
  163. @callback.called.should.equal true
  164. describe "getDocUpdates", ->
  165. beforeEach ->
  166. @updates = ["mock-updates"]
  167. @options = { to: "mock-to", limit: "mock-limit" }
  168. @MongoManager.getDocUpdates = sinon.stub().callsArgWith(2, null, @updates)
  169. @UpdatesManager.processUncompressedUpdatesWithLock = sinon.stub().callsArg(2)
  170. @UpdatesManager.getDocUpdates @project_id, @doc_id, @options, @callback
  171. it "should process outstanding updates", ->
  172. @UpdatesManager.processUncompressedUpdatesWithLock
  173. .calledWith(@project_id, @doc_id)
  174. .should.equal true
  175. it "should get the updates from the database", ->
  176. @MongoManager.getDocUpdates
  177. .calledWith(@doc_id, @options)
  178. .should.equal true
  179. it "should return the updates", ->
  180. @callback
  181. .calledWith(null, @updates)
  182. .should.equal true
  183. describe "getDocUpdatesWithUserInfo", ->
  184. beforeEach ->
  185. @updates = ["mock-updates"]
  186. @options = { to: "mock-to", limit: "mock-limit" }
  187. @updatesWithUserInfo = ["updates-with-user-info"]
  188. @UpdatesManager.getDocUpdates = sinon.stub().callsArgWith(3, null, @updates)
  189. @UpdatesManager.fillUserInfo = sinon.stub().callsArgWith(1, null, @updatesWithUserInfo)
  190. @UpdatesManager.getDocUpdatesWithUserInfo @project_id, @doc_id, @options, @callback
  191. it "should get the updates", ->
  192. @UpdatesManager.getDocUpdates
  193. .calledWith(@project_id, @doc_id, @options)
  194. .should.equal true
  195. it "should file the updates with the user info", ->
  196. @UpdatesManager.fillUserInfo
  197. .calledWith(@updates)
  198. .should.equal true
  199. it "should return the updates with the filled details", ->
  200. @callback.calledWith(null, @updatesWithUserInfo).should.equal true
  201. describe "getProjectUpdates", ->
  202. beforeEach ->
  203. @updates = ["mock-updates"]
  204. @options = { before: "mock-before", limit: "mock-limit" }
  205. @MongoManager.getProjectUpdates = sinon.stub().callsArgWith(2, null, @updates)
  206. @UpdatesManager.getProjectUpdates @project_id, @options, @callback
  207. it "should get the updates from the database", ->
  208. @MongoManager.getProjectUpdates
  209. .calledWith(@project_id, @options)
  210. .should.equal true
  211. it "should return the updates", ->
  212. @callback
  213. .calledWith(null, @updates)
  214. .should.equal true
  215. describe "getProjectUpdatesWithUserInfo", ->
  216. beforeEach ->
  217. @updates = ["mock-updates"]
  218. @options = { before: "mock-before", limit: "mock-limit" }
  219. @updatesWithUserInfo = ["updates-with-user-info"]
  220. @UpdatesManager.getProjectUpdates = sinon.stub().callsArgWith(2, null, @updates)
  221. @UpdatesManager.fillUserInfo = sinon.stub().callsArgWith(1, null, @updatesWithUserInfo)
  222. @UpdatesManager.getProjectUpdatesWithUserInfo @project_id, @options, @callback
  223. it "should get the updates", ->
  224. @UpdatesManager.getProjectUpdates
  225. .calledWith(@project_id, @options)
  226. .should.equal true
  227. it "should file the updates with the user info", ->
  228. @UpdatesManager.fillUserInfo
  229. .calledWith(@updates)
  230. .should.equal true
  231. it "should return the updates with the filled details", ->
  232. @callback.calledWith(null, @updatesWithUserInfo).should.equal true
  233. describe "_extendBatchOfSummarizedUpdates", ->
  234. beforeEach ->
  235. @to = 42
  236. @limit = 2
  237. @existingSummarizedUpdates = ["summarized-updates-3"]
  238. @summarizedUpdates = ["summarized-updates-3", "summarized-update-2", "summarized-update-1"]
  239. describe "when there are updates to get", ->
  240. beforeEach ->
  241. @updates = ["mock-updates"]
  242. @existingSummarizedUpdates = ["summarized-updates-3"]
  243. @summarizedUpdates = ["summarized-updates-3", "summarized-update-2", "summarized-update-1"]
  244. @UpdatesManager._summarizeUpdates = sinon.stub().returns(@summarizedUpdates)
  245. @UpdatesManager.getDocUpdatesWithUserInfo = sinon.stub().callsArgWith(3, null, @updates)
  246. @UpdatesManager._extendBatchOfSummarizedUpdates @project_id, @doc_id, @existingSummarizedUpdates, @to, @limit, @callback
  247. it "should get the updates", ->
  248. @UpdatesManager.getDocUpdatesWithUserInfo
  249. .calledWith(@project_id, @doc_id, { to: @to, limit: 3 * @limit })
  250. .should.equal true
  251. it "should summarize the updates", ->
  252. @UpdatesManager._summarizeUpdates
  253. .calledWith(@updates, @existingSummarizedUpdates)
  254. .should.equal true
  255. it "should call the callback with the summarized updates and false for end-of-databse", ->
  256. @callback.calledWith(null, @summarizedUpdates.slice(0, @limit), false).should.equal true
  257. describe "when there are no more updates", ->
  258. beforeEach ->
  259. @updates = []
  260. @UpdatesManager._summarizeUpdates = sinon.stub().returns(@summarizedUpdates)
  261. @UpdatesManager.getDocUpdatesWithUserInfo = sinon.stub().callsArgWith(3, null, @updates)
  262. @UpdatesManager._extendBatchOfSummarizedUpdates @project_id, @doc_id, @existingSummarizedUpdates, @to, @limit, @callback
  263. it "should call the callback with the summarized updates and true for end-of-database", ->
  264. @callback.calledWith(null, @summarizedUpdates.slice(0, @limit), true).should.equal true
  265. describe "getSummarizedDocUpdates", ->
  266. describe "when one batch of updates is enough to meet the limit", ->
  267. beforeEach ->
  268. @to = 42
  269. @limit = 2
  270. @updates = ["summarized-updates-3", "summarized-updates-2"]
  271. @UpdatesManager._extendBatchOfSummarizedUpdates = sinon.stub().callsArgWith(5, null, @updates)
  272. @UpdatesManager.getSummarizedDocUpdates @project_id, @doc_id, { to: @to, limit: @limit }, @callback
  273. it "should get the batch of summarized updates", ->
  274. @UpdatesManager._extendBatchOfSummarizedUpdates
  275. .calledWith(@project_id, @doc_id, [], @to, @limit)
  276. .should.equal true
  277. it "should call the callback with the updates", ->
  278. @callback.calledWith(null, @updates).should.equal true
  279. describe "when multiple batches are needed to meet the limit", ->
  280. beforeEach ->
  281. @to = 6
  282. @limit = 4
  283. @firstBatch = [{ toV: 6, fromV: 6 }, { toV: 5, fromV: 5 }]
  284. @secondBatch = [{ toV: 4, fromV: 4 }, { toV: 3, fromV: 3 }]
  285. @UpdatesManager._extendBatchOfSummarizedUpdates = (project_id, doc_id, existingUpdates, to, limit, callback) =>
  286. if existingUpdates.length == 0
  287. callback null, @firstBatch, false
  288. else
  289. callback null, @firstBatch.concat(@secondBatch), false
  290. sinon.spy @UpdatesManager, "_extendBatchOfSummarizedUpdates"
  291. @UpdatesManager.getSummarizedDocUpdates @project_id, @doc_id, { to: @to, limit: @limit }, @callback
  292. it "should get the first batch of summarized updates", ->
  293. @UpdatesManager._extendBatchOfSummarizedUpdates
  294. .calledWith(@project_id, @doc_id, [], @to, @limit)
  295. .should.equal true
  296. it "should get the second batch of summarized updates", ->
  297. @UpdatesManager._extendBatchOfSummarizedUpdates
  298. .calledWith(@project_id, @doc_id, @firstBatch, 4, @limit)
  299. .should.equal true
  300. it "should call the callback with all the updates", ->
  301. @callback.calledWith(null, @firstBatch.concat(@secondBatch)).should.equal true
  302. describe "when the end of the database is hit", ->
  303. beforeEach ->
  304. @to = 6
  305. @limit = 4
  306. @updates = [{ toV: 6, fromV: 6 }, { toV: 5, fromV: 5 }]
  307. @UpdatesManager._extendBatchOfSummarizedUpdates = sinon.stub().callsArgWith(5, null, @updates, true)
  308. @UpdatesManager.getSummarizedDocUpdates @project_id, @doc_id, { to: @to, limit: @limit }, @callback
  309. it "should get the batch of summarized updates", ->
  310. @UpdatesManager._extendBatchOfSummarizedUpdates
  311. .calledWith(@project_id, @doc_id, [], @to, @limit)
  312. .should.equal true
  313. it "should call the callback with the updates", ->
  314. @callback.calledWith(null, @updates).should.equal true
  315. describe "fillUserInfo", ->
  316. describe "with valid users", ->
  317. beforeEach (done) ->
  318. {ObjectId} = require "mongojs"
  319. @user_id_1 = ObjectId().toString()
  320. @user_id_2 = ObjectId().toString()
  321. @updates = [{
  322. meta:
  323. user_id: @user_id_1
  324. op: "mock-op-1"
  325. }, {
  326. meta:
  327. user_id: @user_id_1
  328. op: "mock-op-2"
  329. }, {
  330. meta:
  331. user_id: @user_id_2
  332. op: "mock-op-3"
  333. }]
  334. @user_info = {}
  335. @user_info[@user_id_1] = email: "user1@sharelatex.com"
  336. @user_info[@user_id_2] = email: "user2@sharelatex.com"
  337. @WebApiManager.getUserInfo = (user_id, callback = (error, userInfo) ->) =>
  338. callback null, @user_info[user_id]
  339. sinon.spy @WebApiManager, "getUserInfo"
  340. @UpdatesManager.fillUserInfo @updates, (error, @results) =>
  341. done()
  342. it "should only call getUserInfo once for each user_id", ->
  343. @WebApiManager.getUserInfo.calledTwice.should.equal true
  344. @WebApiManager.getUserInfo
  345. .calledWith(@user_id_1)
  346. .should.equal true
  347. @WebApiManager.getUserInfo
  348. .calledWith(@user_id_2)
  349. .should.equal true
  350. it "should return the updates with the user info filled", ->
  351. expect(@results).to.deep.equal [{
  352. meta:
  353. user:
  354. email: "user1@sharelatex.com"
  355. op: "mock-op-1"
  356. }, {
  357. meta:
  358. user:
  359. email: "user1@sharelatex.com"
  360. op: "mock-op-2"
  361. }, {
  362. meta:
  363. user:
  364. email: "user2@sharelatex.com"
  365. op: "mock-op-3"
  366. }]
  367. describe "with invalid user ids", ->
  368. beforeEach (done) ->
  369. @updates = [{
  370. meta:
  371. user_id: null
  372. op: "mock-op-1"
  373. }, {
  374. meta:
  375. user_id: "anonymous-user"
  376. op: "mock-op-2"
  377. }]
  378. @WebApiManager.getUserInfo = (user_id, callback = (error, userInfo) ->) =>
  379. callback null, @user_info[user_id]
  380. sinon.spy @WebApiManager, "getUserInfo"
  381. @UpdatesManager.fillUserInfo @updates, (error, @results) =>
  382. done()
  383. it "should not call getUserInfo", ->
  384. @WebApiManager.getUserInfo.called.should.equal false
  385. it "should return the updates without the user info filled", ->
  386. expect(@results).to.deep.equal [{
  387. meta: {}
  388. op: "mock-op-1"
  389. }, {
  390. meta: {}
  391. op: "mock-op-2"
  392. }]
  393. describe "_buildUpdatesView", ->
  394. beforeEach ->
  395. @now = Date.now()
  396. it "should concat updates that are close in time", ->
  397. expect(@UpdatesManager._summarizeUpdates [{
  398. meta:
  399. user: @user_1 = { id: "mock-user-1" }
  400. start_ts: @now + 20
  401. end_ts: @now + 30
  402. v: 5
  403. }, {
  404. meta:
  405. user: @user_2 = { id: "mock-user-2" }
  406. start_ts: @now
  407. end_ts: @now + 10
  408. v: 4
  409. }]).to.deep.equal [{
  410. meta:
  411. users: [@user_1, @user_2]
  412. start_ts: @now
  413. end_ts: @now + 30
  414. fromV: 4
  415. toV: 5
  416. }]
  417. it "should leave updates that are far apart in time", ->
  418. oneDay = 1000 * 60 * 60 * 24
  419. expect(@UpdatesManager._summarizeUpdates [{
  420. meta:
  421. user: @user_2 = { id: "mock-user-2" }
  422. start_ts: @now + oneDay
  423. end_ts: @now + oneDay + 10
  424. v: 5
  425. }, {
  426. meta:
  427. user: @user_1 = { id: "mock-user-2" }
  428. start_ts: @now
  429. end_ts: @now + 10
  430. v: 4
  431. }]).to.deep.equal [{
  432. meta:
  433. users: [@user_2]
  434. start_ts: @now + oneDay
  435. end_ts: @now + oneDay + 10
  436. fromV: 5
  437. toV: 5
  438. }, {
  439. meta:
  440. users: [@user_1]
  441. start_ts: @now
  442. end_ts: @now + 10
  443. fromV: 4
  444. toV: 4
  445. }]
  446. it "should concat onto existing summarized updates", ->
  447. @user_1 = { id: "mock-user-1" }
  448. @user_2 = { id: "mock-user-2" }
  449. expect(@UpdatesManager._summarizeUpdates [{
  450. meta:
  451. user: @user_1
  452. start_ts: @now + 20
  453. end_ts: @now + 30
  454. v: 5
  455. }, {
  456. meta:
  457. user: @user_2
  458. start_ts: @now
  459. end_ts: @now + 10
  460. v: 4
  461. }], [{
  462. meta:
  463. users: [@user_1]
  464. start_ts: @now + 40
  465. end_ts: @now + 50
  466. fromV: 6
  467. toV: 8
  468. }]).to.deep.equal [{
  469. meta:
  470. users: [@user_1, @user_2]
  471. start_ts: @now
  472. end_ts: @now + 50
  473. fromV: 4
  474. toV: 8
  475. }]