Ignore:
Timestamp:
01/10/25 00:33:50 (3 weeks ago)
Author:
Kristijan <kristijanzafirovski26@…>
Branches:
master
Children:
1c51912
Parents:
c164f8f
Message:

dodadeno informacii za broj na lugje

File:
1 edited

Legend:

Unmodified
Added
Removed
  • backend/GlobeGuru-backend/src/main/java/Server.java

    rc164f8f r53bad7e  
    2828import java.time.LocalDateTime;
    2929import java.time.format.DateTimeFormatter;
     30import java.time.temporal.ChronoUnit;
    3031import java.util.*;
    3132import java.util.concurrent.ExecutorService;
     
    3435
    3536public class Server {
    36 
     37    private static final ExecutorService executorService = Executors.newFixedThreadPool(1);
    3738    public static void main(String[] args) throws IOException, SQLException {
    3839        // Start HTTP server
     
    5758
    5859        server.start();
    59 
    6060        System.out.println("Server started on port 8000");
     61
     62        LocalDateTime lastUpdateTime = getLastUpdateTime();
     63        LocalDateTime now = LocalDateTime.now();
     64        if (ChronoUnit.MONTHS.between(lastUpdateTime, now) >= 3) {
     65            System.out.println("Automatic Update");
     66            Future<Void> future = executorService.submit(new Scraper());
     67            Server.updateLastUpdateTime();
     68            executorService.submit(() -> {
     69                try {
     70                    future.get();
     71                } catch (Exception e) {
     72                    e.printStackTrace();
     73                }
     74            });
     75
     76        }
     77
    6178    }
    6279    static class RemoveFromSavedTripsHandler implements HttpHandler {
Note: See TracChangeset for help on using the changeset viewer.