Laravel, have a limited amount of post each day - forms

I was wondering if Laravel has an implemented way to limit the submits of a form. I would like to work with a day limit that resets every day.
So for example: I want to limit the submits of a referal form. Each user can refer 3 times a day.
How do I manage the amount of submits? And how do I reset the limit every day?

When you're validating the form submission, you can query the database and count how many time this user (or IP address, or else, depending on what you use to track the users) submitted the form in the last day.
Laravel uses the Carbon library, and it provides very easy way to get the date of "one day ago", you could use that for your query.
The specific implementation will depend on how you track users and when you reset - at a set hour once per day, or the time doesn't matter as long as they don't submit a form more than three times in 24 hours.

Related

Using a holiday calendar in kdb?

has anyone ever implemented a holiday calendar in kdb?
it's pretty easy to exclude weekends or to create a function to get nextweekday or previous weekday, but what if you want to also take into account public holidays / bank holidays?
What have people done in order to account for this?
A rudimentary way is to create a file with known bank holidays across LDN & NY let's say - but is there a more automated way?
You may want to take a look at holiday.q on Github. Note that NYSE rules change from time to time so you may need to make some adjustments to bring that code up to date.
Most places will have purchased some form of calendar data product (.e.g Copp Clark). From that you'd build a suite of functions for getPrevBizDay etc, and you'd do it for all regions. It will also have future holidays.
Alternatively I'm sure there are some open source holiday data downloads you could scrape from the web and from them you could manually put together a table (perhaps it would be an annual once-off process to update it for the next year).

Facebook Marketing API - Keywordstats empty

I am working with ADs api and using keywordstats.
It worked well, now I am getting some weird responses, or maybe it should be like that.
I created AD 7 days ago, 24 days after using keywordstats and fields like, cpc, actions, impressions, unique_actions returned me good results, matched at what I was seeing on ADS manager. AD was live one day.
Now 6 days after after, actions and unique actions has only one element "attention_event"? Impressions by each interest are also weird, for each I am getting from 1 to 5? In total I have more then 5K impressions, how is this possible? I have tried with specific dates, for one day it returns this weird data, for other days just returns empty response.
Actions fields, 6 days ago contained and events from FB Pixel, now none is returned in response.
Is this supposed to work like this, or I am missing something?
I've also dealt with some bugginess with the keywordstats endpoint.
If you look at the API documentation, you'll see a particular line: "To query from a particular day in the last week:". It seems like Facebook doesn't allow you to query for keywordstats that aren't from the past week. The discrepancy between metrics might arise because of this.
For some more context, I've found that even the last seven days isn't a reliable indicator of retrievable dates. I had to query each date individually (using <API_VERSION>/<AD_ID>/keywordstats?date=YYYY-MM-DD) and see which ones don't return an empty object. The dates that do return a metric are the ones that you should use in your calculations.

Identifying the last time customers ordered a particular item and have them enter a workflow

I have made a Customer search that identifying the customers that haven't purchased an item in six months or more. I've used group summaries and maximum summaries for the company name and the maximum transaction date, which refers to the latest sales order containing a certain item. The idea is to send them an email. However, the workflow is only executing on 20 records at a time. i even conducted a search that was not summarized and the workflow still only executed on 20 records. I did use the "Execute Now" button in testing mode to see how many entered the work flow from the summary search. But each execution only yields 20 workflow instances. the searches yield about 213 and 300 records respectively. I appreciate any insight!
Workflows using searches will only process 20 records when in testing mode.
From SuiteAnswers Article 36738 (NetSuite Login required)
When you execute a workflow on demand, NetSuite only processes the first 20 records returned by the saved search. For example, if the saved search for a scheduled workflow returns 1000 records, the workflow only initiates on the first 20 records returned by the saved search.

DialogFlow confuses time and number

I want to define an intent PlaceReservation that would capture a restaurant reservation. The parameters for that would be numOfPeople and time. Both of those parameters are optional, so a user can say:
get a table for 5 people for 9pm
get a table for 5 people
get a table for 9pm
get a table
get a table for 5
get a table for 9pm for 5 people
get a table for 5 for 9pm
My problem is with the last one, get a table for 5 for 9pm the intent then captures 5 as the hour (5am) and ignores 9pm.
time is defined as a #sys.time system entity.
Is there a way to tell it to not accept simple integers as time, as I think this is what is confusing it?
Is there some other solution I'm missing?
I certainly understand why it is making the mistake, but we, as humans understand how to interpret it, and I want to help DialogFlow interpret it accordingly.
I've had a similar problem and haven't found a proper solution for it yet. In your case you could define your own time entity that consists of entries like 9pm or 10am or even expand it with a composite entity to also let users say "10 in the morning" https://dialogflow.com/docs/entities#dev_composite.
This is definitely confusing for the bot to understand/interpret which one is time & which one is the number of people. Even creating a separate entity for time like 9am/10am won't work cause this does not guarantee that user will enter 9am/pm only. They may not append am/pm ahead of time as well. The solution to your problem can be creating separate intents, first asking users for time & then for number of people. This way you reduce the complexity & can train the bot in a proper way. In addition, you can direct user to a certain direction instead of keeping your bot open for questions.

Speed up fetch of EKEvents

in my app I'm displaying a list of EKEvents and I would like to display all events of a month in a UITableView, each section containing the respective days. Well, this works and I get all the data, I need, but the fetch is very slow.
The problem consists in events, which spread across multiple days.
Let's say I'm going on vacation from 10th of November until 17th of November.
My search predicate has a startDate with 1st of November and an endDate with 30th of November.
I do an enumerateEventsMatchingPredicate or eventsMatchingPredicate, whatever, both are slow.
I get an array in return with all events taking place in November, as well as my vacation.
But my vacation is just one EKEvent object. So if I want to display a monthly list view of events it would only appear once, on 10th of November, but for reasons of clarity I would to show it on every day it takes place, 10th, 11th, ... 17th.
So what I do is, iterate over each day in a month and do a fetch :-/ This way I get the correct amount of events that take place on a specific day, but ... it feels so complicated.
I already put the fetch into a dispatch_async, so the fetch doesn't block the UI and after the fetch is finished the tableView gets reloaded and cells redrawn. But it still takes time. No userfriendly time.
How do you perform those searches? Do you have any tips on how to speed up the search, maybe a little code snippet or can point me in the right direction!?
Is my question clear? :-/
Thanks,
-Martin.
Fetches are slow especially if there is a lot of recurring events. What I did in my app, is to fetch only once, and parse whole-day-multiple-spanning-day-events to chunks. I abstracted events: I create "date" class, which has NSString properties usable as section titles in table view, and one of its ivars is array with matching "events". "events" are not EKEvents, but my class, to which I copy needed properties from EKEvents. From multiple day spanning single whole day EKEvent I create corresponding "events". Parsing is quite quick - the slowdown is when getting properties from fetched recurring EKEvents.