aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorZephyrrus <[email protected]>2021-01-08 17:44:48 +0200
committerZephyrrus <[email protected]>2021-01-08 17:44:48 +0200
commite962efd01486020d04c1774c2691e8d8799ac845 (patch)
tree61bee0d49e464ca27aabbdef90392a1ff56c85e9 /src/api
parentchore: remove query from API response (diff)
downloadhost.fuwn.me-e962efd01486020d04c1774c2691e8d8799ac845.tar.xz
host.fuwn.me-e962efd01486020d04c1774c2691e8d8799ac845.zip
fix: pagination not working when searching
fix: search not working on albums
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/search/searchGET.js8
-rw-r--r--src/api/routes/service/statsGET.js4
2 files changed, 9 insertions, 3 deletions
diff --git a/src/api/routes/search/searchGET.js b/src/api/routes/search/searchGET.js
index eaad946..187fcab 100644
--- a/src/api/routes/search/searchGET.js
+++ b/src/api/routes/search/searchGET.js
@@ -20,7 +20,7 @@ class configGET extends Route {
async run(req, res, db, user) {
let count = 0;
- const { q } = req.query;
+ const { q, albumId } = req.query;
const parsed = searchQuery.parse(q, options);
let files = db.table('files')
@@ -28,6 +28,12 @@ class configGET extends Route {
.where({ 'files.userId': user.id })
.orderBy('files.createdAt', 'desc');
+ if (albumId) {
+ files
+ .join('albumsFiles', 'albumsFiles.fileId', 'files.id')
+ .where({ albumId });
+ }
+
files = queryHelper.processQuery(db, files, parsed);
// const query = files.toString();
diff --git a/src/api/routes/service/statsGET.js b/src/api/routes/service/statsGET.js
index 6d5197b..bcddc9f 100644
--- a/src/api/routes/service/statsGET.js
+++ b/src/api/routes/service/statsGET.js
@@ -17,8 +17,8 @@ class filesGET extends Route {
[category]: {
...dbRes,
meta: {
- cached: true,
- generatedOn: moment().format('MMMM Do YYYY, h:mm:ss a z'), // pg returns this as a date, sqlite3 returns an unix timestamp :<
+ cached: false,
+ generatedOn: moment().format('MMMM Do YYYY, h:mm:ss a z'),
type: StatsGenerator.Type.HIDDEN
}
}