feat: update art listings in home controller

- Modify the popular arts query to include city and country relationships
- Ensure the latest arts query also includes necessary associations
- Removed deprecated commented code for clarity

These changes improve data retrieval by establishing better relationships to
cities and their countries. This enhances the availability of data for
the views rendering the arts and keeps the code clean by removing
unnecessary comments.
This commit is contained in:
songtianlun 2025-02-17 14:38:29 +08:00
parent 81116a2f3e
commit f79299d707
3 changed files with 98 additions and 4 deletions

View File

@ -1,8 +1,8 @@
class HomeController < ApplicationController
def index
@popular_arts = WeatherArt.includes(:city, :image_attachment).by_popularity(3)
@popular_arts = WeatherArt.includes(:image_attachment, city: :country).by_popularity(3)
@latest_arts = WeatherArt.includes(:image_attachment, city: :country).latest(6)
# @random_arts = WeatherArt.includes(:city, :image_attachment).random(3)
@latest_arts = WeatherArt.includes(:city, :image_attachment).latest(6)
# @featured_arts = WeatherArt.includes(:city, :image_attachment).order(created_at: :desc).limit(5)
set_meta_tags(
title: "AI-Generated Weather Art",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 108 KiB

View File

@ -1,3 +1,97 @@
<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg">
<circle cx="256" cy="256" r="256" fill="red"/>
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="463.000000pt" height="463.000000pt" viewBox="0 0 463.000000 463.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,463.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M2240 4412 c-74 -25 -125 -59 -185 -123 -39 -42 -61 -57 -99 -67
-110 -28 -211 -124 -242 -228 -21 -74 -16 -184 10 -213 19 -21 24 -21 693 -21
l674 0 26 26 c24 24 25 30 21 102 -6 97 -32 157 -95 220 -60 60 -130 93 -210
100 -59 4 -64 7 -95 47 -50 63 -99 102 -173 137 -60 28 -81 32 -169 35 -78 2
-113 -1 -156 -15z m284 -122 c60 -29 135 -103 160 -157 l18 -42 67 6 c55 5 75
2 119 -17 78 -34 142 -117 142 -185 l0 -25 -615 0 -615 0 6 43 c18 117 126
215 240 217 25 0 37 8 63 48 38 54 101 106 157 127 61 23 196 15 258 -15z"/>
<path d="M3581 3714 c-30 -8 -76 -30 -103 -49 -35 -26 -59 -35 -87 -35 -72 0
-117 -63 -73 -103 14 -13 38 -17 96 -17 75 0 77 1 108 36 79 90 177 87 266
-10 l42 -46 81 0 c94 0 142 -18 164 -61 8 -15 15 -30 15 -34 0 -3 -148 -5
-330 -5 -317 0 -331 -1 -350 -20 -27 -27 -25 -55 6 -79 26 -20 38 -21 386 -21
l359 0 26 26 c23 23 25 31 20 83 -2 32 -12 71 -20 88 -42 81 -150 143 -249
143 -44 0 -56 5 -91 36 -76 69 -172 94 -266 68z"/>
<path d="M1352 3637 c-85 -53 -130 -87 -127 -95 3 -7 40 -68 83 -135 43 -67
132 -204 196 -305 l118 -183 32 20 c17 11 35 26 39 33 6 9 -45 97 -157 272
-91 142 -166 263 -166 267 0 9 70 59 82 59 7 0 170 -255 283 -442 33 -54 63
-98 68 -98 11 0 87 39 87 45 0 10 -375 612 -394 632 -9 10 -40 -5 -144 -70z"/>
<path d="M2160 3381 l0 -241 24 0 c13 0 38 3 55 6 l32 7 -3 231 -3 231 -52 3
-53 3 0 -240z"/>
<path d="M2380 3380 l0 -240 50 0 50 0 0 240 0 240 -50 0 -50 0 0 -240z"/>
<path d="M3012 3518 c-51 -83 -252 -441 -252 -449 0 -7 71 -49 84 -49 9 0 266
468 266 484 0 10 -59 46 -75 46 -2 0 -12 -15 -23 -32z"/>
<path d="M1932 3413 c-24 -8 -41 -20 -39 -27 2 -6 21 -72 42 -146 21 -74 39
-136 40 -138 2 -2 24 2 50 9 54 14 54 -7 2 188 -19 69 -38 126 -43 127 -5 1
-28 -5 -52 -13z"/>
<path d="M2650 3427 c0 -2 -16 -64 -35 -138 -19 -74 -35 -142 -35 -151 0 -15
51 -38 85 -38 9 0 75 242 79 287 1 10 -15 20 -44 29 -50 15 -50 15 -50 11z"/>
<path d="M3042 3124 c-57 -86 -102 -157 -100 -158 2 -1 19 -14 39 -28 l36 -27
74 107 c90 129 143 212 138 216 -30 22 -69 46 -76 46 -4 0 -54 -71 -111 -156z"/>
<path d="M1292 3017 l-31 -32 97 -91 c53 -49 102 -93 108 -97 12 -7 74 39 74
55 0 11 -13 24 -118 121 -46 42 -86 77 -90 77 -5 0 -22 -15 -40 -33z"/>
<path d="M3206 2949 l-108 -102 36 -35 35 -35 88 80 c139 127 133 117 92 159
l-35 34 -108 -101z"/>
<path d="M825 3017 c-17 -6 -46 -22 -65 -33 -19 -12 -60 -27 -90 -33 -101 -22
-165 -73 -209 -171 -34 -74 -26 -196 13 -222 6 -4 197 -8 424 -8 l412 0 20 32
c17 28 18 35 6 53 -13 19 -24 20 -401 23 l-388 2 6 42 c11 81 68 130 159 136
52 3 68 9 93 32 17 15 40 33 52 39 57 29 151 -1 199 -64 23 -30 32 -35 69 -35
26 0 50 6 59 15 37 38 26 90 -22 101 -15 4 -42 20 -60 35 -18 16 -47 36 -65
46 -40 21 -170 27 -212 10z"/>
<path d="M2222 2978 c-218 -17 -441 -128 -613 -305 -442 -455 -339 -1204 210
-1529 90 -52 206 -96 321 -119 124 -25 332 -17 453 19 445 132 734 538 714
1001 -18 408 -293 766 -683 889 -138 43 -250 56 -402 44z m250 -112 c354 -68
626 -322 710 -664 27 -110 29 -293 4 -396 -78 -328 -321 -581 -641 -667 -117
-32 -328 -32 -440 0 -274 77 -472 243 -590 493 -112 238 -102 538 26 779 66
123 199 263 325 342 169 105 411 150 606 113z"/>
<path d="M3550 2394 c-68 -19 -126 -37 -128 -38 -3 -4 18 -85 24 -94 2 -3 285
68 292 73 2 2 -2 23 -9 49 -14 56 -12 56 -179 10z"/>
<path d="M430 2010 l0 -160 370 0 370 0 0 50 0 50 -315 0 -315 0 0 55 0 55
315 0 315 0 0 33 c0 17 3 42 6 55 l6 22 -376 0 -376 0 0 -160z"/>
<path d="M3470 2146 c0 -13 3 -38 6 -55 l7 -31 308 0 309 0 0 -55 0 -55 -309
0 -308 0 -7 -31 c-15 -75 -49 -69 364 -69 l370 0 0 160 0 160 -370 0 -370 0 0
-24z"/>
<path d="M1037 1711 c-75 -21 -140 -40 -143 -43 -9 -9 18 -90 32 -95 11 -4 85
16 252 68 20 7 32 17 32 28 0 24 -20 81 -28 80 -4 0 -69 -17 -145 -38z"/>
<path d="M3441 1713 c-6 -21 -11 -43 -11 -49 0 -9 289 -100 295 -92 1 2 9 24
18 50 l15 47 -31 10 c-51 16 -256 71 -267 71 -5 0 -14 -17 -19 -37z"/>
<path d="M3371 1514 c-12 -26 -21 -47 -19 -49 8 -5 232 -137 298 -175 41 -24
119 -70 172 -102 l97 -59 -20 -34 c-34 -57 -39 -57 -104 -16 -73 46 -491 291
-498 291 -6 0 -59 -81 -55 -85 2 -1 26 -16 53 -32 28 -17 172 -103 321 -192
149 -88 276 -161 281 -161 8 0 163 255 163 268 0 4 -85 56 -188 116 -103 61
-218 129 -257 152 -38 22 -104 60 -146 82 l-75 42 -23 -46z"/>
<path d="M1170 1513 c-90 -50 -584 -335 -589 -339 -5 -5 153 -274 162 -274 5
0 34 15 65 33 181 107 588 349 591 353 2 2 -9 22 -24 44 l-28 40 -61 -34 c-34
-19 -158 -91 -276 -160 -118 -69 -220 -126 -226 -126 -12 0 -54 59 -54 77 0 8
196 127 443 268 65 37 117 70 115 74 -2 3 -10 23 -18 44 -8 20 -19 37 -25 37
-5 0 -39 -17 -75 -37z"/>
<path d="M1362 1104 c-62 -58 -112 -112 -112 -119 0 -7 15 -24 34 -39 l35 -26
113 109 113 110 -35 36 -36 35 -112 -106z"/>
<path d="M3139 1174 l-33 -34 112 -113 112 -112 36 36 35 36 -73 75 c-40 41
-91 91 -114 111 l-41 36 -34 -35z"/>
<path d="M1475 849 c-232 -366 -255 -404 -252 -410 5 -16 260 -180 267 -172 4
4 60 96 125 203 65 107 151 250 191 316 41 67 74 126 74 131 0 9 -63 43 -79
43 -9 0 -59 -77 -219 -340 -52 -85 -103 -167 -114 -183 l-19 -27 -45 31 c-27
19 -42 35 -37 42 20 35 219 345 272 426 33 51 61 97 61 101 0 9 -65 60 -77 60
-5 0 -71 -99 -148 -221z"/>
<path d="M2973 1047 c-18 -12 -32 -26 -33 -31 0 -4 71 -119 158 -255 87 -135
164 -256 170 -268 11 -20 8 -25 -32 -52 l-45 -31 -74 118 c-41 64 -118 190
-172 279 l-98 161 -44 -21 c-23 -11 -43 -24 -43 -27 0 -14 372 -625 393 -647
9 -9 41 8 137 73 69 47 126 88 128 93 1 4 -55 100 -126 212 -219 347 -267 419
-277 418 -5 0 -24 -11 -42 -22z"/>
<path d="M1936 756 c-21 -73 -38 -141 -39 -151 -2 -14 10 -21 45 -30 42 -11
48 -11 52 4 23 77 76 272 76 280 0 9 -60 31 -86 31 -6 0 -27 -60 -48 -134z"/>
<path d="M2602 877 c-18 -5 -31 -15 -29 -21 2 -6 21 -72 42 -146 20 -74 39
-138 41 -142 4 -5 47 3 91 17 11 4 6 24 -56 233 -23 78 -26 79 -89 59z"/>
<path d="M2160 470 l0 -381 158 3 157 3 3 378 2 377 -50 0 -50 0 0 -325 0
-325 -55 0 -55 0 -2 323 -3 322 -52 3 -53 3 0 -381z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 122 B

After

Width:  |  Height:  |  Size: 6.1 KiB