FEATURE: Sort queries by last_run_at as default
This commit is contained in:
parent
feb8a1ce0f
commit
1b68847d21
|
@ -21,7 +21,7 @@ export default Ember.Controller.extend({
|
|||
editing: false,
|
||||
everEditing: false,
|
||||
showRecentQueries: true,
|
||||
sortBy: ['id:desc'],
|
||||
sortBy: ['last_run_at:desc'],
|
||||
sortedQueries: Em.computed.sort('model', 'sortBy'),
|
||||
|
||||
createDisabled: function() {
|
||||
|
|
|
@ -160,12 +160,12 @@
|
|||
<br>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<td class="query-created-by">
|
||||
<a href="/users/{{query.username}}/activity">
|
||||
<medium class="query-created-by">{{query.username}}</medium>
|
||||
<medium>{{query.username}}</medium>
|
||||
</a>
|
||||
</td>
|
||||
<td><medium class="query-created-at">{{query.created_at}}</medium></td>
|
||||
<td class="query-created-at"><medium>{{bound-date query.last_run_at}}</medium></td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
|
|
|
@ -226,19 +226,21 @@
|
|||
}
|
||||
.time {
|
||||
width: 15%;
|
||||
text-align: center;
|
||||
}
|
||||
.user {
|
||||
width: 20%;
|
||||
padding-left: 1em;
|
||||
}
|
||||
td{
|
||||
.query-created-at {
|
||||
font-weight: bold;
|
||||
color: $secondary-medium;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.query-created-by {
|
||||
color: $primary-high;
|
||||
}
|
||||
}
|
||||
tr {
|
||||
height: 2px;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ en:
|
|||
run_time: "Query completed in {{value}} ms."
|
||||
query_name: "Query"
|
||||
query_description: "Description"
|
||||
query_time: "Date created"
|
||||
query_time: "Last run"
|
||||
query_user: "Created by"
|
||||
column: "Column {{number}}"
|
||||
explain_label: "Include query plan?"
|
||||
|
|
15
plugin.rb
15
plugin.rb
|
@ -567,7 +567,7 @@ SQL
|
|||
|
||||
# Reimplement a couple ActiveRecord methods, but use PluginStore for storage instead
|
||||
class DataExplorer::Query
|
||||
attr_accessor :id, :name, :description, :sql, :created_by, :created_at
|
||||
attr_accessor :id, :name, :description, :sql, :created_by, :created_at, :last_run_at
|
||||
|
||||
def initialize
|
||||
@name = 'Unnamed Query'
|
||||
|
@ -609,7 +609,7 @@ SQL
|
|||
|
||||
def self.from_hash(h)
|
||||
query = DataExplorer::Query.new
|
||||
[:name, :description, :sql, :created_by, :created_at].each do |sym|
|
||||
[:name, :description, :sql, :created_by, :created_at, :last_run_at].each do |sym|
|
||||
query.send("#{sym}=", h[sym].strip) if h[sym]
|
||||
end
|
||||
query.id = h[:id].to_i if h[:id]
|
||||
|
@ -623,7 +623,8 @@ SQL
|
|||
description: @description,
|
||||
sql: @sql,
|
||||
created_by: @created_by,
|
||||
created_at: @created_at
|
||||
created_at: @created_at,
|
||||
last_run_at: @last_run_at
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -940,8 +941,9 @@ SQL
|
|||
# guardian.ensure_can_create_explorer_query!
|
||||
|
||||
query = DataExplorer::Query.from_hash params.require(:query)
|
||||
query.created_at = Time.now.strftime("%b %e, %Y")
|
||||
query.created_at = Time.now
|
||||
query.created_by = current_user.id.to_s
|
||||
query.last_run_at = Time.now
|
||||
query.id = nil # json import will assign an id, which is wrong
|
||||
query.save
|
||||
|
||||
|
@ -999,6 +1001,9 @@ SQL
|
|||
def run
|
||||
check_xhr unless params[:download]
|
||||
query = DataExplorer::Query.find(params[:id].to_i)
|
||||
query.last_run_at = Time.now
|
||||
query.save
|
||||
|
||||
if params[:download]
|
||||
response.sending_file = true
|
||||
end
|
||||
|
@ -1077,7 +1082,7 @@ SQL
|
|||
end
|
||||
|
||||
class DataExplorer::QuerySerializer < ActiveModel::Serializer
|
||||
attributes :id, :sql, :name, :description, :param_info, :created_by, :created_at, :username
|
||||
attributes :id, :sql, :name, :description, :param_info, :created_by, :created_at, :username, :last_run_at
|
||||
|
||||
def param_info
|
||||
object.params.map(&:to_hash) rescue nil
|
||||
|
|
Loading…
Reference in New Issue