mirror of
https://github.com/HangarMC/Hangar.git
synced 2024-11-21 01:21:54 +08:00
remove refresh hack
This commit is contained in:
parent
4ff62c84a3
commit
debd074388
5
pom.xml
5
pom.xml
@ -180,11 +180,6 @@
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.impossibl.pgjdbc-ng</groupId>
|
||||
<artifactId>pgjdbc-ng</artifactId>
|
||||
<version>0.8.9</version>
|
||||
</dependency>
|
||||
|
||||
<!-- flyway -->
|
||||
<dependency>
|
||||
|
@ -1,5 +1,24 @@
|
||||
package io.papermc.hangar.controller.internal.projects;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.view.RedirectView;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import io.papermc.hangar.HangarComponent;
|
||||
import io.papermc.hangar.exceptions.HangarApiException;
|
||||
import io.papermc.hangar.exceptions.InternalHangarException;
|
||||
@ -24,30 +43,11 @@ import io.papermc.hangar.security.annotations.visibility.VisibilityRequired.Type
|
||||
import io.papermc.hangar.service.internal.admin.StatService;
|
||||
import io.papermc.hangar.service.internal.organizations.OrganizationService;
|
||||
import io.papermc.hangar.service.internal.perms.members.ProjectMemberService;
|
||||
import io.papermc.hangar.service.internal.projects.HomeProjectService;
|
||||
import io.papermc.hangar.service.internal.projects.ProjectFactory;
|
||||
import io.papermc.hangar.service.internal.projects.ProjectService;
|
||||
import io.papermc.hangar.service.internal.uploads.ImageService;
|
||||
import io.papermc.hangar.service.internal.users.UserService;
|
||||
import io.papermc.hangar.service.internal.users.invites.ProjectInviteService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.view.RedirectView;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Controller
|
||||
@RateLimit(path = "project")
|
||||
@ -62,10 +62,9 @@ public class ProjectController extends HangarComponent {
|
||||
private final OrganizationService organizationService;
|
||||
private final ImageService imageService;
|
||||
private final StatService statService;
|
||||
private final HomeProjectService homeProjectService;
|
||||
|
||||
@Autowired
|
||||
public ProjectController(ProjectFactory projectFactory, ProjectService projectService, UserService userService, OrganizationService organizationService, ProjectMemberService projectMemberService, ProjectInviteService projectInviteService, ImageService imageService, StatService statService, HomeProjectService homeProjectService) {
|
||||
public ProjectController(ProjectFactory projectFactory, ProjectService projectService, UserService userService, OrganizationService organizationService, ProjectMemberService projectMemberService, ProjectInviteService projectInviteService, ImageService imageService, StatService statService) {
|
||||
this.projectFactory = projectFactory;
|
||||
this.projectService = projectService;
|
||||
this.userService = userService;
|
||||
@ -74,7 +73,6 @@ public class ProjectController extends HangarComponent {
|
||||
this.projectInviteService = projectInviteService;
|
||||
this.imageService = imageService;
|
||||
this.statService = statService;
|
||||
this.homeProjectService = homeProjectService;
|
||||
}
|
||||
|
||||
@LoggedIn
|
||||
@ -98,7 +96,7 @@ public class ProjectController extends HangarComponent {
|
||||
public ResponseEntity<String> createProject(@RequestBody @Valid NewProjectForm newProject) {
|
||||
ProjectTable projectTable = projectFactory.createProject(newProject);
|
||||
// need to do this here, outside of the transactional
|
||||
homeProjectService.refreshHomeProjects();
|
||||
projectService.refreshHomeProjects();
|
||||
return ResponseEntity.ok(projectTable.getUrl());
|
||||
}
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
package io.papermc.hangar.service.internal.projects;
|
||||
|
||||
import com.impossibl.postgres.jdbc.PGDataSource;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Service
|
||||
public class HomeProjectService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HomeProjectService.class);
|
||||
|
||||
private final String url;
|
||||
private final String username;
|
||||
private final String password;
|
||||
|
||||
public HomeProjectService(@Value("${spring.datasource.url}") String url, @Value("${spring.datasource.username}") String username, @Value("${spring.datasource.password}") String password) {
|
||||
this.url = url.replace("postgresql", "pgsql");
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
private Connection getConnection() throws SQLException {
|
||||
// force using pgjdbc-ng since that doesn't do dum begin queries that break cockroach
|
||||
PGDataSource ds = new PGDataSource();
|
||||
ds.setDatabaseUrl(url);
|
||||
// ds.setSqlTrace(true);
|
||||
return ds.getConnection(username, password);
|
||||
}
|
||||
|
||||
// if it works, it's not wrong, right?
|
||||
public void refreshHomeProjects() {
|
||||
try (var con = getConnection();
|
||||
var stmt = con.createStatement()) {
|
||||
stmt.execute("REFRESH MATERIALIZED VIEW home_projects");
|
||||
} catch (SQLException e) {
|
||||
if (e.getMessage().contains("Unsupported database URL")) {
|
||||
logger.warn("Unsupported database URL: {}", url);
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,11 @@
|
||||
package io.papermc.hangar.service.internal.projects;
|
||||
|
||||
import org.jdbi.v3.core.enums.EnumByName;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import io.papermc.hangar.HangarComponent;
|
||||
import io.papermc.hangar.db.dao.internal.table.projects.ProjectsDAO;
|
||||
import io.papermc.hangar.exceptions.HangarApiException;
|
||||
@ -20,11 +26,6 @@ import io.papermc.hangar.service.internal.uploads.ProjectFiles;
|
||||
import io.papermc.hangar.service.internal.visibility.ProjectVisibilityService;
|
||||
import io.papermc.hangar.util.FileUtils;
|
||||
import io.papermc.hangar.util.StringUtils;
|
||||
import org.jdbi.v3.core.enums.EnumByName;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class ProjectFactory extends HangarComponent {
|
||||
@ -39,10 +40,9 @@ public class ProjectFactory extends HangarComponent {
|
||||
private final JobService jobService;
|
||||
private final ProjectFiles projectFiles;
|
||||
private final ValidationService validationService;
|
||||
private final HomeProjectService homeProjectService;
|
||||
|
||||
@Autowired
|
||||
public ProjectFactory(ProjectsDAO projectDAO, ProjectService projectService, ChannelService channelService, ProjectPageService projectPageService, ProjectMemberService projectMemberService, ProjectVisibilityService projectVisibilityService, UsersApiService usersApiService, JobService jobService, ProjectFiles projectFiles, ValidationService validationService, HomeProjectService homeProjectService) {
|
||||
public ProjectFactory(ProjectsDAO projectDAO, ProjectService projectService, ChannelService channelService, ProjectPageService projectPageService, ProjectMemberService projectMemberService, ProjectVisibilityService projectVisibilityService, UsersApiService usersApiService, JobService jobService, ProjectFiles projectFiles, ValidationService validationService) {
|
||||
this.projectsDAO = projectDAO;
|
||||
this.projectService = projectService;
|
||||
this.channelService = channelService;
|
||||
@ -53,7 +53,6 @@ public class ProjectFactory extends HangarComponent {
|
||||
this.jobService = jobService;
|
||||
this.projectFiles = projectFiles;
|
||||
this.validationService = validationService;
|
||||
this.homeProjectService = homeProjectService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -96,7 +95,7 @@ public class ProjectFactory extends HangarComponent {
|
||||
projectsDAO.update(projectTable);
|
||||
actionLogger.project(LogAction.PROJECT_RENAMED.create(ProjectContext.of(projectTable.getId()), author + "/" + compactNewName, author + "/" + oldName));
|
||||
jobService.save(new UpdateDiscourseProjectTopicJob(projectTable.getId()));
|
||||
homeProjectService.refreshHomeProjects();
|
||||
projectService.refreshHomeProjects();
|
||||
return StringUtils.slugify(compactNewName);
|
||||
}
|
||||
|
||||
@ -133,7 +132,7 @@ public class ProjectFactory extends HangarComponent {
|
||||
} else {
|
||||
jobService.save(new UpdateDiscourseProjectTopicJob(projectTable.getId()));
|
||||
projectVisibilityService.changeVisibility(projectTable, Visibility.SOFTDELETE, comment);
|
||||
homeProjectService.refreshHomeProjects();
|
||||
projectService.refreshHomeProjects();
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,6 +141,6 @@ public class ProjectFactory extends HangarComponent {
|
||||
FileUtils.deleteDirectory(projectFiles.getProjectDir(projectTable.getOwnerName(), projectTable.getName()));
|
||||
jobService.save(new DeleteDiscourseTopicJob(projectTable.getId()));
|
||||
projectsDAO.delete(projectTable);
|
||||
homeProjectService.refreshHomeProjects();
|
||||
projectService.refreshHomeProjects();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,25 @@
|
||||
package io.papermc.hangar.service.internal.projects;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
import io.papermc.hangar.HangarComponent;
|
||||
import io.papermc.hangar.db.dao.internal.HangarUsersDAO;
|
||||
import io.papermc.hangar.db.dao.internal.projects.HangarProjectsDAO;
|
||||
@ -28,25 +48,6 @@ import io.papermc.hangar.service.internal.uploads.ProjectFiles;
|
||||
import io.papermc.hangar.service.internal.versions.RecommendedVersionService;
|
||||
import io.papermc.hangar.service.internal.visibility.ProjectVisibilityService;
|
||||
import io.papermc.hangar.util.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
public class ProjectService extends HangarComponent {
|
||||
@ -60,10 +61,9 @@ public class ProjectService extends HangarComponent {
|
||||
private final ProjectFiles projectFiles;
|
||||
private final PermissionService permissionService;
|
||||
private final RecommendedVersionService recommendedVersionService;
|
||||
private final HomeProjectService homeProjectService;
|
||||
|
||||
@Autowired
|
||||
public ProjectService(ProjectsDAO projectDAO, HangarUsersDAO hangarUsersDAO, HangarProjectsDAO hangarProjectsDAO, ProjectVisibilityService projectVisibilityService, OrganizationService organizationService, ProjectPageService projectPageService, ProjectFiles projectFiles, PermissionService permissionService, RecommendedVersionService recommendedVersionService, HomeProjectService homeProjectService) {
|
||||
public ProjectService(ProjectsDAO projectDAO, HangarUsersDAO hangarUsersDAO, HangarProjectsDAO hangarProjectsDAO, ProjectVisibilityService projectVisibilityService, OrganizationService organizationService, ProjectPageService projectPageService, ProjectFiles projectFiles, PermissionService permissionService, RecommendedVersionService recommendedVersionService) {
|
||||
this.projectsDAO = projectDAO;
|
||||
this.hangarUsersDAO = hangarUsersDAO;
|
||||
this.hangarProjectsDAO = hangarProjectsDAO;
|
||||
@ -73,7 +73,6 @@ public class ProjectService extends HangarComponent {
|
||||
this.projectFiles = projectFiles;
|
||||
this.permissionService = permissionService;
|
||||
this.recommendedVersionService = recommendedVersionService;
|
||||
this.homeProjectService = homeProjectService;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -139,7 +138,7 @@ public class ProjectService extends HangarComponent {
|
||||
projectTable.setDonationEnabled(settingsForm.getSettings().getDonation().isEnable());
|
||||
projectTable.setDonationSubject(settingsForm.getSettings().getDonation().getSubject());
|
||||
projectsDAO.update(projectTable);
|
||||
homeProjectService.refreshHomeProjects();
|
||||
refreshHomeProjects();
|
||||
// TODO what settings changed
|
||||
projectTable.logAction(this.actionLogger, LogAction.PROJECT_SETTINGS_CHANGED, "", "");
|
||||
}
|
||||
@ -207,6 +206,10 @@ public class ProjectService extends HangarComponent {
|
||||
return projectsDAO.getProjectWatchers(projectId);
|
||||
}
|
||||
|
||||
public void refreshHomeProjects() {
|
||||
hangarProjectsDAO.refreshHomeProjects();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <T> ProjectTable getProjectTable(@Nullable T identifier, @NotNull Function<T, ProjectTable> projectTableFunction) {
|
||||
if (identifier == null) {
|
||||
|
@ -23,6 +23,8 @@ import io.papermc.hangar.model.internal.api.requests.versions.UpdatePluginDepend
|
||||
import io.papermc.hangar.model.internal.logs.LogAction;
|
||||
import io.papermc.hangar.model.internal.logs.contexts.VersionContext;
|
||||
import io.papermc.hangar.service.internal.projects.ChannelService;
|
||||
import io.papermc.hangar.service.internal.projects.ProjectService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -45,9 +47,10 @@ public class VersionDependencyService extends HangarComponent {
|
||||
private final PlatformVersionDAO platformVersionDAO;
|
||||
private final ChannelService channelService;
|
||||
private final VersionTagService versionTagService;
|
||||
private final ProjectService projectService;
|
||||
|
||||
@Autowired
|
||||
public VersionDependencyService(ProjectVersionDependenciesDAO projectVersionDependencyDAO, VersionsApiDAO versionsApiDAO, ProjectsDAO projectsDAO, ProjectVersionPlatformDependenciesDAO projectVersionPlatformDependencyDAO, PlatformVersionDAO platformVersionDAO, ChannelService channelService, VersionTagService versionTagService) {
|
||||
public VersionDependencyService(ProjectVersionDependenciesDAO projectVersionDependencyDAO, VersionsApiDAO versionsApiDAO, ProjectsDAO projectsDAO, ProjectVersionPlatformDependenciesDAO projectVersionPlatformDependencyDAO, PlatformVersionDAO platformVersionDAO, ChannelService channelService, VersionTagService versionTagService, ProjectService projectService) {
|
||||
this.projectVersionDependenciesDAO = projectVersionDependencyDAO;
|
||||
this.versionsApiDAO = versionsApiDAO;
|
||||
this.projectsDAO = projectsDAO;
|
||||
@ -55,6 +58,7 @@ public class VersionDependencyService extends HangarComponent {
|
||||
this.platformVersionDAO = platformVersionDAO;
|
||||
this.channelService = channelService;
|
||||
this.versionTagService = versionTagService;
|
||||
this.projectService = projectService;
|
||||
}
|
||||
|
||||
public List<ProjectVersionDependencyTable> getProjectVersionDependencyTables(long versionId) {
|
||||
@ -114,6 +118,7 @@ public class VersionDependencyService extends HangarComponent {
|
||||
}
|
||||
projectVersionTagTable.setData(form.getVersions());
|
||||
versionTagService.updateTag(projectVersionTagTable);
|
||||
projectService.refreshHomeProjects();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
@ -1,5 +1,25 @@
|
||||
package io.papermc.hangar.service.internal.versions;
|
||||
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import io.papermc.hangar.HangarComponent;
|
||||
import io.papermc.hangar.db.dao.internal.table.PlatformVersionDAO;
|
||||
import io.papermc.hangar.db.dao.internal.table.versions.ProjectVersionsDAO;
|
||||
@ -28,7 +48,6 @@ import io.papermc.hangar.service.api.UsersApiService;
|
||||
import io.papermc.hangar.service.internal.JobService;
|
||||
import io.papermc.hangar.service.internal.PlatformService;
|
||||
import io.papermc.hangar.service.internal.projects.ChannelService;
|
||||
import io.papermc.hangar.service.internal.projects.HomeProjectService;
|
||||
import io.papermc.hangar.service.internal.projects.ProjectService;
|
||||
import io.papermc.hangar.service.internal.uploads.ProjectFiles;
|
||||
import io.papermc.hangar.service.internal.users.NotificationService;
|
||||
@ -37,25 +56,6 @@ import io.papermc.hangar.service.internal.versions.plugindata.PluginFileWithData
|
||||
import io.papermc.hangar.service.internal.visibility.ProjectVisibilityService;
|
||||
import io.papermc.hangar.util.CryptoUtils;
|
||||
import io.papermc.hangar.util.StringUtils;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
@Service
|
||||
public class VersionFactory extends HangarComponent {
|
||||
@ -77,10 +77,9 @@ public class VersionFactory extends HangarComponent {
|
||||
private final UsersApiService usersApiService;
|
||||
private final JobService jobService;
|
||||
private final ValidationService validationService;
|
||||
private final HomeProjectService homeProjectService;
|
||||
|
||||
@Autowired
|
||||
public VersionFactory(ProjectVersionPlatformDependenciesDAO projectVersionPlatformDependencyDAO, ProjectVersionDependenciesDAO projectVersionDependencyDAO, PlatformVersionDAO platformVersionDAO, ProjectVersionsDAO projectVersionDAO, VersionsApiDAO versionsApiDAO, ProjectFiles projectFiles, PluginDataService pluginDataService, ChannelService channelService, ProjectVisibilityService projectVisibilityService, RecommendedVersionService recommendedVersionService, ProjectService projectService, NotificationService notificationService, VersionTagService versionTagService, PlatformService platformService, UsersApiService usersApiService, JobService jobService, ValidationService validationService, HomeProjectService homeProjectService) {
|
||||
public VersionFactory(ProjectVersionPlatformDependenciesDAO projectVersionPlatformDependencyDAO, ProjectVersionDependenciesDAO projectVersionDependencyDAO, PlatformVersionDAO platformVersionDAO, ProjectVersionsDAO projectVersionDAO, VersionsApiDAO versionsApiDAO, ProjectFiles projectFiles, PluginDataService pluginDataService, ChannelService channelService, ProjectVisibilityService projectVisibilityService, RecommendedVersionService recommendedVersionService, ProjectService projectService, NotificationService notificationService, VersionTagService versionTagService, PlatformService platformService, UsersApiService usersApiService, JobService jobService, ValidationService validationService) {
|
||||
this.projectVersionPlatformDependenciesDAO = projectVersionPlatformDependencyDAO;
|
||||
this.projectVersionDependenciesDAO = projectVersionDependencyDAO;
|
||||
this.platformVersionDAO = platformVersionDAO;
|
||||
@ -98,7 +97,6 @@ public class VersionFactory extends HangarComponent {
|
||||
this.usersApiService = usersApiService;
|
||||
this.jobService = jobService;
|
||||
this.validationService = validationService;
|
||||
this.homeProjectService = homeProjectService;
|
||||
}
|
||||
|
||||
public PendingVersion createPendingVersion(long projectId, MultipartFile file) {
|
||||
@ -301,7 +299,7 @@ public class VersionFactory extends HangarComponent {
|
||||
jobService.save(new UpdateDiscourseVersionPostJob(projectVersionTable.getId()));
|
||||
}
|
||||
|
||||
homeProjectService.refreshHomeProjects();
|
||||
projectService.refreshHomeProjects();
|
||||
usersApiService.clearAuthorsCache();
|
||||
} catch (IOException e) {
|
||||
logger.error("Unable to create version {} for {}", pendingVersion.getVersionString(), getHangarPrincipal().getName(), e);
|
||||
|
@ -6,6 +6,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import io.papermc.hangar.db.dao.internal.projects.HangarProjectsDAO;
|
||||
import io.papermc.hangar.db.dao.internal.table.VisibilityDAO;
|
||||
import io.papermc.hangar.db.dao.internal.table.projects.ProjectsDAO;
|
||||
import io.papermc.hangar.model.db.projects.ProjectTable;
|
||||
@ -14,7 +15,6 @@ import io.papermc.hangar.model.internal.job.UpdateDiscourseProjectTopicJob;
|
||||
import io.papermc.hangar.model.internal.logs.LogAction;
|
||||
import io.papermc.hangar.model.internal.logs.contexts.ProjectContext;
|
||||
import io.papermc.hangar.service.internal.JobService;
|
||||
import io.papermc.hangar.service.internal.projects.HomeProjectService;
|
||||
|
||||
@Service
|
||||
public class ProjectVisibilityService extends VisibilityService<ProjectContext, ProjectTable, ProjectVisibilityChangeTable> {
|
||||
@ -22,15 +22,15 @@ public class ProjectVisibilityService extends VisibilityService<ProjectContext,
|
||||
private final ProjectsDAO projectsDAO;
|
||||
private final VisibilityDAO visibilityDAO;
|
||||
private final JobService jobService;
|
||||
private final HomeProjectService homeProjectService;
|
||||
private final HangarProjectsDAO hangarProjectsDAO;
|
||||
|
||||
@Autowired
|
||||
public ProjectVisibilityService(VisibilityDAO visibilityDAO, ProjectsDAO projectsDAO, JobService jobService, HomeProjectService homeProjectService) {
|
||||
public ProjectVisibilityService(VisibilityDAO visibilityDAO, ProjectsDAO projectsDAO, JobService jobService, HangarProjectsDAO hangarProjectsDAO) {
|
||||
super(ProjectVisibilityChangeTable::new, LogAction.PROJECT_VISIBILITY_CHANGED);
|
||||
this.projectsDAO = projectsDAO;
|
||||
this.visibilityDAO = visibilityDAO;
|
||||
this.jobService = jobService;
|
||||
this.homeProjectService = homeProjectService;
|
||||
this.hangarProjectsDAO = hangarProjectsDAO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,7 +58,7 @@ public class ProjectVisibilityService extends VisibilityService<ProjectContext,
|
||||
if (model != null) {
|
||||
jobService.save(new UpdateDiscourseProjectTopicJob(model.getId()));
|
||||
}
|
||||
homeProjectService.refreshHomeProjects();
|
||||
hangarProjectsDAO.refreshHomeProjects();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,27 +1,27 @@
|
||||
package io.papermc.hangar.tasks;
|
||||
|
||||
import io.papermc.hangar.service.internal.admin.StatService;
|
||||
import io.papermc.hangar.service.internal.projects.HomeProjectService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import io.papermc.hangar.service.internal.admin.StatService;
|
||||
import io.papermc.hangar.service.internal.projects.ProjectService;
|
||||
|
||||
@Component
|
||||
public class DbUpdateTask {
|
||||
|
||||
private final HomeProjectService homeProjectService;
|
||||
private final ProjectService projectService;
|
||||
private final StatService statService;
|
||||
|
||||
@Autowired
|
||||
public DbUpdateTask(HomeProjectService projectService, StatService statService) {
|
||||
this.homeProjectService = projectService;
|
||||
public DbUpdateTask(ProjectService projectService, StatService statService) {
|
||||
this.projectService = projectService;
|
||||
this.statService = statService;
|
||||
}
|
||||
|
||||
@Scheduled(fixedRateString = "#{@hangarConfig.homepage.updateInterval.toMillis()}")
|
||||
public void refreshHomePage() {
|
||||
homeProjectService.refreshHomeProjects();
|
||||
projectService.refreshHomeProjects();
|
||||
}
|
||||
|
||||
@Scheduled(fixedRateString = "#{@hangarConfig.homepage.updateInterval.toMillis()}", initialDelay = 1000)
|
||||
|
Loading…
Reference in New Issue
Block a user