Skip to content

Commit

Permalink
Site edit fixes (#35)
Browse files Browse the repository at this point in the history
* Trigger changelog when stall count changes
* Add /siteadmin/allHosts endpoint
* Update API reference, update version to 6.2.0
  • Loading branch information
paulkva authored May 26, 2024
1 parent fe15d1c commit f346091
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 5 deletions.
Binary file modified documents/api-reference.ods
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>info.supercharge.api</groupId>
<artifactId>supercharge.info-api</artifactId>
<version>6.1.0</version>
<version>6.2.0</version>


<properties>
Expand Down
2 changes: 1 addition & 1 deletion service-dao/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>info.supercharge.api</groupId>
<artifactId>supercharge.info-api</artifactId>
<version>6.1.0</version>
<version>6.2.0</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import com.google.common.collect.Maps;
import com.redshiftsoft.tesla.dao.BaseDAO;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -75,4 +77,9 @@ public void delete(int siteId) {
addressDAO.delete(site.getAddress().getId());
getJdbcTemplate().update("DELETE FROM site WHERE site_id=?", siteId);
}

public List<String> getDistinctHosts() {
String SQL = "SELECT DISTINCT facility_name FROM site WHERE facility_name IS NOT NULL ORDER BY facility_name";
return getJdbcTemplate().queryForList(SQL, String.class);
}
}
2 changes: 1 addition & 1 deletion service-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>info.supercharge.api</groupId>
<artifactId>supercharge.info-api</artifactId>
<version>6.1.0</version>
<version>6.2.0</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ private JsonResponse handleEdit(User user, Site site, SiteEditDTO.NotifyEnum not

Site oldSite = siteDAO.getById(site.getId());
SiteStatus oldSiteStatus = oldSite.getStatus();
int oldStallCount = oldSite.getStallCount();

boolean changes = siteDiffLogger.record(user, oldSite, site);
if (!changes) {
Expand All @@ -141,7 +142,7 @@ private JsonResponse handleEdit(User user, Site site, SiteEditDTO.NotifyEnum not
messages.add(format("UPDATED site '%s'", site.getName()));
siteDAO.update(site);

if (oldSiteStatus != site.getStatus() && !SiteEditDTO.NotifyEnum.no.equals(notify)) {
if ((oldSiteStatus != site.getStatus() || oldStallCount != site.getStallCount()) && !SiteEditDTO.NotifyEnum.no.equals(notify)) {
ChangeLogEdit changeLogEdit = ChangeLogEdit.toPersist(site.getId(), ChangeType.UPDATE, site.getStatus(), Instant.now(), Instant.now(), SiteEditDTO.NotifyEnum.yes.equals(notify), user.getId(), site.getStallCount());
if (changeLogDAO.getSiteList(site.getId()).isEmpty()) {
changeLogEdit.setChangeType(ChangeType.ADD);
Expand Down Expand Up @@ -282,4 +283,20 @@ public List<ChangeLogEditDTO> listChangeEdits(@RequestParam int siteId) {
}


// - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
// get distinct list of hosts (facilityName) across all sites
//
// - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@PreAuthorize("hasAnyRole('editor')")
@RequestMapping(method = RequestMethod.GET, value = "/allHosts")
@ResponseBody
@Transactional
public List<String> allHosts() {
return siteDAO.getDistinctHosts().stream()
.collect(Collectors.toList());
}


}
2 changes: 1 addition & 1 deletion web-scrape/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>info.supercharge.api</groupId>
<artifactId>supercharge.info-api</artifactId>
<version>6.1.0</version>
<version>6.2.0</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down

0 comments on commit f346091

Please sign in to comment.