RealDevSquad / RealDevSquad/website-backend

[RFC] Generating auto incrementing sequence for task number

Open
#800 1 comment 0 reactions 1 assignee View on GitHub

@YashJain24-chief is already working on this.

Since Nov 5, 2022.

backlog RFC
Dominant language
JavaScript
Stars
74
Forks
276
Avg merge
1d 26m
Merged PRs (30d)
14

Description

https://github.com/Real-Dev-Squad/todo-action-items/issues/77

Approach 1

When a new task is created, update the counter by reading from and writing to the taskCounter collection that will store the previous value of the counter.

Pros

  1. Lesser number of reads and writes as we have a separate collection. Basically, only 1 read for getting the previous value and 1 write for updating the value in collection everytime a new task is created.

Cons

  1. Creating a whole new collection just for storing the previous counter value
  2. Two operations are performed - Reading the old counter value and then using it to increment the value and storing back to the taskCounter collection.
Approach 2

Getting QuerySnapshot of the task collection and using size property

Pros

  1. No need to maintain a collection just to maintain a single count value. Good for medium-sized collections that contain around 100-1000 documents.

Cons

  1. The main problem is the cost, by executing this query we will be charged for one read for each doc of the sub-collection.
Approach 3

Using the count aggregation query.

Pros
No need to read and write to the firestore every time. It will basically return the number of documents in a collection which can then be incremented and stored when a new task is created. We are charged a small number of reads for a large number of matched entries.

Cons
If a count() aggregation cannot resolve within 60 seconds, it returns a DEADLINE_EXCEEDED error. Performance depends on the size of the dataset.

Also what happens to the tasks that are already in the DB? How do we have a task number for those tasks?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.