Project

General

Profile

Increase limit of time_entries query past 100

Added by George Theophanous over 8 years ago

Hello,
I am working as an intern at a company that does webdev and we use redmine 2.2.2.stable.

I have been tasked with making a ruby script that gets everyone's total logged time within a week, and then sending out emails to whoever did not fill their 30 hour quota of spent time.

I am using a variable to store the response of a query, and then parsing the string on my own (which I am able to do):
using HTTParty, I can make queries quite easily.

the code where I do the query:
response = HTTParty.get("https://projects.bencrudo.com/time_entries.json?key="+key+"&from="+datestr1+"&to="+datestr2+"&limit=100")

datestr1 and datestr2 are strings in the proper format representing the start and end date of the time entries I wish to get.
My problem lies in the limit parameter. Whenever I try to increase the limit past 100, it doesn't go further (I read somewhere that this is intended).
The number of employees (the company is growing fast) and projects we work on makes it so that within a week, we are well beyond 300 time entries.

1)Is there an easy way for me to get ALL of the time entries within a week without being limited by the 100 per query? Or is there a way for me to loop through queries until there are no more time entries? (this condition, i.e. "until there are no more time entries to look at" is what I can't seem to figure out)

2)Say I can get ALL the time entries I need, is there a way to retrieve a user's email without having to do an additional query (get users) to retrieve their email?

It seems to me like there should be an efficient way of doing it. For now, I am performing a 100-limit query on each day of the week, then parsing those responses in the following way:

I have an array that stores user's names and hours spent within a week.

for each time entry (in the response text):
- if the user's name is not in the array, make a new element in the array. Otherwise, add the time of that entry to the corresponding employee in the array.

Since our clients have access to redmine for communication purposes, they sometimes make time entries, so I have to accomodate that in the following way
Pull a list of our employees form a config file, and for each element in the time array ive created, if the element is one of our employees, keep it, check if it's >= 30. If not, send them an email.

I don't really care about the whole email issue because I wrote my own auto-mailer script, and worst case scenario I just put the employee emails in the config file.
My issue is getting all the time entries for a week, or month, efficiently. This script should be able to be used for a week where there is only 1 time entry, or a week where there are 1000 time entries. That shouldn't matter.

Language: pure ruby
redmine version: 2.2.2.stable
using HTTParty

Thanks in advance!

George T
Cheers