Possibilities of AngularFire, sum of values entered by users, obtaining sum at main site with angular? - angularjs

Suppose we want to develop a website. Key features:
home page (access for all) the main element on the page is the
sum of payments
registration and login page - mail address and password, account activation
the payment will be declared by the registered and logged in users through the form and a checkbox, when the checkbox is selected data should be uploaded to the server and saved if "pass verification" for example, do not exceed $ 10, each user in one day can only declare one payment
after possitive verification the sum from "number 1 above" is updated
additional features - user notification: when the last payment hasn't been made for more than six months, or if the total sum exceeds a certain level eg $ 1,000...
Is it possible that the whole solution would be based on angularfire? In particular:
the sum of payments - on main site the information about
the sum avaible for all visitors, so each time somebody visits the website
we will have to send request to Firebase to get all the records and
add the payments to finally show the sum on web site? With Angular we can do that?
Firebase enables queries/limits: e.g. last 20, but to get the whole amount you need to have knowledge of the previous value - in this case, increase in payments and visits will result in sending large amounts of data client side vs firebase - whether and how it can be optimized?
suppose that the activation of user account will require small payment
(paypal/transfer) is it possible to set account active when the
payment is done?

Related

Firebase Firestore Stock Count updating?

I am using firebase purely to integrate a simple ticket buying system.
I would think this is a very common scenario people have and wondering what the solutions are.
I have an issue with the write limit time, it means I can't keep the stock count updated.
Due to Firebase's 1 second write limit and the way transactions work, they keep timing out when there is a large buy of tickets at one point in time.
For example:
Let's say we have a simple ticket document like this
{
name: "Taylor Bieber Concert"
stock: 100
price: 1000
}
I use a firebase transaction server side that does (pseudo)
transaction{
ticket = t.get(ticketRef).data() //get the data of ticketRef doc
guard (ticket .stock > 0) else return //check the stock is more than 0
t.update(ticketRef, {stock : increment(-1) }) //update the document and remove 1 stock value
}
The transaction and functionality all works however if I get 20-100 people trying to buy a ticket as it releases, it goes into contention it seems and times out a bunch of the requests...
Is there a way to avoid these timeouts? Some sort of queue or something?
I have tried using Transactions server-side in firebase functions to update the stock value, when many people try to purchase the product simultaneously it leads to majority of the transactions being locked out / Aborted Code 10

Using Vlookup inside array formula in Sheets

I have two sheets with relevant columns:
Confirmed Cards
a. Email
b. Credits
Purchase Credits.
a. Email
b. Rolling Total Credits
I'm hoping to populate "Credits" inside of "Confirmed Cards" with "Rolling Total Credits" from "Purchase Credits" by cross-referencing emails to show how many credits a user has.
I'm hoping to do this within an Array Formula, so as users are added to my database within confirmed cards, the amount of credits they own are automatically updated.
This is what I am currently using within "Confirmed Cards" to try to pull in the amount of credits the user has:
=ArrayFormula(VLOOKUP(A2:A,'Purchase Credits'!A2:F,5))
The formula correctly inputs the correct amount of credits for A2, the first user email, however, it inputs this value into every single row, regardless of email. For example, if alex#gmail.com has 100 credits, this amount shows for every single row within "Credits."
you will need 4th vlookup parameter. try:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A, 'Purchase Credits'!A2:F, 5, 0)))

how to pre-fill some parts of an access form?

New here, so be gentle with me. - edited to simplify
I'm trying to set up something in Access where:
user selects driver name and date
query finds stops along the driver's route
form opens with route stops (location details) filled in and user can add additional information (item picked up, weight of item)
all information gets transferred to a "Pickups" table, which has data on what was picked up, the weight, where (route stop) and by whom (driver).
I have stores A through H, and three drivers, Bob, Tom, and Jill. Bob’s route is stores A,B,C,D. Tom’s route is stores A,C,G,H, and Jill’s route is stores D,E,F,G. (I can't give real names/locations - work is very strict about privacy issues!)
Behind these are “Driver” Table, with driver name, ID, and truck info; and “Store” Table, with store name (A-H), address, phone number, and contact person.
We’re collecting all of the information about items picked up at each store into a “Pickup” table, with Fields: Date, Driver, Store, WeightOfFurniture, WeightOfBooks, WeightOfClothes
The user starts with the driver’s name and date, clicks a button, and this opens a form with the following fields:
Driver, Date, Store, WeightOfFurniture, WeightOfBooks, WeightOfClothes
with driver and date filled in based on the initial entry, and “Store” having all listings for a given driver’s route. So I select Bob and a date (11-12) and get a form with:
Name Date Store WtFurn WtBooks WtClothes
Bob 11-12 A
Bob 11-12 B
Bob 11-12 C
Bob 11-12 D
I can get the above information from a query without any problem, but I can't figure out how to (partially) fill the form with the query results (there will be multiple query results for a given route, so DLookup is not useful).
I think recordsets might be a way to go, but not sure how to do this. I'm very new at VBA, but am learning (the hard way!).
Any suggestions?
Thanks!
Use an INSERT INTO action query to insert those records into your Pickup table.
I can get the above information from a query without any problem,
This query is the SELECT FROM part for the INSERT query.
Then open your Pickup form, filtered for Driver, Date and Store that you just inserted.

hMailServer sending limit per day

I want to set a max number of email sent a day for each mailbox on hmailserver to avoid spamming.
I am looking for an issue to do this in hmailserver administration and COM API.
I believe there's no such property in hMailServer. You must define a script on OnAcceptMessage event to implement this behaviour hMailserve doc | OnAcceptMessage.
For the number of emails sent per day you must create some kind of counter (a database table with username, date and count fields) and get the current number of messages in the body of the OnAcceptMessage function. If the count per current user and current day will be reached then reject the email with return code 1 or 2 and a meaningful message. If the count is less return 0 and the email will be sent.

How to combine two search results effectively?

I'm programming a site in PHP/MySQL that gets search results for products via API from an external site. This site also will have it's own products and the owners of the site want the search results to be inter-connected.
If someone searches for VIDEO, ordered by date then the results should be all in order regardless of the source it came from.
eg.
July 31 - Video A - our database
July 30 - Video B - via API
July 29 - Video C - via API
July 28 - Video D - our database
...
The problem I'm having is figuring out a way to do this effectively especially regarding viewing multiple pages of results. If someone clicks to the 2nd page of results then I need to figure out the last item on the first page of results (and the last item from the API), then only get the items from the API starting after the last API item viewed on the previous page and then do the same for our database results and re-combine them again.
In order to avoid this complex algorithm, another idea I had was to limit the results to a large amount - like 500 results and grab them all at once and order them. Then if the user goes forward a few pages, I do not have to re-grab all the data.
Does anyone have suggestions on good algorithms to use to combine two search results?
Whether you use it for caching or not, you will need to grab at least a page worth of results from both sources, in case all the next results will come from that source.
Grabbing a lot of results and caching them (in the session) is one solution you could use.
If for some reason you don't want to cache all the results (if the operation is expensive and you need this optimized), you could store a simple array in the session that contains the location of the results, and then you would know the starting number for the next page.
For example (pseudo code)
**Request 1**
Get 10 results from API
Get 10 results form Database
Merge the results
Display first 10 and save the order to an array
(A for API, D for Database, ex: A,A,A,D,A,D,D,A,D,A)
User clicks page 2
**Request 2** (Page 2)
Get 10 results from API starting at 5
Get 10 results from Database starting at 7
Repeat merge and display above.
You could also optionally cache what you have needed to retrieve so far (and you will have 10 extra results). This would make the first request longer, but could possibly make the second request much faster.
If the user jumps forward several pages, you would need to get the largest number of results that could have been displayed in the preceeding unknown pages from each source.
If you are not too worried about performance from either source, I would retrieve up to a large number like you said and cache all results temporarily. As soon as a new search is executed, dump the old results.

Resources