[][src]Function tweetr::ops::start_daemon::tweet_indices_to_post

pub fn tweet_indices_to_post(tweets: &Vec<QueuedTweet>) -> Vec<usize>

Get the indices of tweets to post now from the provided batch based on whether thy've been posted already and the current time.

All returned indices are guaranteed to be valid.

Examples

let now = Local::now();
let now = now.with_timezone(now.offset());

assert_eq!(start_daemon::tweet_indices_to_post(&vec![
    QueuedTweet {
        author: "nabijaczleweli".to_string(),
        time: now + Duration::hours(1),
        content: "This tweet is not going to be posted (it's too early)".to_string(),
        time_posted: None,
        id: None,
    },
    QueuedTweet {
        author: "nabijaczleweli".to_string(),
        time: now - Duration::hours(1),
        content: "This tweet is going to be posted".to_string(),
        time_posted: None,
        id: None,
    },
    QueuedTweet {
        author: "nabijaczleweli".to_string(),
        time: now - Duration::hours(1),
        content: "This tweet is not going to be posted (it already was)".to_string(),
        time_posted: Some(now - Duration::minutes(30)),
        id: Some(6908265),
    },
]), vec![1]);