Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Archive archive;
- {
- string fileText = File.ReadAllText("getAllArchivedHistory.json");
- archive = JsonSerializer.Deserialize<Archive>(fileText);
- }
- JSONGetLeaderboard leaderboards;
- {
- string fileText = File.ReadAllText("getLeaderboard.json");
- leaderboards = JsonSerializer.Deserialize<JSONGetLeaderboard>(fileText);
- }
- Dictionary<string, User> users = new Dictionary<string, User>();
- int userIndex = 0;
- foreach(LeaderboardUser leaderboardUser in leaderboards.leaderboard.leaderboard)
- {
- if(!users.ContainsKey(leaderboardUser.userid))
- {
- users.Add(leaderboardUser.userid, new User()
- {
- userid = leaderboardUser.userid,
- username = leaderboardUser.username,
- userIndex = userIndex++
- });
- }
- }
- int deletedUserCount = 0;
- int negs = 0;
- foreach(History history in archive.archive)
- {
- foreach(Transaction transaction in history.transactions)
- {
- if(!users.TryGetValue(transaction.userid, out User user))
- {
- deletedUserCount++;
- string username = $"[deleted user {deletedUserCount}]";
- if(transaction.userid == "1c407698-d26f-4c10-bfcc-1e88db41d8bb")
- {
- username = "FinanCivial Management Co.";
- }
- user = new User()
- {
- userid = transaction.userid,
- username = username,
- userIndex = userIndex + deletedUserCount
- };
- users.Add(transaction.userid, user);
- }
- user.transactions.Add(transaction);
- int diff = transaction.type == 0 ? 1 : -1;
- if(user.coins.TryGetValue(transaction.coin, out int coinValue))
- {
- int newVal = coinValue + diff;
- if(newVal < 0)
- {
- newVal = 0;
- }
- user.coins[transaction.coin] = newVal;
- }
- else
- {
- if(diff == -1)
- negs++;
- user.coins.Add(transaction.coin, (diff == -1 ? 0 : diff));
- }
- }
- }
- User user = users["10dcbbd5-f761-44f3-92ce-ea5b01f1d747"];
- Dictionary<string, List<Transaction>> coinTransactions = new Dictionary<string, List<Transaction>>();
- foreach(Transaction trans in user.transactions)
- {
- if(trans.timestamp > 1624161600000L)
- {
- List<Transaction> transactions = null;
- if(!coinTransactions.TryGetValue(trans.coin, out transactions))
- {
- transactions = new List<Transaction>();
- coinTransactions.Add(trans.coin, transactions);
- }
- transactions.Add(trans);
- }
- }
- Dictionary<string, List<(long, long)>> timestampPairs = new Dictionary<string, List<(long, long)>>();
- Transaction prev = default;
- Transaction current = default;
- int count10 = 0;
- int countMoreTen = 0;
- foreach(var kvp in coinTransactions)
- {
- List<(long, long)> pairs = null;
- if(!timestampPairs.TryGetValue(kvp.Key, out pairs))
- {
- pairs = new List<(long, long)>();
- timestampPairs.Add(kvp.Key, pairs);
- }
- for(int i = 0; i < kvp.Value.Count; i++)
- {
- if(i - 1 >= 0)
- {
- prev = kvp.Value[i-1];
- }
- current = kvp.Value[i];
- long diff = current.timestamp - (prev == null ? 0 : prev.timestamp);
- if(diff >= 540000 && diff <= 780000)
- {
- pairs.Add((prev.timestamp, current.timestamp));
- if(diff <= 630000)
- {
- count10++;
- }
- else
- {
- countMoreTen++;
- }
- }
- }
- }
- StreamWriter ws = new StreamWriter("diffTimestamps");
- ws.WriteLine($"Less than 10:30 count: {count10}, more: {countMoreTen}, good times {((((float)count10) * 100.0f) / (count10 + countMoreTen))}");
- foreach(var kvp in timestampPairs)
- {
- for(int i = 0; i < kvp.Value.Count; i++)
- {
- DateTimeOffset prevDate = DateTimeOffset.FromUnixTimeSeconds(kvp.Value[i].Item1 / 1000);
- DateTimeOffset currentDate = DateTimeOffset.FromUnixTimeSeconds(kvp.Value[i].Item2 / 1000);
- TimeSpan diff = currentDate - prevDate;
- ws.WriteLine($"{diff.Minutes.ToString("00")}:{diff.Seconds.ToString("00")} - {kvp.Key} - {prevDate} -> {currentDate}");
- }
- }
- ws.Close();
- public class User
- {
- public string username;
- public string userid;
- public int userIndex;
- public List<Transaction> transactions = new List<Transaction>();
- public Dictionary<string, int> coins = new Dictionary<string, int>();
- }
- public class JSONGetLeaderboard
- {
- public Leaderboard leaderboard {get; set;}
- public Oshiboard oshiboard {get; set;}
- public GachaboardPlayer[] gachaboard { get; set; }
- }
- public class Leaderboard
- {
- public long timestamp {get; set;}
- public LeaderboardUser[] leaderboard { get; set; }
- }
- public class LeaderboardUser
- {
- public string userid { get; set; }
- public string username { get; set; }
- public string icon { get; set; }
- public double networth { get; set; }
- public bool walletIsPublic { get; set; }
- public bool hasItems { get; set; }
- }
- public class Oshiboard
- {
- public long timestamp { get; set; }
- public Dictionary<string, Board> coins { get; set; }
- }
- public class Board
- {
- public int totalOwned { get; set; }
- public Director[] directors { get; set; }
- }
- public class Director
- {
- public string username { get; set; }
- public string icon { get; set; }
- public int amtOwned { get; set; }
- }
- public class GachaboardPlayer
- {
- public string username { get; set; }
- public double spentAmt { get; set; }
- }
- public class Archive
- {
- public History[] archive { get; set; }
- }
- public class History
- {
- public long timestamp { get; set; }
- public Transaction[] transactions { get; set; }
- }
- public class Transaction
- {
- public string coin { get; set; }
- public int type { get; set; }
- public string userid { get; set; }
- public long timestamp { get; set; }
- public bool completed { get; set; }
- public float price { get; set; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement