Changeset View
Changeset View
Standalone View
Standalone View
lib/subject/subject-types/image-format.js
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | function get_formatted_version( | ||||
format_name, | format_name, | ||||
format_obj | format_obj | ||||
) { | ) { | ||||
const random = Math.random(); | const random = Math.random(); | ||||
const hash = format_hash(format_obj); | const hash = format_hash(format_obj); | ||||
return app.Datastore.aggregate("formatted-images", [ | return app.Datastore.aggregate("formatted-images", [ | ||||
{ | { | ||||
$match: { | $match: { | ||||
"body.original_photo_file": { $eq: file_id }, | original_photo_file: { $eq: file_id }, | ||||
}, | }, | ||||
}, | }, | ||||
{ | { | ||||
$match: { | $match: { | ||||
$or: [ | $or: [{ "format.original": hash }, { "format.safe": hash }], | ||||
{ "body.format.original": hash }, | |||||
{ "body.format.safe": hash }, | |||||
], | |||||
}, | }, | ||||
}, | }, | ||||
]).then(function(results) { | ]).then(function(results) { | ||||
return ( | return ( | ||||
results[0] && | results[0] && | ||||
results[0].body && { | results[0] && { | ||||
id: results[0].body.formatted_photo_file, | id: results[0].formatted_photo_file, | ||||
original_name: format_filename(file_name, format_name), | original_name: format_filename(file_name, format_name), | ||||
} | } | ||||
); | ); | ||||
}); | }); | ||||
} | } | ||||
const ImageFormatFile = function(file_id, format_name, file_name) { | const ImageFormatFile = function(file_id, format_name, file_name) { | ||||
this.name = "SingleFile"; | this.name = "SingleFile"; | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |