Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shotengai
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
shotengai
Commits
94f8a98f
Commit
94f8a98f
authored
Nov 16, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow series scope :query_spec_value_with_product
Allow series scope :query_spec_value_with_product to get spec_value which contain target value
parent
6a5e335b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
product.rb
lib/shotengai/product.rb
+2
-2
series.rb
lib/shotengai/series.rb
+2
-2
No files found.
lib/shotengai/product.rb
View file @
94f8a98f
...
...
@@ -74,8 +74,8 @@ module Shotengai
Shotengai
::
Series
.
alive
.
find_by_id
(
default_series_id
)
||
series
.
alive
.
first
end
def
series_with_spec_value
val
series_class
.
query_spec_value_with_product
(
val
,
self
)
def
series_with_spec_value
val
,
eql
=
true
series_class
.
query_spec_value_with_product
(
val
,
self
,
eql
)
end
def
meta
...
...
lib/shotengai/series.rb
View file @
94f8a98f
...
...
@@ -54,8 +54,8 @@ module Shotengai
scope
:recycle_bin
,
->
{
unscope
(
where: :aasm_state
).
deleted
.
where
(
'updated_at < ?'
,
Time
.
now
-
10
.
day
)}
# where("spec->'$.\"颜色\"' = ? and spec->'$.\"大小\"' = ?" ,红色,S)
scope
:query_spec_value_with_product
,
->
(
val
,
product
)
{
if
val
.
keys
.
sort
==
product
.
spec_template
.
keys
.
sort
scope
:query_spec_value_with_product
,
->
(
val
,
product
,
eql
=
true
)
{
if
val
.
keys
.
sort
==
product
.
spec_template
.
keys
.
sort
||
(
!
.
eql
&&
(
val
.
keys
-
product
.
spec_template
.
keys
).
empty?
)
keys
=
[];
values
=
[];
proc
=
Proc
.
new
{
|
k
,
v
|
keys
<<
"spec_value->'$.
\"
#{
k
}
\"
' = ? "
;
values
<<
v
}
Shotengai
::
Harray
===
val
?
val
.
hash_map
(
&
proc
)
:
val
.
map
(
&
proc
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment