Maximizing the timeout efficiency in Firebase Cloud Functions

In my project, I have a function that triggers the sending of emails every time a new element is added to the database. The function grabs email addresses for specific users and sends out emails accordingly.

Now, I'm running this function every time a new work child is created. However, I'm wondering if there's a way to check if the child has been in the database for more than 5 minutes.

My goal:

If the work's property (available) remains unchanged for 5 minutes, I want to resend the emails. While I could implement this using a timeout loop, I'm curious if there is a more efficient method available.

Answer №1

To tackle this issue, my suggestion would be to implement a CRON job that retrieves tasks according to their status and creation time. Make sure to populate the createTime field when adding new tasks. One convenient method for running CRON jobs is through Azure Functions; however, you could also explore alternative solutions provided by GCP or Firebase.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Enhance your webpage with dynamic styling using third-party CSS animation

Apologies for any similarity to other questions on this topic. I have searched extensively, but any assistance would be greatly appreciated. I am utilizing a new animation library from Animista to animate specific elements on a test website. Animating ele ...

AngularJS data retrieval timeout function

After reading this response, I am currently in the process of developing a service that can provide data even if the request fails due to timing out. this.getStatus = function() { var timeoutPromise = $timeout(function () { cancele ...

Ways to postpone CSS and Script loading once JavaScript has been executed

My issue with my backbone.js app is that I have noticed some slow loading files (a .css and a .js) that are causing the page to block until they are fully loaded. After rendering the backbone view, I am looking for a way to delay the loading of these file ...

Is there a way to reverse the image without physically clicking on it?

I've created a JavaScript code for matching images in a 4x4 grid. The goal is to flip the images when clicked and then flip them back if they don't match. I've managed to flip the images initially, but there's an issue with flipping the ...

Creating a Record instance consisting of a specific key and its corresponding value

Sorry for the complexity, I've struggled to simplify this further. Feel free to update the question title for more specificity. I aim to define a foundational data type structure: type AbstractBaseTypes = { [key: string]: { inputTypes ...

Using Vue 3 to have the ability to include multiple composable instances in a single script tag

Currently in the process of revamping our components that are originally built using the Options API. A key point for refactoring from a code-cut perspective is how we handle our multiple modals, each with their own open/close and boolean logic scattered t ...

The execution of my JavaScript code does not pause for the completion of an ajax request

I'm currently working on a register validation code in JavaScript. One of the key aspects checked by the validation function is whether the email address provided by the user already exists in the database. To handle this, I'm implementing ajax, ...

Is it necessary for me to use bindActionCreators?

While going through a post, I couldn't help but notice that the bindActionCreators method from redux wasn't being utilized. Is there a specific reason for this? Could it be that the method is not necessary in this context? The post in question ...

"Shopping just got easier with our new drag and drop feature! Simply drag items

I want to develop a Virtual Shopping Cart system. Items will be retrieved from a database. A virtual basket will be available. Users can drag items and drop them into the basket, similar to shopping in a mall. Once the user clicks the save button, the s ...

What is the reason behind not requiring to invoke the next function in a Sails.js controller method, even when it includes an asynchronous database query?

Sample controller function: fetchArticles: function(req, res) { Articles.find({}).exec(function(err, articles) { res.json(articles) // It appears this part is asynchronous // Is next() required here? }) } In my experience, I typicall ...

The error message from the Three.js program states: "Attempting to access property '0' of an undefined value is not possible."

To create a captivating animation with quaternion data, the following code snippet is utilized: var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 ); var renderer = new THREE.WebG ...

Removing an item from a Firebase array: A step-by-step guide

I'm currently facing a challenge with removing a specific object/field within a document in Firebase. While I can delete entire collections or documents, I'm struggling to delete the name and tag fields associated with a particular ID. Is there a ...

What is the method for determining the size of a WeakMap?

I am working with a WeakMap that looks like the following: let newObj = new WeakMap(); let key1={"a":1}; let key2={"b":2}; let key3={"c":3}; newObj.set(key1,"value1"); newObj.set(key2,"value2"); newObj.set( ...

Implementing a function as the `data-*` attribute for an element in Angular 6

I have a question about my component.ts file: import { Component, OnInit, AfterViewInit, ElementRef, Inject } from '@angular/core'; import { DOCUMENT } from '@angular/platform-browser'; import { environment } from '../../../enviro ...

Tips on separating a function into two separate files in Node.js

Hey there! I am just starting to explore Node.js so bear with me if I make any mistakes. So, I have this file: exports.Client = function() { this.example = function(name, callback) { console.log(name); }; ...

What is the best way to split an array into smaller chunks?

My JavaScript program fetches this array via ajax every second, but the response time for each request is around 3 to 4 seconds. To address this delay, I attempted to split the array into chunks, however, encountered difficulties in completing the task: { ...

Warning: Promise rejection not handled - unable to save data to the database

When data is coming from the req, it is stored in the Comment collection but not in the Product collection, causing an error message to appear. app.post("/products/:id/comments", function(req, res) { //lookup product using ID Product.findById(req ...

Is it possible for AngularJS components to alter their enclosing element?

I see Angular components as element directives. Take a component named hero, for example, I can include it in the parent template like so: <hero myparam="something"></hero> What I envision is using the hero element as a container managed by t ...

What could be the reason for jquery not functioning properly on my website?

Hey there! I'm running into an issue where my jQuery code isn't running. I've tried triggering it on button click or page load, but no luck so far. Any tips would be greatly appreciated. Thanks! <head> <script src ...

Transforming data separated by slashes into a hierarchical tree format

Currently, I am in the process of developing a platform similar to Google Drive. I have successfully implemented the file upload feature and am now focusing on enabling folder uploads using the HTML file input within Next.js/React framework. <input ...