Sha256: 6105f3bdd4cb33134cebfb423450d143b1d36e0a07b88302a76104d857b65bb8
Contents?: true
Size: 1.37 KB
Versions: 4
Compression:
Stored size: 1.37 KB
Contents
module Hubstats class Repo < ActiveRecord::Base scope :with_recent_activity, lambda {|time| where("updated_at > ?", time).order("updated_at DESC") } attr_accessible :id, :name, :full_name, :homepage, :language, :description, :default_branch, :url, :html_url, :clone_url, :git_url, :ssh_url, :svn_url, :mirror_url, :hooks_url, :issue_events_url, :events_url, :contributors_url, :git_commits_url, :issue_comment_url, :merges_url, :issues_url, :pulls_url, :labels_url, :forks_count, :stargazers_count, :watchers_count, :size, :open_issues_count, :has_issues, :has_wiki, :has_downloads,:fork, :private, :pushed_at, :created_at, :updated_at, :owner_id has_many :pull_requests has_many :deploys belongs_to :owner, :class_name => "User", :foreign_key => "id" def self.create_or_update(github_repo) github_repo = github_repo.to_h.with_indifferent_access if github_repo.respond_to? :to_h repo_data = github_repo.slice(*column_names.map(&:to_sym)) if github_repo[:owner] user = Hubstats::User.create_or_update(github_repo[:owner]) repo_data[:owner_id] = user[:id] end repo = where(:id => repo_data[:id]).first_or_create(repo_data) return repo if repo.update_attributes(repo_data) Rails.logger.warn repo.errors.inspect end def to_param self.name end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hubstats-0.3.8 | app/models/hubstats/repo.rb |
hubstats-0.3.7 | app/models/hubstats/repo.rb |
hubstats-0.3.6 | app/models/hubstats/repo.rb |
hubstats-0.3.5 | app/models/hubstats/repo.rb |