chore: disable dummy event seeding in DataSeeder

This commit is contained in:
2026-06-19 10:48:05 +05:30
parent 785fe05902
commit 7fb507c47e

View File

@@ -19,70 +19,7 @@ public class DataSeeder {
@Bean @Bean
CommandLineRunner initDatabase(EventRepository eventRepository, UserRepository userRepository) { CommandLineRunner initDatabase(EventRepository eventRepository, UserRepository userRepository) {
return args -> { return args -> {
// Check if we already have events to avoid duplicate seeding on every restart System.out.println("DataSeeder: Dummy events seeding disabled.");
// unless the user specifically wants to clear them.
// For this task, we will add them if they don't exist for these depts in this range.
User proposer = userRepository.findByEmail("faculty@rit.edu").orElse(null);
if (proposer == null) {
System.out.println("No faculty user found to seed events. Please run DataInitializer first.");
return;
}
String[] depts = {"CSE", "AI&ML", "ECE"};
String[] statuses = {"REQUESTED", "APPROVED", "COMPLETED", "CANCELLED", "PENDING_PR"};
String[] categories = {"ACADEMIC", "CLUB", "PLACEMENT", "SPORTS"};
String[] types = {"Workshop", "Seminar", "Guest Lecture", "Competition"};
String[] years = {"1st Year", "2nd Year", "3rd Year", "4th Year"};
Random random = new Random();
for (String dept : depts) {
for (int month = 1; month <= 6; month++) {
// Create 2 events per department per month
for (int i = 0; i < 2; i++) {
int day = random.nextInt(25) + 1;
int hour = 9 + random.nextInt(8);
LocalDateTime start = LocalDateTime.of(2026, month, day, hour, 0);
LocalDateTime end = start.plusHours(2 + random.nextInt(3));
String status = statuses[random.nextInt(statuses.length)];
// Logic: Past events are more likely to be COMPLETED or APPROVED
if (start.isBefore(LocalDateTime.now())) {
if (random.nextBoolean()) status = "COMPLETED";
}
String[] venues = {
"GB 4th floor auditorium",
"Wozniak Auditorium",
"C6-02 Indoor Theatre",
"H Block Guest Lecture Theatre",
"Steve Jobs Computer Centre 1",
"Steve Jobs Computer Centre 2"
};
String venue = venues[random.nextInt(venues.length)];
eventRepository.save(Event.builder()
.title(dept + " " + types[random.nextInt(types.length)] + " - " + month + "/" + day)
.description("Sample event for " + dept + " department.")
.startDate(start)
.endDate(end)
.location(venue)
.category(categories[random.nextInt(categories.length)])
.type(types[random.nextInt(types.length)])
.institution("RIT")
.department(dept)
.academicYears(Arrays.asList(years[random.nextInt(years.length)]))
.status(status)
.proposer(proposer)
.budget(1000.0 * (random.nextInt(20) + 5))
.build());
}
}
}
System.out.println("Seeded events for CSE, AI&ML, ECE for Jan-June semester.");
}; };
} }
} }