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
57524ea2
Commit
57524ea2
authored
Nov 16, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Product scope :query_spec_value_with_product
parent
97aece1e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
series.rb
lib/shotengai/series.rb
+3
-2
No files found.
lib/shotengai/series.rb
View file @
57524ea2
...
...
@@ -56,8 +56,9 @@ module Shotengai
# where("spec->'$.\"颜色\"' = ? and spec->'$.\"大小\"' = ?" ,红色,S)
scope
:query_spec_value_with_product
,
->
(
val
,
product
)
{
if
val
.
keys
.
sort
==
product
.
spec_template
.
keys
.
sort
keys
=
[];
values
=
[]
val
.
hash_map
{
|
k
,
v
|
keys
<<
"spec_value->'$.
\"
#{
k
}
\"
' = ? "
;
values
<<
v
}
keys
=
[];
values
=
[];
proc
=
Proc
.
new
{
|
k
,
v
|
keys
<<
"spec_value->'$.
\"
#{
k
}
\"
' = ? "
;
values
<<
v
}
val
===
Harray
?
val
.
hash_map
(
&
proc
)
:
val
.
map
(
&
proc
)
where
(
product:
product
).
where
(
keys
.
join
(
' and '
),
*
values
)
else
self
.
none
...
...
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