Skip to content

Commit 044a781

Browse files
Fix
1 parent 4eee5a7 commit 044a781

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
"udt-collaboration-server": "./bin/cli.js"
99
},
1010
"scripts": {
11-
"start": "micro-dev --watch src ./app.js",
11+
"start": " micro-dev --watch src ./app.js",
1212
"start:prod": "micro ./app.js",
13-
"test": " yarn test:ava && yarn lint && yarn test:prettier",
14-
"prettier": "prettier --write \"src/**/*.js\"",
13+
"test": "yarn run test:ava && yarn run lint && yarn run test:prettier",
14+
"write:prettier": "prettier --write \"src/**/*.js\"",
1515
"test:prettier": "prettier --check \"src/**/*.js\"",
16-
"test:ava": "yarn ava tests/**/*.test.js",
16+
"test:ava": "ava tests/**/*.test.js",
1717
"lint": "eslint src tests"
1818
},
1919
"dependencies": {
@@ -41,6 +41,6 @@
4141
"test-listen": "^1.1.0"
4242
},
4343
"ava": {
44-
"timeout": "60s"
44+
"timeout": "120s"
4545
}
4646
}

src/utils/apply-sample-patch.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const fjp = require("fast-json-patch")
2-
const samplePathRe = "\\/(sample|samples)\\/([^/]+)(.*)"
2+
const samplePathRe = "\\/(sample|samples)\\/([^\\/]+)(.*)"
33
const applyRemoveSample = require("./apply-remove-sample")
44
const getSampleIndexAndId = require("./get-sample-index-and-id")
55

@@ -40,16 +40,25 @@ module.exports = async ({ db, patch, sessionId, workingSummaryObject }) => {
4040
]).newDocument
4141

4242
// Update sample in database with new content and new version
43-
44-
db.prepare(
45-
"UPDATE sample_state SET sample_version=?, sample_ref_id=?, content=? WHERE session_short_id=? AND sample_ref_id=?"
46-
).run(
47-
sample.sample_version + 1,
48-
newSampleContent._id,
49-
JSON.stringify(newSampleContent),
50-
sessionId,
51-
sampleId
52-
)
43+
if (newSampleContent._id)
44+
db.prepare(
45+
"UPDATE sample_state SET sample_version=?, sample_ref_id=?, content=? WHERE session_short_id=? AND sample_ref_id=?"
46+
).run(
47+
sample.sample_version + 1,
48+
newSampleContent._id,
49+
JSON.stringify(newSampleContent),
50+
sessionId,
51+
sampleId
52+
)
53+
else
54+
db.prepare(
55+
"UPDATE sample_state SET sample_version=?, content=? WHERE session_short_id=? AND sample_ref_id=?"
56+
).run(
57+
sample.sample_version + 1,
58+
JSON.stringify(newSampleContent),
59+
sessionId,
60+
sampleId
61+
)
5362

5463
workingSummaryObject.summary.samples[sampleIndex] = {
5564
hasAnnotation: Boolean(newSampleContent.annotation),

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4120,7 +4120,7 @@ yallist@^4.0.0:
41204120
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
41214121
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
41224122

4123-
yargs-parser@^20.2.2, yargs-parser@^20.2.7:
4123+
yargs-parser@^20.2.2:
41244124
version "20.2.7"
41254125
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.7.tgz#61df85c113edfb5a7a4e36eb8aa60ef423cbc90a"
41264126
integrity sha512-FiNkvbeHzB/syOjIUxFDCnhSfzAL8R5vs40MgLFBorXACCOAEaWu0gRZl14vG8MR9AOJIZbmkjhusqBYZ3HTHw==

0 commit comments

Comments
 (0)