|
|
@@ -43,16 +43,16 @@ func (m *MonitorTestResultRepository) UpdateMonitorTestResult(monitor *models.Mo
|
|
|
return monitor, nil
|
|
|
}
|
|
|
|
|
|
-func (m *MonitorTestResultRepository) ArchiveMonitorTestResults(recommenderID string) error {
|
|
|
- query := m.db.Debug().Unscoped().Model(&models.MonitorTestResult{}).Where("last_recommender_run_id != ?", recommenderID)
|
|
|
+func (m *MonitorTestResultRepository) ArchiveMonitorTestResults(projectID, clusterID uint, recommenderID string) error {
|
|
|
+ query := m.db.Debug().Unscoped().Model(&models.MonitorTestResult{}).Where("project_id = ? AND cluster_id = ? AND last_recommender_run_id != ?", projectID, clusterID, recommenderID)
|
|
|
|
|
|
return query.Update("archived", true).Error
|
|
|
}
|
|
|
|
|
|
-func (m *MonitorTestResultRepository) DeleteOldMonitorTestResults(recommenderID string) error {
|
|
|
+func (m *MonitorTestResultRepository) DeleteOldMonitorTestResults(projectID, clusterID uint, recommenderID string) error {
|
|
|
monitors := make([]*models.MonitorTestResult, 0)
|
|
|
|
|
|
- query := m.db.Debug().Unscoped().Where("last_recommender_run_id != ?", recommenderID)
|
|
|
+ query := m.db.Debug().Unscoped().Where("project_id = ? AND cluster_id = ? AND last_recommender_run_id != ?", projectID, clusterID, recommenderID)
|
|
|
|
|
|
// we need to switch on the database type to delete records older than 24 hours
|
|
|
switch m.db.Dialector.Name() {
|