Compare commits

...

7 Commits

4 changed files with 853 additions and 769 deletions

View File

@ -27,31 +27,31 @@
"sequelize-erd": "https://github.com/Alamantus/sequelize-erd.git" "sequelize-erd": "https://github.com/Alamantus/sequelize-erd.git"
}, },
"dependencies": { "dependencies": {
"autoprefixer": "^9.7.4", "autoprefixer": "^9.8.5",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"choo": "^7.1.0", "choo": "^7.1.0",
"cross-env": "^7.0.0", "cross-env": "^7.0.2",
"fastify": "^2.11.0", "fastify": "^3.1.1",
"fastify-caching": "^5.0.0", "fastify-caching": "^6.0.1",
"fastify-compress": "^2.0.0", "fastify-compress": "^3.2.2",
"fastify-cookie": "^3.5.0", "fastify-cookie": "^4.0.2",
"fastify-helmet": "^3.0.2", "fastify-helmet": "^4.0.2",
"fastify-jwt": "^1.2.1", "fastify-jwt": "^2.1.2",
"fastify-plugin": "^1.6.0", "fastify-plugin": "^2.0.3",
"fastify-static": "^2.6.0", "fastify-static": "^3.2.0",
"make-promises-safe": "^5.1.0", "make-promises-safe": "^5.1.0",
"marked": "^1.1.0", "marked": "^1.1.1",
"mysql2": "^2.1.0", "mysql2": "^2.1.0",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.0",
"nodemailer": "^6.4.2", "nodemailer": "^6.4.10",
"parcel-bundler": "^1.12.4", "parcel-bundler": "^1.12.4",
"parcel-plugin-goodie-bag": "^2.0.0", "parcel-plugin-goodie-bag": "^2.0.0",
"pg": "^8.2.1", "pg": "^8.3.0",
"pg-hstore": "^2.3.3", "pg-hstore": "^2.3.3",
"picnic": "^6.5.2", "picnic": "^6.5.2",
"sass": "^1.25.0", "sass": "^1.26.10",
"sequelize": "^5.21.3", "sequelize": "^6.3.3",
"sharp": "^0.25.4", "sharp": "^0.25.4",
"sqlite3": "^4.2.0" "sqlite3": "^5.0.0"
} }
} }

View File

@ -48,6 +48,12 @@ class SearchController {
[fn('AVG', col('Ratings.rating')), 'averageRating'], [fn('AVG', col('Ratings.rating')), 'averageRating'],
], ],
order: [[col('totalInteractions'), 'DESC']], order: [[col('totalInteractions'), 'DESC']],
group: [
col('BookReference.id'),
col('Interactions.id'),
col('Reviews.id'),
col('Ratings.id'),
],
}; };
} }
@ -77,7 +83,7 @@ class SearchController {
let extraReferences = []; let extraReferences = [];
if (urisToCheck.length > 0) { if (urisToCheck.length > 0) {
// Need to figure this out // Need to figure this out
// extraReferences = await this.searchReferencesBySourceCodes(source, urisToCheck); extraReferences = await this.searchReferencesBySourceCodes(source, urisToCheck);
} }
return [ return [
...bookReferences, ...bookReferences,
@ -140,7 +146,7 @@ class SearchController {
const sourceJSONKey = `"${source}"`; // Enable searching withing JSON column. const sourceJSONKey = `"${source}"`; // Enable searching withing JSON column.
return await this.models.BookReference.findOne({ return await this.models.BookReference.findOne({
where: { where: {
source: { sources: {
[sourceJSONKey]: { // Where the object key is the source [sourceJSONKey]: { // Where the object key is the source
[Op.eq]: sourceId, [Op.eq]: sourceId,
}, },
@ -157,7 +163,7 @@ class SearchController {
return await this.models.BookReference.findAll({ return await this.models.BookReference.findAll({
where: { where: {
[Op.or]: sourceIds.map(sourceId => ({ [Op.or]: sourceIds.map(sourceId => ({
source: { sources: {
[sourceJSONKey]: sourceId, [sourceJSONKey]: sourceId,
}, },
})), })),

View File

@ -23,7 +23,7 @@ module.exports = sequelize => sequelize.define('Shelf', {
}, },
}, },
permissionLevel: { permissionLevel: {
type: Sequelize.NUMBER, type: Sequelize.INTEGER,
allowNull: false, allowNull: false,
defaultValue: 0, defaultValue: 0,
references: { references: {

1576
yarn.lock

File diff suppressed because it is too large Load Diff