feat: Create reports for tracked private projects
Relates to #81 (closed)
Merge request reports
Activity
added 2 commits
added 1 commit
- f7d39f1f - feat: Add date filtering on query and service
25 import org.eclipsefoundation.git.eca.service.ReportsService; 26 import org.slf4j.Logger; 27 import org.slf4j.LoggerFactory; 28 29 @Path("/reports") 30 public class ReportsResource { 31 private static final Logger LOGGER = LoggerFactory.getLogger(ReportsResource.class); 32 33 private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); 34 35 @Inject 36 ReportsService reportsService; 37 38 @GET 39 @Path("/webhooks/gitlab/system") 40 public Response getPrivateProjectEvents(@QueryParam("status") String status, @QueryParam("since") String since, rather than handle date conversion here, we should use a https://docs.jboss.org/resteasy/docs/3.5.0.Final/userguide/html/StringConverter.html and add support for LocalDate. LocalDate also parses and prints in the exact format we want so its a really easy swap in.
changed this line in version 10 of the diff
29 import org.eclipsefoundation.persistence.model.RDBMSQuery; 30 import org.eclipsefoundation.persistence.service.FilterService; 31 import org.jboss.resteasy.specimpl.MultivaluedMapImpl; 32 import org.slf4j.Logger; 33 import org.slf4j.LoggerFactory; 34 35 @ApplicationScoped 36 public class DefaultReportsService implements ReportsService { 37 38 private static final Logger LOGGER = LoggerFactory.getLogger(DefaultReportsService.class); 39 40 @Inject 41 PersistenceDao dao; 42 43 @Inject 44 RequestWrapper wrap; changed this line in version 10 of the diff
19 import javax.ws.rs.Path; 20 import javax.ws.rs.QueryParam; 21 import javax.ws.rs.core.Response; 22 import javax.ws.rs.ext.ParamConverter; 23 24 import org.apache.commons.lang3.StringUtils; 25 import org.eclipsefoundation.git.eca.namespace.GitEcaParameterNames; 26 import org.eclipsefoundation.git.eca.service.ReportsService; 27 28 @Path("/reports") 29 public class ReportsResource { 30 31 @Inject 32 ReportsService reportsService; 33 @Inject 34 ParamConverter<LocalDate> dateConverter; That's not how you use param converters. Param converter providers are picked up on launch and registered. These would then be iterated over and allow you to do
@QueryParam("date") LocalDate date
as an example and have it automatically convert from the string value for you. The ParamConverter is not a service, it is a disposable instance that can be quickly created and discarded if needed. The implementation in the given link is the pattern you should use.changed this line in version 10 of the diff
6 * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 * 8 * Author: Zachary Sabourin <zachary.sabourin@eclipse-foundation.org> 9 * 10 * SPDX-License-Identifier: EPL-2.0 11 **********************************************************************/ 12 package org.eclipsefoundation.git.eca.service.impl; 13 14 import java.time.LocalDate; 15 import java.time.format.DateTimeFormatter; 16 17 import javax.enterprise.context.ApplicationScoped; 18 import javax.ws.rs.BadRequestException; 19 import javax.ws.rs.ext.ParamConverter; 20 21 @ApplicationScoped changed this line in version 10 of the diff
9 * 10 * SPDX-License-Identifier: EPL-2.0 11 **********************************************************************/ 12 package org.eclipsefoundation.git.eca.service.impl; 13 14 import java.time.LocalDate; 15 import java.time.format.DateTimeFormatter; 16 17 import javax.enterprise.context.ApplicationScoped; 18 import javax.ws.rs.BadRequestException; 19 import javax.ws.rs.ext.ParamConverter; 20 21 @ApplicationScoped 22 public class LocalDateParamConverter implements ParamConverter<LocalDate> { 23 24 private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); changed this line in version 10 of the diff
1 /********************************************************************* changed this line in version 10 of the diff
93 93 500: 94 94 description: Error while processing data 95 95 96 /reports/webhooks/gitlab/system: changed this line in version 10 of the diff
mentioned in commit 127895b9