public static SqlTwitchFollower[] GetAllWithUsernames(SqlTwitchChannel channel) { try { List<object[]> results = _table.Select("join twitch_users on id=" + _table.tableName + ".UserId", _table.tableName + ".*, name", "ChannelUserId=?a", new object[] { channel.user.id }, null, 0); if(results != null) { SqlTwitchFollower[] followers = new SqlTwitchFollower[results.Count]; for(int i = 0; i < followers.Length; i++) { followers[i] = FromSql(channel, results[i]); } return followers; } else { return null; } } catch(Exception e) { Log.exception(e); return null; } }
public static SqlTwitchFollower[] GetNew(SqlTwitchAlert twitchAlerts) { try { DateTime latestCreatedAt = twitchAlerts.lastFollowerNotification; List<object[]> results = _table.Select(null, null, "ChannelUserId=?a AND CreatedAt>?b", new object[] { twitchAlerts.connection.channel.user.id, twitchAlerts.lastFollowerNotification }, null, 3); if(results != null && results.Count > 0) { SqlTwitchFollower[] followers = new SqlTwitchFollower[results.Count]; for(int i = 0; i < followers.Length; i++) { followers[i] = FromSql(twitchAlerts.connection.channel, results[i]); if(latestCreatedAt < followers[i].createdAt) { latestCreatedAt = followers[i].createdAt; } } twitchAlerts.lastFollowerNotification = latestCreatedAt; twitchAlerts.Save(false); return followers; } else { return null; } } catch(Exception e) { Log.exception(e); return null; } }