Fixes
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
"build:webpack": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js --progress",
|
"build:webpack": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js --progress",
|
||||||
"build:analyze": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js --json | webpack-bundle-size-analyzer",
|
"build:analyze": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js --json | webpack-bundle-size-analyzer",
|
||||||
"build": "npm run clean && npm run build:webpack",
|
"build": "npm run clean && npm run build:webpack",
|
||||||
"start": "cross-env NODE_ENV=development DEBUG=sql,cache,presenters ./node_modules/.bin/nodemon --watch server index.js",
|
"start": "cross-env NODE_ENV=development DEBUG=cache,presenters ./node_modules/.bin/nodemon --watch server index.js",
|
||||||
"lint": "eslint frontend",
|
"lint": "eslint frontend",
|
||||||
"deploy": "git push heroku master",
|
"deploy": "git push heroku master",
|
||||||
"heroku-postbuild": "npm run build && npm run sequelize db:migrate",
|
"heroku-postbuild": "npm run build && npm run sequelize db:migrate",
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
sequelize,
|
sequelize,
|
||||||
} from '../sequelize';
|
} from '../sequelize';
|
||||||
|
|
||||||
const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z0-9]{15})$/;
|
const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z0-9]{10,15})$/;
|
||||||
|
|
||||||
import auth from './authentication';
|
import auth from './authentication';
|
||||||
// import pagination from './middlewares/pagination';
|
// import pagination from './middlewares/pagination';
|
||||||
@ -22,11 +22,16 @@ const getDocumentForId = async (id) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
document = await Document.findOne({
|
document = await Document.findOne({
|
||||||
where: {
|
where: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
// Invalid UUID
|
||||||
|
throw httpErrors.NotFound();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return document;
|
return document;
|
||||||
};
|
};
|
||||||
|
11
server/migrations/20160816082738-add-revision-index.js
Normal file
11
server/migrations/20160816082738-add-revision-index.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: function (queryInterface, Sequelize) {
|
||||||
|
queryInterface.addIndex('revisions', ['documentId']);
|
||||||
|
},
|
||||||
|
|
||||||
|
down: function (queryInterface, Sequelize) {
|
||||||
|
queryInterface.removeIndex('revisions', ['documentId']);
|
||||||
|
},
|
||||||
|
};
|
@ -142,7 +142,7 @@ const Atlas = sequelize.define('atlas', {
|
|||||||
|
|
||||||
return newTree;
|
return newTree;
|
||||||
},
|
},
|
||||||
async addNodeToNavigationTree(document) {
|
addNodeToNavigationTree(document) {
|
||||||
const newNode = {
|
const newNode = {
|
||||||
id: document.id,
|
id: document.id,
|
||||||
title: document.title,
|
title: document.title,
|
||||||
@ -163,6 +163,7 @@ const Atlas = sequelize.define('atlas', {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.navigationTree = insertNode(this.navigationTree);
|
this.navigationTree = insertNode(this.navigationTree);
|
||||||
|
return this.navigationTree;
|
||||||
},
|
},
|
||||||
async deleteDocument(document) {
|
async deleteDocument(document) {
|
||||||
const deleteNodeAndDocument = async (node, documentId, shouldDelete = false) => {
|
const deleteNodeAndDocument = async (node, documentId, shouldDelete = false) => {
|
||||||
|
@ -35,9 +35,16 @@ const documentBeforeSave = async (doc) => {
|
|||||||
doc.revisionCount = doc.revisionCount + 1;
|
doc.revisionCount = doc.revisionCount + 1;
|
||||||
|
|
||||||
// Collaborators
|
// Collaborators
|
||||||
const ids = await Revision.findAll({
|
let ids = [];
|
||||||
|
// Only get previous user IDs if the document already exists
|
||||||
|
if (doc.id) {
|
||||||
|
ids = await Revision.findAll({
|
||||||
attributes: [[DataTypes.literal('DISTINCT "userId"'), 'userId']],
|
attributes: [[DataTypes.literal('DISTINCT "userId"'), 'userId']],
|
||||||
|
where: {
|
||||||
|
documentId: doc.id,
|
||||||
|
},
|
||||||
}).map(rev => rev.userId);
|
}).map(rev => rev.userId);
|
||||||
|
}
|
||||||
// We'll add the current user as revision hasn't been generated yet
|
// We'll add the current user as revision hasn't been generated yet
|
||||||
ids.push(doc.lastModifiedById);
|
ids.push(doc.lastModifiedById);
|
||||||
doc.collaboratorIds = _.uniq(ids);
|
doc.collaboratorIds = _.uniq(ids);
|
||||||
|
Reference in New Issue
Block a user