Class: ScribeDb::Model::Scribe
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ScribeDb::Model::Scribe
- Defined in:
- lib/scribelite/models/scribe.rb,
lib/scribelite/models/forward.rb
Class Method Summary collapse
- .avif ⇒ Object
- .block_counts ⇒ Object (also: counts_by_block)
- .block_with_timestamp_counts ⇒ Object (also: counts_by_block_with_timestamp)
- .content_type_counts ⇒ Object (also: counts_by_content_type)
- .date_counts ⇒ Object (also: counts_by_date, counts_by_day)
- .facet ⇒ Object
- .from_counts ⇒ Object (also: counts_by_address)
- .gif ⇒ Object
- .hour_counts ⇒ Object (also: counts_by_hour)
- .html ⇒ Object
- .image ⇒ Object
- .jpg ⇒ Object (also: jpeg)
- .js ⇒ Object (also: javascript)
- .largest ⇒ Object (also: biggest)
- .month_counts ⇒ Object (also: counts_by_month)
- .pdf ⇒ Object
-
.png ⇒ Object
scope like helpers.
- .sub100k ⇒ Object
- .sub10k ⇒ Object
- .sub10m ⇒ Object
-
.sub1k ⇒ Object
def self.search( q ) ## “full-text” search helper ## rename to text_search - why? why not? ## auto-sort by num - why? why not? joins(:blob).text.where( “content LIKE ‘%#q%’” ).order(‘num’) end.
- .sub1m ⇒ Object
- .sub20k ⇒ Object
- .sub20m ⇒ Object
- .sub21m ⇒ Object
- .sub2k ⇒ Object
- .sub2m ⇒ Object
- .svg ⇒ Object
- .text ⇒ Object
- .webp ⇒ Object
- .year_counts ⇒ Object (also: counts_by_year)
Class Method Details
.avif ⇒ Object
24 |
# File 'lib/scribelite/models/scribe.rb', line 24 def self.avif() where( content_type: 'image/avif' ); end |
.block_counts ⇒ Object Also known as: counts_by_block
110 111 112 113 |
# File 'lib/scribelite/models/scribe.rb', line 110 def self.block_counts joins(:tx).group( 'block' ) .order( 'block').count end |
.block_with_timestamp_counts ⇒ Object Also known as: counts_by_block_with_timestamp
115 116 117 118 |
# File 'lib/scribelite/models/scribe.rb', line 115 def self. joins(:tx).group( Arel.sql( "block || ' @ ' || date" )) .order( 'block' ).count end |
.content_type_counts ⇒ Object Also known as: counts_by_content_type
104 105 106 107 |
# File 'lib/scribelite/models/scribe.rb', line 104 def self.content_type_counts group( 'content_type' ) .order( Arel.sql( 'COUNT(*) DESC, content_type')).count end |
.date_counts ⇒ Object Also known as: counts_by_date, counts_by_day
121 122 123 124 125 |
# File 'lib/scribelite/models/scribe.rb', line 121 def self.date_counts ## note: strftime is SQLite specific/only!!! joins(:tx).group( Arel.sql("strftime('%Y-%m-%d', date)")) .order( Arel.sql("strftime('%Y-%m-%d', date)")).count end |
.facet ⇒ Object
28 |
# File 'lib/scribelite/models/scribe.rb', line 28 def self.facet() where( content_type: 'application/vnd.facet.tx+json' ); end |
.from_counts ⇒ Object Also known as: counts_by_address
146 147 148 149 150 151 |
# File 'lib/scribelite/models/scribe.rb', line 146 def self.from_counts ## note: from is sql keyword!!! ## wrap in [] for sqlite - check if works for others!!! joins(:tx).group( '[from]' ) .order( Arel.sql( 'COUNT(*) DESC')).count end |
.gif ⇒ Object
19 |
# File 'lib/scribelite/models/scribe.rb', line 19 def self.gif() where( content_type: 'image/gif' ); end |
.hour_counts ⇒ Object Also known as: counts_by_hour
139 140 141 142 143 |
# File 'lib/scribelite/models/scribe.rb', line 139 def self.hour_counts ## note: strftime is SQLite specific/only!!! joins(:tx).group( Arel.sql("strftime('%Y-%m-%d %Hh', date)")) .order( Arel.sql("strftime('%Y-%m-%d %Hh', date)")).count end |
.html ⇒ Object
49 50 51 52 53 54 |
# File 'lib/scribelite/models/scribe.rb', line 49 def self.html where( content_type: [ 'text/html;charset=utf-8', 'text/html', ]) end |
.image ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/scribelite/models/scribe.rb', line 36 def self.image ## change to/or add alias e.g. image/images - why? why not where( content_type: [ 'image/png', 'image/jpeg', 'image/jpg', 'image/gif', 'image/webp', 'image/svg+xml', 'image/avif', ]) end |
.jpg ⇒ Object Also known as: jpeg
20 21 |
# File 'lib/scribelite/models/scribe.rb', line 20 def self.jpg() where( content_type: ['image/jpeg', 'image/jpg'] ); end |
.js ⇒ Object Also known as: javascript
56 57 58 59 60 61 |
# File 'lib/scribelite/models/scribe.rb', line 56 def self.js where( content_type: [ 'text/javascript', 'application/javascript', ]) end |
.largest ⇒ Object Also known as: biggest
100 101 102 |
# File 'lib/scribelite/models/scribe.rb', line 100 def self.largest order( 'bytes DESC' ) end |
.month_counts ⇒ Object Also known as: counts_by_month
127 128 129 130 131 |
# File 'lib/scribelite/models/scribe.rb', line 127 def self.month_counts ## note: strftime is SQLite specific/only!!! joins(:tx).group( Arel.sql("strftime('%Y-%m', date)")) .order( Arel.sql("strftime('%Y-%m', date)")).count end |
.pdf ⇒ Object
26 |
# File 'lib/scribelite/models/scribe.rb', line 26 def self.pdf() where( content_type: 'application/pdf' ); end |
.png ⇒ Object
scope like helpers
18 |
# File 'lib/scribelite/models/scribe.rb', line 18 def self.png() where( content_type: 'image/png' ); end |
.sub100k ⇒ Object
92 |
# File 'lib/scribelite/models/scribe.rb', line 92 def self.sub100k() where( 'num < 100000' ); end |
.sub10k ⇒ Object
90 |
# File 'lib/scribelite/models/scribe.rb', line 90 def self.sub10k() where( 'num < 10000' ); end |
.sub10m ⇒ Object
95 |
# File 'lib/scribelite/models/scribe.rb', line 95 def self.sub10m() where( 'num < 10000000' ); end |
.sub1k ⇒ Object
def self.search( q ) ## “full-text” search helper
## rename to text_search - why? why not?
## auto-sort by num - why? why not?
joins(:blob).text.where( "content LIKE '%#{q}%'" ).order('num')
end
88 |
# File 'lib/scribelite/models/scribe.rb', line 88 def self.sub1k() where( 'num < 1000' ); end |
.sub1m ⇒ Object
93 |
# File 'lib/scribelite/models/scribe.rb', line 93 def self.sub1m() where( 'num < 1000000' ); end |
.sub20k ⇒ Object
91 |
# File 'lib/scribelite/models/scribe.rb', line 91 def self.sub20k() where( 'num < 20000' ); end |
.sub20m ⇒ Object
96 |
# File 'lib/scribelite/models/scribe.rb', line 96 def self.sub20m() where( 'num < 20000000' ); end |
.sub21m ⇒ Object
97 |
# File 'lib/scribelite/models/scribe.rb', line 97 def self.sub21m() where( 'num < 21000000' ); end |
.sub2k ⇒ Object
89 |
# File 'lib/scribelite/models/scribe.rb', line 89 def self.sub2k() where( 'num < 2000' ); end |
.sub2m ⇒ Object
94 |
# File 'lib/scribelite/models/scribe.rb', line 94 def self.sub2m() where( 'num < 2000000' ); end |
.svg ⇒ Object
23 |
# File 'lib/scribelite/models/scribe.rb', line 23 def self.svg() where( content_type: 'image/svg+xml' ); end |
.text ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/scribelite/models/scribe.rb', line 67 def self.text ## change to/or add alias e.g. text/texts - why? why not ## include html or svg in text-only inscription - why? why not? ## include markdown in text-only inscription - why? why not? ## make content_type lower case with lower() - why? why not? where( content_type: [ 'text/plain', 'text/plain;charset=utf-8', 'text/plain;charset=us-ascii', 'application/json', ]) end |
.webp ⇒ Object
22 |
# File 'lib/scribelite/models/scribe.rb', line 22 def self.webp() where( content_type: 'image/webp' ); end |
.year_counts ⇒ Object Also known as: counts_by_year
133 134 135 136 137 |
# File 'lib/scribelite/models/scribe.rb', line 133 def self.year_counts ## note: strftime is SQLite specific/only!!! joins(:tx).group( Arel.sql("strftime('%Y', date)")) .order( Arel.sql("strftime('%Y', date)")).count end |