Skip to content

Commit

Permalink
Merge branch 'MAS-129_121__112_Daily_Email' of https://github.com/nhs…
Browse files Browse the repository at this point in the history
…evidence/MAS into MAS-129_121__112_Daily_Email
  • Loading branch information
d-lan1 committed Jan 16, 2020
2 parents 78f6c65 + ef4e6b2 commit 8b643c5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
19 changes: 12 additions & 7 deletions cms/models/EvidenceType.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const keystone = require("keystone"),
fs = require("fs"),
path = require("path");
path = require("path"),
log4js = require("log4js");

const logger = log4js.getLogger("Item.js");

// Load the JSONLD for evidence types on application load
// so we don't have to hit the file system again and again
Expand All @@ -10,7 +13,7 @@ fs.readFile(
"UTF-8",
function(err, contents) {
if (err) {
loggger.error(err);
logger.error(err);
throw err;
}

Expand All @@ -30,7 +33,11 @@ const EvidenceType = new keystone.List("EvidenceType", {
EvidenceType.add({
title: { type: String, required: true },
key: { type: String, required: true },
oldEPiServerId: { label: "Old EPiServer ID", type: Types.Number, required: false },
oldEPiServerId: {
label: "Old EPiServer ID",
type: Types.Number,
required: false
}
});

EvidenceType.relationship({
Expand All @@ -47,10 +54,8 @@ EvidenceType.schema.virtual("broaderTitle").get(function() {
// Assume only 2 levels
const broaderConcept = evidenceTypes.find(e => e["@id"] === concept.broader);

if(broaderConcept.broader)
return broaderConcept.prefLabel["@value"];
else
return concept.prefLabel["@value"];
if (broaderConcept.broader) return broaderConcept.prefLabel["@value"];
else return concept.prefLabel["@value"];
});

EvidenceType.defaultColumns = "title, oldEPiServerId, key";
Expand Down
6 changes: 3 additions & 3 deletions cms/models/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Item.add({
staticPath: {
type: Types.Text,
watch: "title",
value: function () {
value: function() {
return (
process.env.STATIC_SITE_PATH +
(this.slug || utils.slug(this.title)) +
Expand All @@ -107,7 +107,7 @@ Item.add({
}
});

Item.schema.pre("validate", function (next) {
Item.schema.pre("validate", function(next) {
if (this.isInitial) {
this.isInitial = false;
next();
Expand Down Expand Up @@ -152,7 +152,7 @@ const createWeeklyIfNeeded = async () => {
};

// Post save hook to trigger a lambda with the document details
Item.schema.post("save", async function (doc, next) {
Item.schema.post("save", async function(doc, next) {
await createWeeklyIfNeeded();

logger.info("Post save, sending request...", doc);
Expand Down
11 changes: 6 additions & 5 deletions cms/routes/api/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ const keystone = require("keystone"),
const log4js = require("log4js"),
logger = log4js.getLogger();

exports.single = function (req, res, next) {
exports.single = function(req, res, next) {
Items.model
.findById(req.params.itemId)
.populate("source")
.populate("evidenceType")
.populate("specialities")
.exec(function (err, item) {
.exec(function(err, item) {
if (err) {
logger.error(`Error getting item with id ${req.params.itemId}`, err);
return res.error(err, true);
Expand Down Expand Up @@ -40,7 +40,8 @@ exports.single = function (req, res, next) {
"evidenceType._id",
"evidenceType.title",
"evidenceType.key",
"evidenceType.broaderTitle"]);
"evidenceType.broaderTitle"
]);

return res.json(obj);
});
Expand All @@ -49,14 +50,14 @@ exports.single = function (req, res, next) {
/**
* List Items
*/
exports.list = function (req, res) {
exports.list = function(req, res) {
// TODO: Pagination
Items.model
.find()
.populate("source")
.populate("evidenceType")
.populate("specialities")
.exec(function (err, items) {
.exec(function(err, items) {
if (err) {
logger.error(`Failed to get list of items`, err);
return res.error(err, true);
Expand Down

2 comments on commit 8b643c5

@NICE-TeamCity
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity MAS / MAS Build 1.1.0.568-MAS-129_121__112_Dai outcome was FAILURE
Summary: Tests passed: 5; artifacts size 186.2 KB is 95% different from 3.6 MB in build #1.1.0.557-r893BC73; exit code 1 (Step: CMS - Build NuGet package (NuGet Pack)) (new) Build time: 00:00:45

@NICE-TeamCity
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity MAS / MAS Build 1.1.0.569-MAS-129_121__112_Dai outcome was FAILURE
Summary: Tests passed: 5; artifacts size 186.2 KB is 95% different from 3.6 MB in build #1.1.0.557-r893BC73; exit code 1 (Step: CMS - Build NuGet package (NuGet Pack)) Build time: 00:00:39

Please sign in to comment.