Skip to content

Commit

Permalink
using archive in history
Browse files Browse the repository at this point in the history
  • Loading branch information
rajatshuvro committed Jun 19, 2022
1 parent ec291d8 commit d4a8e9c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/com/nola/databases/DbUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ public static TransactionDb LoadTransactionsDb(BookDb bookDb, UserDb userDb) {

return getTransactionDb(bookDb, userDb, inputStream);
}
public static TransactionDb LoadTransactionArchiveDb(BookDb bookDb, UserDb userDb) {
var filePath = DbCommons.getTransactionArchiveFilePath();
var inputStream = GetFileReadStream(filePath);

return getTransactionDb(bookDb, userDb, inputStream);
}

private static TransactionDb getTransactionDb(BookDb bookDb, UserDb userDb, InputStream inputStream) {
var transactions = ReadTransactions(inputStream);
Expand Down
8 changes: 6 additions & 2 deletions src/com/nola/subcommands/History.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,18 @@ public static void Run(String[] args) {
var bookDb = DbUtilities.LoadBookDb();
var userDb = DbUtilities.LoadUserDb();
var transactionDb = DbUtilities.LoadTransactionsDb(bookDb, userDb);
var archiveDb = DbUtilities.LoadTransactionArchiveDb(bookDb, userDb);

if (userId.equals("all")){
for (var user: userDb.GetAllUsers()) {
PrintUserHistory(user.Id, bookDb, archiveDb);
PrintUserHistory(user.Id, bookDb, transactionDb);
}
}
else PrintUserHistory(userId, bookDb, transactionDb);
else {
PrintUserHistory(userId, bookDb, archiveDb);
PrintUserHistory(userId, bookDb, transactionDb);
}
}

}
Expand All @@ -63,7 +68,6 @@ private static void PrintUserHistory(String userId, BookDb bookDb, TransactionDb
var transactions = transactionDb.GetUserActivity(userId);
if (transactions == null || transactions.size()==0){
return;
//PrintUtilities.PrintLine("No transactions found for user:" + userId);
}
else {
PrintUtilities.PrintLine("USER ID:"+ userId);
Expand Down
1 change: 0 additions & 1 deletion src/com/nola/subcommands/archive.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.nola.databases.AppendUtilities;
import com.nola.databases.DbCommons;
import com.nola.databases.DbUtilities;
import com.nola.databases.TransactionDb;
import com.nola.utilities.PrintUtilities;
import org.apache.commons.cli.*;

Expand Down

0 comments on commit d4a8e9c

Please sign in to comment.