module analytics;

public import analytics.balances;

import profile.data;
import profile.model;

/**
 * Helper function to run a function on each available user profile.
 * Params:
 *   fn = The function to run.
 */
void doForAllUserProfiles(
    void function(Profile, ProfileRepository) fn
) {
    import auth.data;
    import auth.data_impl_fs;
    import profile.data;
    import profile.data_impl_sqlite;

    UserRepository userRepo = new FileSystemUserRepository();
    foreach (user; userRepo.findAll()) {
        ProfileRepository profileRepo = new FileSystemProfileRepository(user.username);
        foreach (prof; profileRepo.findAll()) {
            fn(prof, profileRepo);
        }
    }
}