import java.io.IOException;

import models.Bundle;
import models.Query;
import models.Shapefile;
import models.User;
import controllers.Api;
import play.Application;
import play.GlobalSettings;
import play.api.mvc.EssentialFilter;
import utils.QueryResultStore;

public class Global extends GlobalSettings {
  
	@Override
	public void onStart(Application app) {
		Bundle.importBundlesAsNeeded();			
		
		// upload to S3
		try {
			Bundle.writeAllToClusterCache();
			Shapefile.writeAllToClusterCache();
		} catch (IOException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}

		for (Query q : Query.getAll()) {
			if (!q.completePoints.equals(q.totalPoints)) {
				QueryResultStore.accumulate(q);
			}
		}
	}
}

import models.Bundle;
import models.Query;
import models.Shapefile;
import play.Application;
import play.GlobalSettings;
import utils.QueryResultStore;

import java.io.IOException;

public class Global extends GlobalSettings {
  
	@Override
	public void onStart(Application app) {
		Bundle.importBundlesAsNeeded();			
		
		// upload to S3
		try {
			Bundle.writeAllToClusterCache();
			Shapefile.writeAllToClusterCache();
		} catch (IOException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}

		for (Query q : Query.getAll()) {
			if (q.completePoints == null || !q.completePoints.equals(q.totalPoints)) {
				QueryResultStore.accumulate(q);
			}
		}
	}
}

fix crash with scenarios that have not started.