Skip to content

Commit ecd751b

Browse files
Merge pull request #390 from COS301-SE-2023/bug-search-functionality
2 parents 5f18fba + 09ca997 commit ecd751b

File tree

160 files changed

+2359
-1385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+2359
-1385
lines changed

apps/api/src/main/java/com/fridgetoplate/controller/MealPlanController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import com.fridgetoplate.frontendmodels.MealPlanFrontendModel;
1616
import com.fridgetoplate.model.Ingredient;
17-
import com.fridgetoplate.model.MealPlanModel;
1817
import com.fridgetoplate.service.MealPlanService;
1918

2019
@RestController

apps/api/src/main/java/com/fridgetoplate/controller/PushNotificationsController.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import org.springframework.messaging.handler.annotation.SendTo;
88
import org.springframework.messaging.Message;
99
import org.springframework.stereotype.Controller;
10-
import org.springframework.web.bind.annotation.CrossOrigin;
11-
import org.springframework.web.bind.annotation.RequestMethod;
1210
import org.springframework.messaging.simp.SimpMessagingTemplate;
1311
@Controller
1412
public class PushNotificationsController {
@@ -24,15 +22,15 @@ public class PushNotificationsController {
2422
//Mapped as app/application
2523
@MessageMapping("/application")
2624
@SendTo("/all/messages")
27-
public Message send(final Message message) throws Exception{
25+
public Message<String> send(final Message<String> message) throws Exception{
2826
System.out.println("Message: " + message);
2927

3028
return message;
3129
}
3230

3331
// app/private
3432
@MessageMapping("/private")
35-
public void sendToSpecificUser(@Payload Message message){
33+
public void sendToSpecificUser(@Payload Message<String> message){
3634
simpMessagingTemplate.convertAndSendToUser("ToReplaceLater", "/specific", message);
3735
}
3836

apps/api/src/main/java/com/fridgetoplate/controller/RecipeController.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.web.bind.annotation.*;
88

9-
import com.fridgetoplate.model.Ingredient;
10-
import com.fridgetoplate.model.RecipeModel;
11-
import com.fridgetoplate.repository.RecipeRepository;
129
import com.fridgetoplate.service.RecipeService;
1310
import com.fridgetoplate.frontendmodels.RecipeFrontendModel;
1411

@@ -27,8 +24,8 @@ public RecipeFrontendModel save(@RequestBody RecipeFrontendModel recipe){
2724
}
2825

2926
@GetMapping("/{id}")
30-
public RecipeFrontendModel findById(@PathVariable(value = "id") String id){
31-
return recipeService.findById(id);
27+
public RecipeFrontendModel findFullRecipeById(@PathVariable(value = "id") String id){
28+
return recipeService.findFullRecipeById(id);
3229
}
3330

3431
@GetMapping("/name/{recipename}")

apps/api/src/main/java/com/fridgetoplate/controller/RecommendController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.web.bind.annotation.*;
77

8-
import com.fridgetoplate.frontendmodels.RecipeFrontendModel;
98
import com.fridgetoplate.frontendmodels.RecommendFrontendModel;
109
import com.fridgetoplate.interfaces.RecipeDesc;
1110
import com.fridgetoplate.service.RecommendService;

apps/api/src/main/java/com/fridgetoplate/model/NotificationModel.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
44
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGeneratedKey;
55
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
6+
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey;
67
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
78

8-
import lombok.Data;
9+
import lombok.Setter;
910

1011
@DynamoDBTable(tableName = "notifications")
11-
@Data
12+
@Setter
1213
public class NotificationModel {
1314

1415
String notificationId;
@@ -19,12 +20,12 @@ public class NotificationModel {
1920
String type;
2021
String metadata;
2122

22-
@DynamoDBAttribute(attributeName = "userId")
23+
@DynamoDBHashKey(attributeName = "userId")
2324
public String getUserId(){
2425
return userId;
2526
}
2627

27-
@DynamoDBHashKey(attributeName = "notificationId")
28+
@DynamoDBRangeKey(attributeName = "notificationId")
2829
@DynamoDBAutoGeneratedKey
2930
public String getNotificationId() {
3031
return notificationId;

apps/api/src/main/java/com/fridgetoplate/repository/ProfileRepository.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.fridgetoplate.repository;
22

3-
import java.time.LocalDate;
43
import java.util.ArrayList;
54
import java.util.List;
65
import org.springframework.beans.factory.annotation.Autowired;
@@ -11,9 +10,6 @@
1110
import com.amazonaws.services.dynamodbv2.datamodeling.PaginatedScanList;
1211
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
1312
import com.amazonaws.services.dynamodbv2.model.ExpectedAttributeValue;
14-
import com.fridgetoplate.frontendmodels.ProfileFrontendModel;
15-
import com.fridgetoplate.interfaces.Profile;
16-
import com.fridgetoplate.interfaces.RecipeDesc;
1713
import com.fridgetoplate.model.ProfileModel;
1814
import com.fridgetoplate.model.Review;
1915

apps/api/src/main/java/com/fridgetoplate/repository/ReviewRepository.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package com.fridgetoplate.repository;
22

3-
import java.util.ArrayList;
43
import java.util.List;
54

65
import org.springframework.beans.factory.annotation.Autowired;
76

87
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
98
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression;
10-
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression;
11-
import com.amazonaws.services.dynamodbv2.datamodeling.PaginatedScanList;
129
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
1310
import com.fridgetoplate.model.Review;
1411

@@ -40,7 +37,7 @@ public Review getReviewByReviewId(String recipeId, String reviewId) {
4037
}
4138

4239
public String delete(String recipeId, String reviewId){
43-
Review review = dynamoDBMapper.load(Review.class, recipeId, reviewId);
40+
Review review = dynamoDBMapper.load(Review.class, recipeId, reviewId);
4441
dynamoDBMapper.delete(review);
4542
return "SUCCESSFULLY DELETED";
4643
}

apps/api/src/main/java/com/fridgetoplate/service/ExternalApiService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.fridgetoplate.frontendmodels.RecipePreferencesFrontendModel;
1212
import com.fridgetoplate.interfaces.SpoonacularIngredientItem;
1313
import com.fridgetoplate.interfaces.SpoonacularRecipe;
14-
import com.fridgetoplate.interfaces.SpoonacularResponse;
1514
import com.fridgetoplate.interfaces.YoutubeVideosResponse;
1615
import com.fridgetoplate.model.Ingredient;
1716

apps/api/src/main/java/com/fridgetoplate/service/MealPlanService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.stereotype.Service;
8-
import org.springframework.web.bind.annotation.PathVariable;
98

109
import com.fridgetoplate.frontendmodels.MealPlanFrontendModel;
1110
import com.fridgetoplate.interfaces.RecipeDesc;

apps/api/src/main/java/com/fridgetoplate/service/MessageService.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
import nl.martijndwars.webpush.Subscription;
2020
import org.springframework.beans.factory.annotation.Value;
2121

22-
import org.springframework.messaging.handler.annotation.MessageMapping;
23-
import org.springframework.messaging.handler.annotation.SendTo;
24-
import org.springframework.messaging.simp.SimpMessagingTemplate;
25-
26-
import org.apache.logging.log4j.message.Message;
27-
2822
public class MessageService {
2923
@Value("${Vapid.VAPIDPublicKey}")
3024
private String vapidPublicKey;

apps/api/src/main/java/com/fridgetoplate/service/NotificationService.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,24 @@ public String clearAllNotificationOfType(String userId, String type){
6767

6868
List<NotificationModel> notifications = notificationsRepository.findAllByUser(userId);
6969

70+
List<NotificationModel> deletableNotif = new ArrayList<>();
7071
for (NotificationModel notificationModel : notifications) {
7172
if (notificationModel.getType().equals(type)) {
72-
System.out.println(notificationModel.toString());
73-
notificationsRepository.delete(notificationModel);
73+
deletableNotif.add(notificationModel);
7474
}
7575
}
7676

77+
notificationsRepository.deleteAll(deletableNotif);
78+
7779
return "Successfully cleared all " + type + " notifications";
78-
7980
}
8081

8182
@Scheduled(cron = "0 30 6 * * *")
8283
public void breakfastNotificationsPush(){
8384
random.setSeed(System.currentTimeMillis());
8485

8586
List<ProfileModel> allUsers = profileService.findAllUsers();
86-
List<ProfileModel> selectedUsers = new ArrayList();
87+
List<ProfileModel> selectedUsers = new ArrayList<>();
8788

8889
//1. Get random users
8990
for(; selectedUsers.size() < allUsers.size() * 0.6 ;){
@@ -128,7 +129,7 @@ public void lunchtimeNotificationsPush() {
128129
random.setSeed(System.currentTimeMillis());
129130

130131
List<ProfileModel> allUsers = profileService.findAllUsers();
131-
List<ProfileModel> selectedUsers = new ArrayList();
132+
List<ProfileModel> selectedUsers = new ArrayList<>();
132133

133134
//1. Get random users
134135
for(; selectedUsers.size() < allUsers.size() * 0.6 ;){
@@ -173,7 +174,7 @@ public void dinnertimeNotificationsPush() {
173174
random.setSeed(System.currentTimeMillis());
174175

175176
List<ProfileModel> allUsers = profileService.findAllUsers();
176-
List<ProfileModel> selectedUsers = new ArrayList();
177+
List<ProfileModel> selectedUsers = new ArrayList<>();
177178

178179
//1. Get random users
179180
for(; selectedUsers.size() < allUsers.size() * 0.6 ;){

apps/api/src/main/java/com/fridgetoplate/service/ProfileService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.List;
66

77
import org.springframework.beans.factory.annotation.Autowired;
8-
import org.springframework.boot.autoconfigure.security.SecurityProperties.User;
98
import org.springframework.stereotype.Service;
109

1110
import com.fridgetoplate.frontendmodels.ProfileFrontendModel;

0 commit comments

Comments
 (0)