refresh home view when a new project is created

This commit is contained in:
MiniDigger 2020-08-22 14:54:52 +02:00
parent 1538fd9738
commit b94d69a491
2 changed files with 18 additions and 1 deletions

View File

@ -0,0 +1,11 @@
package io.papermc.hangar.db.dao;
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
import org.springframework.stereotype.Repository;
@Repository
public interface GeneralDao {
@SqlUpdate("refresh materialized view home_projects;")
void refreshHomeProjects();
}

View File

@ -1,6 +1,7 @@
package io.papermc.hangar.service.project;
import io.papermc.hangar.config.hangar.HangarConfig;
import io.papermc.hangar.db.dao.GeneralDao;
import io.papermc.hangar.db.dao.HangarDao;
import io.papermc.hangar.db.dao.ProjectChannelDao;
import io.papermc.hangar.db.dao.ProjectDao;
@ -64,9 +65,10 @@ public class ProjectFactory {
private final NotificationService notificationService;
private final UserActionLogService userActionLogService;
private final ProjectFiles projectFiles;
private final HangarDao<GeneralDao> generalDao;
@Autowired
public ProjectFactory(HangarConfig hangarConfig, HangarDao<ProjectChannelDao> projectChannelDao, HangarDao<ProjectDao> projectDao, HangarDao<ProjectPageDao> projectPagesDao, HangarDao<ProjectVersionDao> projectVersionDao, RoleService roleService, UserService userService, ProjectService projectService, ChannelService channelService, VersionService versionService, NotificationService notificationService, UserActionLogService userActionLogService, ProjectFiles projectFiles) {
public ProjectFactory(HangarConfig hangarConfig, HangarDao<ProjectChannelDao> projectChannelDao, HangarDao<ProjectDao> projectDao, HangarDao<ProjectPageDao> projectPagesDao, HangarDao<ProjectVersionDao> projectVersionDao, RoleService roleService, UserService userService, ProjectService projectService, ChannelService channelService, VersionService versionService, NotificationService notificationService, UserActionLogService userActionLogService, ProjectFiles projectFiles, HangarDao<GeneralDao> generalDao) {
this.hangarConfig = hangarConfig;
this.projectChannelDao = projectChannelDao;
this.projectDao = projectDao;
@ -80,6 +82,7 @@ public class ProjectFactory {
this.notificationService = notificationService;
this.userActionLogService = userActionLogService;
this.projectFiles = projectFiles;
this.generalDao = generalDao;
}
public String getUploadError(UsersTable user) {
@ -111,6 +114,7 @@ public class ProjectFactory {
roleService.addRole(projectsTable, ownerUser.getId(), Role.PROJECT_OWNER, true);
userService.clearAuthorsCache();
generalDao.get().refreshHomeProjects();
return projectsTable;
}
@ -198,6 +202,8 @@ public class ProjectFactory {
}
generalDao.get().refreshHomeProjects();
userService.clearAuthorsCache();
return version;
}