|
|
|
|
@ -11,6 +11,7 @@ void startScheduledJobs() {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
JobScheduler jobScheduler = new TaskPoolScheduler();
|
|
|
|
|
|
|
|
|
|
jobScheduler.addJob(() {
|
|
|
|
|
// Clear old analytics data from profiles.
|
|
|
|
|
import profile.data;
|
|
|
|
|
@ -38,5 +39,32 @@ void startScheduledJobs() {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}, analyticsSchedule);
|
|
|
|
|
|
|
|
|
|
// Add a scheduled job to regularly check for and create recurring transaction drafts.
|
|
|
|
|
jobScheduler.addJob(() {
|
|
|
|
|
import profile.data;
|
|
|
|
|
import profile.data_impl_sqlite;
|
|
|
|
|
import profile.model;
|
|
|
|
|
import transaction.dto;
|
|
|
|
|
import transaction.data;
|
|
|
|
|
import util.pagination;
|
|
|
|
|
import std.stdio;
|
|
|
|
|
import std.datetime;
|
|
|
|
|
import cronexp;
|
|
|
|
|
FileSystemProfileRepository.doForAllUserProfiles((Profile profile, ProfileRepository profileRepo) {
|
|
|
|
|
writefln!"Recurring transaction check: %s / %s"(profile.username, profile.name);
|
|
|
|
|
ProfileDataSource ds = profileRepo.getDataSource(profile);
|
|
|
|
|
RecurringTransactionRepository rtRepo = ds.getRecurringTransactionRepository();
|
|
|
|
|
Page!(RecurringTransactionResponse) result = rtRepo.findAll(PageRequest.unpaged());
|
|
|
|
|
foreach (rt; result.items) {
|
|
|
|
|
writeln(rt.scheduleExpr);
|
|
|
|
|
DateTime now = cast(DateTime) Clock.currTime();
|
|
|
|
|
auto cron = CronExpr(rt.scheduleExpr);
|
|
|
|
|
writefln!"scheduleExpr = %s -> %s"(rt.scheduleExpr, cron.getNext(now));
|
|
|
|
|
// TODO: Figure out how to actually create the transactions!
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, new FixedIntervalSchedule(minutes(1), Clock.currTime(UTC())));
|
|
|
|
|
|
|
|
|
|
jobScheduler.start();
|
|
|
|
|
}
|