Skip to content

Commit

Permalink
all user history
Browse files Browse the repository at this point in the history
  • Loading branch information
rajatshuvro committed Dec 18, 2021
1 parent e4bf652 commit 345493f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/com/nola/subcommands/History.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public static void Run(String[] args) {
var userDb = DbUtilities.LoadUserDb();
var transactionDb = DbUtilities.LoadTransactionsDb(bookDb, userDb);

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

}
Expand All @@ -56,12 +61,13 @@ public static void Run(String[] args) {

private static void PrintUserHistory(String userId, BookDb bookDb, TransactionDb transactionDb) {
var transactions = transactionDb.GetUserActivity(userId);
if (transactions == null){
PrintUtilities.PrintInfoLine("No transactions found for user:" + userId);
if (transactions == null || transactions.size()==0){
return;
//PrintUtilities.PrintLine("No transactions found for user:" + userId);
}
else {
PrintUtilities.PrintInfoLine("USER ID:"+ userId);
PrintUtilities.PrintDelimiterLine(FlatObjectParser.RecordSeparator);
PrintUtilities.PrintLine("USER ID:"+ userId);
PrintUtilities.PrintLine(FlatObjectParser.RecordSeparator);
for (var transaction: transactions) {

if(! transaction.Type.equals(Transaction.CheckoutTag)) continue;
Expand All @@ -70,7 +76,7 @@ private static void PrintUserHistory(String userId, BookDb bookDb, TransactionDb
var book = bookDb.GetBook(bookId);
PrintUtilities.PrintLine(book.Title);
}
PrintUtilities.PrintDelimiterLine(FlatObjectParser.RecordSeparator);
PrintUtilities.PrintLine(FlatObjectParser.RecordSeparator);
}
}
}

0 comments on commit 345493f

Please sign in to comment.