limit response fields

Issue #547 resolved
Max Neverov created an issue

Hi, thank you for your plugin!

Is it possible to reduce the response to only one field? I would like to automate our jira reminderings and to avoid parsing it would be great to have something like this (in terms of SQL):

select email
from users
where (select sum(timespent)
            from users
            group by user_id) < 8 hours;

So the response will contain only the list of users who hadn't track jira for yesterday for example.

Comments (12)

  1. Andriy Zhdanov

    Hi Max,

    No, but I can add user email to raw-timesheet REST response (see here), would it help? Then you can perform request daily with startDate and endDate for previous day, and group by user and find entries with < 8 hours.

    Note, I'm influenced by this question also, may be your goal is a bit different.

  2. Max Neverov reporter

    Hi Andriy,

    Thanks for the quick response! Yes, it might help.

    Sorry for asking you here but when I'm send REST request with following url http://my_server_url/rest/timesheet-gadget/1.0/raw-timesheet.json?startDate=2014-08-18&endDate=2014-08-19 it returns me the following:

    {
       "worklog" :
          [
             {
                "key" : "some key",
                "summary" : "Miscellaneous",
                "entries" :
                   [
                      {
                         "comment" : "my comment",
                         "timeSpent" : 21600,
                         "author" : "me",
                         "authorFullName" : "full name of me",
                         "created" : 1408430793000,
                         "startDate" : 1408344300000,
                         "updateAuthor" : "me",
                         "updateAuthorFullName" : "me again",
                         "updated" : 1408430793000
                      }
                   ]
             }
          ],
       "startDate" : 1408312800000,
       "endDate" : 1408572000000
    }
    

    Timespent here is my total timespent for this task ever. Can I get total timespent for mentioned period of time ? Also, if I'm including &targetGroup="jira-users" or &targetGroup="my_team_group" it returns me an empty response:

    {
       "worklog" :
          [
          ],
       "startDate" : 1408312800000,
       "endDate" : 1408485600000
    }
    

    It's likely that I'm doing something wrong:)

    Could you please point to documentation or provide right arguments please?

    Thanks!

  3. Andriy Zhdanov

    Hm, it should return only worklogs for the specified period, but period for one day should be startDate=2014-08-19&endDate=2014-08-19. I.e. startDate is the same as endDate, e.g.

    {  
       "worklog":[  
          {  
             "key":"DEMO-6",
             "summary":"What's next?",
             "entries":[  
                {  
                   "comment":"test",
                   "timeSpent":18000,
                   "author":"admin",
                   "authorFullName":"admin",
                   "created":1408519248487,
                   "startDate":1408399200000,
                   "updateAuthor":"admin",
                   "updateAuthorFullName":"admin",
                   "updated":1408519248487
                },
                {  
                   "comment":"test3",
                   "timeSpent":3600,
                   "author":"admin",
                   "authorFullName":"admin",
                   "created":1408519609192,
                   "startDate":1408433160000,
                   "updateAuthor":"admin",
                   "updateAuthorFullName":"admin",
                   "updated":1408519663386
                }
             ]
          }
       ],
       "startDate":1408399200000,
       "endDate":1408485600000
    }
    
  4. Max Neverov reporter

    My bad.

    I misunderstood timeSpent field - it shows time in seconds so that's ok.

    What about worklog of other team members? Is it possible with REST to retrieve all data for group or project?

  5. Andriy Zhdanov

    Glad it works :) You can use targetGroup or projectid request parameters to retrieve all data for group or project.

    So, if you find this approach useful, please let me know if you need authorEmail be added.

    Thank you.

  6. Max Neverov reporter

    Actually when I'm requesting with &targetGroup="jira-users" or &targetGroup="my_team_group" it returns empty response like I mentioned earlier.

    Can I get worklogs for all group members or it is only for a current user? If it possible to get worklog for every user in group then authorEmail field would be very helpful.

    Thank in advance!

  7. Andriy Zhdanov

    Hm, it may be because of restricted visibility, check Administration - Add-Ons - Timesheet Configuration, make sure you don't have Timesheet Auditors Groups or Roles or Restricted Groups set; or your user matches the settings.

  8. Andriy Zhdanov

    I'm terribly sorry, it's not that easy to add authorEmail, but it is easy to get all emails for group members, like this: /rest/api/2/group?groupname=jira-users&expand=users

  9. Andriy Zhdanov

    No problem, hope it will work out, after all. If you find it appropriate, please share your script, once you're happy with it :)

    I'm marking it as resolved, please reopen if needed.

    Thank you.

  10. Log in to comment