Skip to content

Commit

Permalink
Merge pull request #390 from COS301-SE-2023/bug-search-functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbasiltrickett authored Oct 26, 2023
2 parents 5f18fba + 09ca997 commit ecd751b
Show file tree
Hide file tree
Showing 160 changed files with 2,359 additions and 1,385 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import com.fridgetoplate.frontendmodels.MealPlanFrontendModel;
import com.fridgetoplate.model.Ingredient;
import com.fridgetoplate.model.MealPlanModel;
import com.fridgetoplate.service.MealPlanService;

@RestController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.messaging.simp.SimpMessagingTemplate;
@Controller
public class PushNotificationsController {
Expand All @@ -24,15 +22,15 @@ public class PushNotificationsController {
//Mapped as app/application
@MessageMapping("/application")
@SendTo("/all/messages")
public Message send(final Message message) throws Exception{
public Message<String> send(final Message<String> message) throws Exception{
System.out.println("Message: " + message);

return message;
}

// app/private
@MessageMapping("/private")
public void sendToSpecificUser(@Payload Message message){
public void sendToSpecificUser(@Payload Message<String> message){
simpMessagingTemplate.convertAndSendToUser("ToReplaceLater", "/specific", message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.fridgetoplate.model.Ingredient;
import com.fridgetoplate.model.RecipeModel;
import com.fridgetoplate.repository.RecipeRepository;
import com.fridgetoplate.service.RecipeService;
import com.fridgetoplate.frontendmodels.RecipeFrontendModel;

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

@GetMapping("/{id}")
public RecipeFrontendModel findById(@PathVariable(value = "id") String id){
return recipeService.findById(id);
public RecipeFrontendModel findFullRecipeById(@PathVariable(value = "id") String id){
return recipeService.findFullRecipeById(id);
}

@GetMapping("/name/{recipename}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.fridgetoplate.frontendmodels.RecipeFrontendModel;
import com.fridgetoplate.frontendmodels.RecommendFrontendModel;
import com.fridgetoplate.interfaces.RecipeDesc;
import com.fridgetoplate.service.RecommendService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGeneratedKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;

import lombok.Data;
import lombok.Setter;

@DynamoDBTable(tableName = "notifications")
@Data
@Setter
public class NotificationModel {

String notificationId;
Expand All @@ -19,12 +20,12 @@ public class NotificationModel {
String type;
String metadata;

@DynamoDBAttribute(attributeName = "userId")
@DynamoDBHashKey(attributeName = "userId")
public String getUserId(){
return userId;
}

@DynamoDBHashKey(attributeName = "notificationId")
@DynamoDBRangeKey(attributeName = "notificationId")
@DynamoDBAutoGeneratedKey
public String getNotificationId() {
return notificationId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.fridgetoplate.repository;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -11,9 +10,6 @@
import com.amazonaws.services.dynamodbv2.datamodeling.PaginatedScanList;
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
import com.amazonaws.services.dynamodbv2.model.ExpectedAttributeValue;
import com.fridgetoplate.frontendmodels.ProfileFrontendModel;
import com.fridgetoplate.interfaces.Profile;
import com.fridgetoplate.interfaces.RecipeDesc;
import com.fridgetoplate.model.ProfileModel;
import com.fridgetoplate.model.Review;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package com.fridgetoplate.repository;

import java.util.ArrayList;
import java.util.List;

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

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression;
import com.amazonaws.services.dynamodbv2.datamodeling.PaginatedScanList;
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
import com.fridgetoplate.model.Review;

Expand Down Expand Up @@ -40,7 +37,7 @@ public Review getReviewByReviewId(String recipeId, String reviewId) {
}

public String delete(String recipeId, String reviewId){
Review review = dynamoDBMapper.load(Review.class, recipeId, reviewId);
Review review = dynamoDBMapper.load(Review.class, recipeId, reviewId);
dynamoDBMapper.delete(review);
return "SUCCESSFULLY DELETED";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.fridgetoplate.frontendmodels.RecipePreferencesFrontendModel;
import com.fridgetoplate.interfaces.SpoonacularIngredientItem;
import com.fridgetoplate.interfaces.SpoonacularRecipe;
import com.fridgetoplate.interfaces.SpoonacularResponse;
import com.fridgetoplate.interfaces.YoutubeVideosResponse;
import com.fridgetoplate.model.Ingredient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

import com.fridgetoplate.frontendmodels.MealPlanFrontendModel;
import com.fridgetoplate.interfaces.RecipeDesc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
import nl.martijndwars.webpush.Subscription;
import org.springframework.beans.factory.annotation.Value;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.simp.SimpMessagingTemplate;

import org.apache.logging.log4j.message.Message;

public class MessageService {
@Value("${Vapid.VAPIDPublicKey}")
private String vapidPublicKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,24 @@ public String clearAllNotificationOfType(String userId, String type){

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

List<NotificationModel> deletableNotif = new ArrayList<>();
for (NotificationModel notificationModel : notifications) {
if (notificationModel.getType().equals(type)) {
System.out.println(notificationModel.toString());
notificationsRepository.delete(notificationModel);
deletableNotif.add(notificationModel);
}
}

notificationsRepository.deleteAll(deletableNotif);

return "Successfully cleared all " + type + " notifications";

}

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

List<ProfileModel> allUsers = profileService.findAllUsers();
List<ProfileModel> selectedUsers = new ArrayList();
List<ProfileModel> selectedUsers = new ArrayList<>();

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

List<ProfileModel> allUsers = profileService.findAllUsers();
List<ProfileModel> selectedUsers = new ArrayList();
List<ProfileModel> selectedUsers = new ArrayList<>();

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

List<ProfileModel> allUsers = profileService.findAllUsers();
List<ProfileModel> selectedUsers = new ArrayList();
List<ProfileModel> selectedUsers = new ArrayList<>();

//1. Get random users
for(; selectedUsers.size() < allUsers.size() * 0.6 ;){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.SecurityProperties.User;
import org.springframework.stereotype.Service;

import com.fridgetoplate.frontendmodels.ProfileFrontendModel;
Expand Down
Loading

0 comments on commit ecd751b

Please sign in to comment.