Browse Source

added fullview command to output full branch history

master
apoc 2 weeks ago
parent
commit
2d1730f3b8
1 changed files with 12 additions and 4 deletions
  1. 12
    4
      server/main.rb

+ 12
- 4
server/main.rb View File

@@ -143,13 +143,14 @@ class Main
input = "%#{input.params}%"
plain_query = 'problem like ? or solution like ?'
full_text_search_query = 'to_tsvector(problem) @@ to_tsquery(?) or to_tsvector(solution) @@ to_tsquery(?)'
result = Problem.where( full_text_search_query, input, input )
selection = Problem.where( 'z != ?', current.z )
result = selection.where( full_text_search_query, input, input )
.order( created_at: 'desc' )
.first

if !result

result = Problem.where( plain_query, input, input )
result = selection.where( plain_query, input, input )
.order( created_at: 'desc' )
.first

@@ -167,7 +168,7 @@ class Main
end

# semver: 1.2.1?
def status( overview = false )
def status( overview = false, fullview = false )

if overview

@@ -189,7 +190,9 @@ class Main
end

@cache = false
return { problems: Problem.where( "z = ? and (x > ? - 5) and (x < ? + 2)", branch, current.x, current.x )
fullview = fullview ?
"" : "and (x > #{current.x - 5} and x < #{current.x + 2})"
return { problems: Problem.where( "z = ? #{fullview}", branch )
.map { |p| p = p.as_json }
.map { |p| p['current'] = true if p['id'] == current.id; p }
}.to_json
@@ -307,6 +310,11 @@ class Main

return status true

# todo: fix ugly code
when 'fullview'

return status false, true

when 'login'

return { token: login( input.params ) }.to_json

Loading…
Cancel
Save