0

I have a code in python which I use to retrieve issues from redmine project.
I am using the python-redmine library.
My code is as below:

from redminelib import Redmine  
from datetime import datetime  
from datetime import timedelta  

time = datetime.now()  
checktime = time -timedelta(minutes = 5)  

redmine = Redmine('*redmine url*',key = '*admin key*')  
issues = redmine.issue.filter(project_id = "*project*", status_id = "1", created_on = '>=%s'%checktime.strftime('%Y-%m-%dT%H:%M:%SZ'))  

for issue in issues:  
*rest of code*  

The requirement is to fetch redmine issues created in the last five minutes. However no record is being fetched in the above code.

If i use:

issues = redmine.issue.filter(project_id = "*project*", status_id = "1", created_on = '>=%s'%checktime.strftime('%Y-%m-%d'))  

records are being fetched - albeit for the whole day.

Could someone point out what is incorrect in the time filter which is preventing the redmine records from being retrieved.

The datetime format in the redmine instance is 2017-08-18 16:31:04

Vivek B Ahmed
  • 33
  • 1
  • 8

1 Answers1

0

You can filter using a datetime ONLY in Redmine 2.5 or higher:

http://www.redmine.org/issues/8842

You might want to verify the version of Redmine you are using. I tried your code works with Redmine 3.3.1 but not with 1.0.1

Tuxdude
  • 47,485
  • 15
  • 109
  • 110
  • If you have a new question, please ask it by clicking the [Ask Question](https://stackoverflow.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/low-quality-posts/17132850) – Tony Babarino Aug 24 '17 at 14:10
  • 1
    @tony Thanks for pointing that out. We are using redmine 3.2.5. We found a workaround to the issue. We intialised the redmine instance as Redmine('url', key = '', datetime_format='%Y-%m-%dT%H:%M:%S'). This set the datetime format and the we queried using that datetime format :) – Vivek B Ahmed Aug 28 '17 at 10:32