Skip to content

Commit

Permalink
fixing GitPod mysql db, and try opening rails console in a gitpod ter…
Browse files Browse the repository at this point in the history
…minal (publiclab#8152)

* try opening rails console in a gitpod terminal

* trying mysql -e "SET @@global.sql_mode=TRADITIONAL;"

* Tag.select('term_data.name, plots.term_data.count')

* 3 changes for "SELECT list is not in GROUP BY clause and contains nonaggregated column"

* Update .gitpod.yml

* Update node.rb

* add community_tags.date to group() in normal_tags()

* group by community_tags.created_at too

* added community_tags.updated_at and now it works!!!

* users controller group - node.nid, node_revisions.vid
  • Loading branch information
jywarren authored and alvesitalo committed Oct 14, 2020
1 parent 59e0ce6 commit d2668b7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ tasks:
- init: >
bundle install --without production &&
cp config/database.yml.gitpod config/database.yml &&
mysql -e "SET @@global.sql_mode=(SELECT REPLACE(@@global.sql_mode, 'ONLY_FULL_GROUP_BY', ''));" &&
mysql -e "CREATE DATABASE plots;" &&
cp db/schema.rb.example db/schema.rb &&
rake db:setup &&
Expand All @@ -16,6 +15,9 @@ tasks:
command: >
passenger start
- command: rails c


github:
prebuilds:
branches: true
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def list
User.select('*, rusers.status, MAX(node_revisions.timestamp) AS last_updated')
.joins(:revisions)
.where("node_revisions.status = 1")
.group('rusers.id')
.group('rusers.id, node.nid, node_revisions.vid')
.order(order_string)
.page(params[:page])
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/wiki_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def index

@wikis = Node.includes(:revision)
.references(:node_revisions)
.group('node_revisions.nid')
.group('node_revisions.nid, node_revisions.vid')
.order(order_string)
.where("node_revisions.status = 1 AND node.status = 1 AND (type = 'page' OR type = 'tool' OR type = 'place')")
.page(params[:page])
Expand All @@ -327,7 +327,7 @@ def stale

@wikis = Node.includes(:revision)
.references(:node_revisions)
.group('node_revisions.nid')
.group('node_revisions.nid, node_revisions.vid')
.order('node_revisions.timestamp ASC')
.where("node_revisions.status = 1 AND node.status = 1 AND (type = 'page' OR type = 'tool' OR type = 'place')")
.page(params[:page])
Expand All @@ -340,7 +340,7 @@ def popular
@title = I18n.t('wiki_controller.popular_wiki_pages')
@wikis = Node.limit(40)
.joins(:revision)
.group('node_revisions.nid')
.group('node_revisions.nid, node_revisions.vid')
.order('node_revisions.timestamp DESC')
.where("node.status = 1 AND node_revisions.status = 1 AND node.nid != 259 AND (type = 'page' OR type = 'tool' OR type = 'place')")
.sort_by(&:views).reverse
Expand Down
2 changes: 1 addition & 1 deletion app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def normal_tags(order = :none)
tags = NodeTag.where('nid = ? AND community_tags.tid IN (?)', id, tids)
.left_outer_joins(:tag, :tag_selections)
.order(Arel.sql('count(tag_selections.user_id) DESC'))
.group(:tid)
.group('community_tags.tid, community_tags.uid, community_tags.date, community_tags.created_at, community_tags.updated_at')
else
tags = NodeTag.where('nid = ? AND tid IN (?)', id, tids)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def followers_who_dont_follow_tags(tags)

# https://github.com/publiclab/plots2/pull/4266
def self.trending(limit = 5, start_date = DateTime.now - 1.month, end_date = DateTime.now)
Tag.select([:name])
Tag.select('term_data.name, plots.term_data.count') # ONLY_FULL_GROUP_BY, issue #8152 & #3120
.joins(:node_tag, :node)
.where('node.status = ?', 1)
.where('node.created > ?', start_date.to_i)
Expand Down

0 comments on commit d2668b7

Please sign in to comment.