Skip to content

Commit

Permalink
Fixup some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
knolleary committed Nov 1, 2024
1 parent 654bdf0 commit d79471e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ module.exports = {
if (!query.collection) {
dbQuery = dbQuery.sort(orderby)
}
const foundCount = await dbQuery.count()
const foundCount = await db.flows.countDocuments(findQuery)
if (proj) {
const docs = await dbQuery.skip(skip).limit(perPage * numPages).toArray()
if (process.env.FLOW_ENV !== 'PRODUCTION') {
console.log(findQuery, 'found=' + foundCount, 'count=' + docs.length)
console.log(findQuery, 'totalCount=' + foundCount, 'thisViewCount=' + docs.length)
}
const result = {
count: foundCount,
Expand Down
7 changes: 6 additions & 1 deletion routes/flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ async function getShareableFlow (id, collection, req, res) {
async function getFlow (id, collection, req, res) {
try {
const gist = await gister.get(id)
if (!gist) {
const err = new Error()
err.code = 404
throw err
}
gist.sessionuser = req.session.user
gist.csrfToken = req.csrfToken()
gist.collection = collection
Expand Down Expand Up @@ -188,7 +193,7 @@ async function getFlow (id, collection, req, res) {
res.send(mustache.render(templates.gist, gist, templates.partials))
} catch (err) {
// TODO: better error logging without the full stack trace
if (err) {
if (err && err.code !== 404) {
console.log('Error loading flow:', id)
console.log(err)
}
Expand Down

0 comments on commit d79471e

Please sign in to comment.