-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new paginated functionality added in GET /tasks #647
new paginated functionality added in GET /tasks #647
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel we need to cover more test cases here.
models/tasks.js
Outdated
const tasksSnapshot = await tasksModel.get(); | ||
const tasksSnapshot = await tasksModel | ||
.orderBy("startedOn", "desc") | ||
.startAfter(lastDoc ? lastDoc.startedOn : "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If lastDoc
is undefined (or null), does this call error out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no
const fetchTasks = async (limit, offset) => { | ||
let lastDoc; | ||
if (offset) { | ||
lastDoc = await tasksModel.doc(offset).get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offset should be a number, but here, it seems to be used as a document_id.
lastDoc = await tasksModel.doc(offset).get(); | ||
lastDoc = lastDoc.data(); | ||
} | ||
const limitDocuments = Number(limit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we request any number of documents from Firestore? Should there be an upper limit here?
Closing this, as this feature is already implemented (https://github.com/Real-Dev-Squad/website-backend/blob/develop/controllers/tasks.js) |
tests are yet to be created
API Contract