pub fn history(conn: &r2d2::PooledConnection<r2d2_postgres::PostgresConnectionManager>, feat_id: &i64) -> Result<serde_json::Value, DeltaError> {
    match conn.query("
        SELECT json_agg(row_to_json(t))
        FROM (
            SELECT
                deltas.id,
                deltas.uid,
                JSON_Array_Elements((deltas.features -> 'features')::JSON) AS feat,
                users.username
            FROM
                deltas,
                users
            WHERE
                affected @> ARRAY[$1]::BIGINT[]
                AND users.id = deltas.uid
            ORDER BY id DESC
        ) t
        WHERE
            (feat->>'id')::BIGINT = $1;
    ", &[&feat_id]) {
        Ok(res) => {
            if res.len() == 0 { return Err(DeltaError::GetFail) }

            let history: serde_json::Value = res.get(0).get(0);
            Ok(history)
        },
        Err(err) => {
            match err.as_db() {
                Some(_e) => { Err(DeltaError::GetFail) },
                _ => Err(DeltaError::GetFail)
            }
        }
    }
}
///Get the history of a particular feature
Get the history of a particular feature
Get the history of a particular feature
pub fn history(conn: &r2d2::PooledConnection<r2d2_postgres::PostgresConnectionManager>, feat_id: &i64) -> Result<serde_json::Value, DeltaError> {
    match conn.query("
        SELECT json_agg(row_to_json(t))
        FROM (
            SELECT
                deltas.id,
                deltas.uid,
                JSON_Array_Elements((deltas.features -> 'features')::JSON) AS feat,
                users.username
            FROM
                deltas,
                users
            WHERE
                affected @> ARRAY[$1]::BIGINT[]
                AND users.id = deltas.uid
            ORDER BY id DESC
        ) t
        WHERE
            (feat->>'id')::BIGINT = $1;
    ", &[&feat_id]) {
        Ok(res) => {
            if res.len() == 0 { return Err(DeltaError::GetFail) }
            let history: serde_json::Value = res.get(0).get(0);
            Ok(history)
        },
        Err(err) => {
            match err.as_db() {
                Some(_e) => { Err(DeltaError::GetFail) },
                _ => Err(DeltaError::GetFail)
            }
        }
    }
}
pub fn history ( conn : & r2d2 :: PooledConnection < r2d2_postgres :: PostgresConnectionManager > , feat_id : & i64 ) -> Result < serde_json :: Value , DeltaError > { match conn . query ( " " , & [ & feat_id ] ) { Ok ( res ) => { if res . len ( ) == 0 { return Err ( DeltaError :: GetFail ) } let history : serde_json :: Value = res . get ( 0 ) . get ( 0 ) ; Ok ( history ) } , Err ( err ) => { match err . as_db ( ) { Some ( _e ) => { Err ( DeltaError :: GetFail ) } , _ => Err ( DeltaError :: GetFail ) } } } }
Get the history of a particular feature
Get the history of a particular feature
conn
&r2d2::PooledConnection<r2d2_postgres::PostgresConnectionManager>
feat_id
&i64
conn
&r2d2::PooledConnection<r2d2_postgres::PostgresConnectionManager>
feat_id
&i64