<commit_before>use time::Timespec;
use pg::PostgresRow;

use Model;
use db::Connection;
use util::CargoResult;

pub struct VersionDownload {
    pub id: i32,
    pub version_id: i32,
    pub downloads: i32,
    pub counted: i32,
    pub date: Timespec,
}

#[deriving(Encodable, Decodable)]
pub struct EncodableVersionDownload {
    pub id: i32,
    pub version_id: i32,
    pub downloads: i32,
    pub date: String,
}

impl VersionDownload {
    pub fn find(conn: &Connection, id: i32) -> CargoResult<VersionDownload> {
        Model::find(conn, id)
    }

    pub fn encodable(self) -> EncodableVersionDownload {
        let VersionDownload { id, version_id, downloads, counted: _,
                              date } = self;
        EncodableVersionDownload {
            id: id,
            version_id: version_id,
            downloads: downloads,
            date: ::encode_time(date),
        }
    }
}

impl Model for VersionDownload {
    fn from_row(row: &PostgresRow) -> VersionDownload {
        VersionDownload {
            id: row.get("id"),<commit_msg>Don't suffix with _id<commit_after>use time::Timespec;
use pg::PostgresRow;

use Model;
use db::Connection;
use util::CargoResult;

pub struct VersionDownload {
    pub id: i32,
    pub version_id: i32,
    pub downloads: i32,
    pub counted: i32,
    pub date: Timespec,
}

#[deriving(Encodable, Decodable)]
pub struct EncodableVersionDownload {
    pub id: i32,
    pub version: i32,
    pub downloads: i32,
    pub date: String,
}

impl VersionDownload {
    pub fn find(conn: &Connection, id: i32) -> CargoResult<VersionDownload> {
        Model::find(conn, id)
    }

    pub fn encodable(self) -> EncodableVersionDownload {
        let VersionDownload { id, version_id, downloads, counted: _,
                              date } = self;
        EncodableVersionDownload {
            id: id,
            version: version_id,
            downloads: downloads,
            date: ::encode_time(date),
        }
    }
}

impl Model for VersionDownload {
    fn from_row(row: &PostgresRow) -> VersionDownload {
        VersionDownload {
            id: row.get("id"),
{'fraction_non_alphanumeric': 0.10149672591206735, 'fraction_numerical': 0.014967259120673527, 'mean_word_length': 2.48371335504886, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5063101', 'n_tokens_mistral': 683, 'n_tokens_neox': 657, 'n_words': 178}