Browse Source

Always a db query so licenses are in the right order

Douglas Thrift 6 years ago
parent
commit
216e395862
1 changed files with 9 additions and 6 deletions
  1. 9 6
      app.rb

+ 9 - 6
app.rb

@@ -234,13 +234,16 @@ end
 
 get '/' do
   @licenses = License.all
-  @licenses = flickr.photos.licenses.getInfo.map do |flickr_license|
-    License.create do |license|
-      license.id = flickr_license.id
-      license.name = flickr_license.name
-      license.url = flickr_license.url
+  if @licenses.count == 0
+    flickr.photos.licenses.getInfo.each do |flickr_license|
+      License.create do |license|
+        license.id = flickr_license.id
+        license.name = flickr_license.name
+        license.url = flickr_license.url
+      end
     end
-  end if @licenses.count == 0
+    @licenses = License.all
+  end
   @show_privacies = {
     all: 'show public and private photos',
     public: 'show only public photos',