Commit e3e2363f authored by Zac Wood's avatar Zac Wood

cron job in docker + version number

parent 2b2789af
Pipeline #5185 failed with stage
in 5 minutes and 46 seconds
......@@ -15,3 +15,7 @@ RUN rails assets:precompile
RUN rails db:migrate
RUN rails db:seed
RUN rails runner db/load_course_ratings.rb
RUN whenever --update-crontab
CMD [ "rails server" ]
......@@ -65,4 +65,6 @@ gem 'rack-cors', require: 'rack/cors'
gem "rubocop", "~> 0.58.2"
# super fast page loads
gem 'turbolinks'
\ No newline at end of file
gem 'turbolinks'
gem 'whenever'
\ No newline at end of file
......@@ -87,8 +87,6 @@ GEM
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
apipie-rails (0.5.16)
rails (>= 4.1)
ast (2.4.0)
backport (1.1.2)
bindex (0.8.1)
......@@ -102,6 +100,7 @@ GEM
rack-test (>= 0.5.4)
xpath (>= 2.0, < 4.0)
childprocess (3.0.0)
chronic (0.10.2)
coderay (1.1.2)
concurrent-ruby (1.1.5)
crass (1.0.5)
......@@ -133,7 +132,6 @@ GEM
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
maruku (0.7.3)
method_source (0.9.2)
mime-types (3.3)
mime-types-data (~> 3.2015)
......@@ -248,6 +246,8 @@ GEM
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
whenever (1.0.0)
chronic (>= 0.6.3)
xpath (3.2.0)
nokogiri (~> 1.8)
yard (0.9.20)
......@@ -257,14 +257,12 @@ PLATFORMS
ruby
DEPENDENCIES
apipie-rails
byebug
capybara (~> 2.13)
httparty
icalendar
jbuilder
listen (>= 3.0.5, < 3.2)
maruku
nokogiri
pry
pry-doc
......@@ -283,6 +281,7 @@ DEPENDENCIES
uglifier
web-console (>= 3.3.0)
webpacker
whenever
BUNDLED WITH
1.17.3
......@@ -253,6 +253,7 @@ a {
footer {
margin: 4em auto 1em;
text-align: center;
max-width: 75%;
}
#count {
......
......@@ -14,6 +14,7 @@ export default class extends Controller {
this.exportTarget.classList.remove('hidden')
this.loaderTarget.classList.remove('hidden')
this.scheduleTarget.innerHTML = ''
fetch(`/course_sections?crns=${getCart().join(',')}`)
.then(resp => resp.text())
.then(text => {
......
import { Controller } from 'stimulus'
import { version } from '../utils'
export default class extends Controller {
connect() {
const [tag, update] = version()
this.element.innerHTML = tag
update.then(tag => (this.element.innerHTML = tag))
}
}
......@@ -13,3 +13,17 @@ export function downloadIcal(url, filename) {
saveAs(blob, filename)
})
}
export function version() {
const cached = sessionStorage.getItem('version') || ''
const promise = fetch('https://git.gmu.edu/api/v4/projects/535/repository/tags')
.then(response => response.json())
.then(tags => {
const tag = tags[0].name
sessionStorage.setItem('version', tag)
return tag
})
.catch(e => e)
return [cached, promise]
}
......@@ -43,7 +43,7 @@
<h5 class="section-type-label"><%= type %></h5>
<% end %>
<ul class="section-list">
<%= render partial: 'shared/section', collection: sections %>
<%= render partial: 'shared/section', collection: sections, cached: true %>
</ul>
<% end %>
</div>
......
......@@ -9,7 +9,7 @@
</a>
<footer class="footer">
Schedules was built by <a href="https://srct.gmu.edu">Mason SRCT</a> and is completely open source. <br/>
Want to contribute? View the code on the <a href="https://git.gmu.edu/srct/schedules">SRCT GitLab</a>.<br/>
Schedules <span data-controller="version"> </span> is a <a href="https://rubyonrails.org">Rails</a> app built by <a href="https://srct.gmu.edu">Mason SRCT</a> and is completely open source. We hope you love it.
Questions? <a href="mailto:srct@gmu.edu">Email us.</a> Want to contribute? View the code on the <a href="https://git.gmu.edu/srct/schedules">SRCT GitLab</a>.<br/>
</footer>
</main>
\ No newline at end of file
Apipie.configure do |config|
config.app_name = "SRCT Schedules API"
config.api_base_url = "/api"
config.doc_base_url = "/api"
# where is your API defined?
config.api_controllers_matcher = "#{Rails.root}/app/controllers/**/*.rb"
config.api_routes = Rails.application.routes
# use Markdown for writing docs
config.markup = Apipie::Markup::Markdown.new
# Fixes annoying "can't find resource" bug, see https://github.com/Apipie/apipie-rails/issues/549
config.translate = false
config.default_locale = nil
config.app_info["1.0"] = "The SRCT Schedules API provides data about courses, sections, and professors offered at GMU."
end
class IntegerValidator < Apipie::Validator::BaseValidator
def initialize(param_description, argument)
super(param_description)
@type = argument
end
def validate(value)
return false if value.nil?
!!(value.to_s =~ /^[-+]?[0-9]+$/)
end
def self.build(param_description, argument, _options, _block)
new(param_description, argument) if argument == Integer
end
def description
"Must be #{@type}."
end
end
set :output, "cron_log.log"
every 1.day, at: '3:00 am' do
command 'rails runner db/seeds.rb update'
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment