Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
P
parlote-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
parlote-facil
Validations
83103c47
Valider
83103c47
rédigé
12 years ago
par
Jonne Haß
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
deterministic stream order take 2, this time with spec
parent
d767410e
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Étiquettes contenant la validation
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
app/models/user/querying.rb
+2
-2
2 ajouts, 2 suppressions
app/models/user/querying.rb
spec/models/user/querying_spec.rb
+15
-0
15 ajouts, 0 suppression
spec/models/user/querying_spec.rb
avec
17 ajouts
et
2 suppressions
app/models/user/querying.rb
+
2
−
2
Voir le fichier @
83103c47
...
@@ -16,7 +16,7 @@ module User::Querying
...
@@ -16,7 +16,7 @@ module User::Querying
def
visible_shareables
(
klass
,
opts
=
{})
def
visible_shareables
(
klass
,
opts
=
{})
opts
=
prep_opts
(
klass
,
opts
)
opts
=
prep_opts
(
klass
,
opts
)
shareable_ids
=
visible_shareable_ids
(
klass
,
opts
)
shareable_ids
=
visible_shareable_ids
(
klass
,
opts
)
klass
.
where
(
:id
=>
shareable_ids
).
select
(
'DISTINCT '
+
klass
.
to_s
.
tableize
+
'.*'
).
limit
(
opts
[
:limit
]).
order
(
opts
[
:order_with_table
])
klass
.
where
(
:id
=>
shareable_ids
).
select
(
'DISTINCT '
+
klass
.
to_s
.
tableize
+
'.*'
).
limit
(
opts
[
:limit
]).
order
(
opts
[
:order_with_table
])
.
order
(
klass
.
table_name
+
".id DESC"
)
end
end
def
visible_shareable_ids
(
klass
,
opts
=
{})
def
visible_shareable_ids
(
klass
,
opts
=
{})
...
@@ -48,7 +48,7 @@ module User::Querying
...
@@ -48,7 +48,7 @@ module User::Querying
def
ugly_select_clause
(
query
,
opts
)
def
ugly_select_clause
(
query
,
opts
)
klass
=
opts
[
:klass
]
klass
=
opts
[
:klass
]
select_clause
=
'DISTINCT %s.id, %s.updated_at AS updated_at, %s.created_at AS created_at'
%
[
klass
.
table_name
,
klass
.
table_name
,
klass
.
table_name
]
select_clause
=
'DISTINCT %s.id, %s.updated_at AS updated_at, %s.created_at AS created_at'
%
[
klass
.
table_name
,
klass
.
table_name
,
klass
.
table_name
]
query
.
select
(
select_clause
).
order
(
opts
[
:order_with_table
]).
order
(
klass
.
table_name
+
'.id DESC'
).
where
(
klass
.
arel_table
[
opts
[
:order_field
]].
lt
(
opts
[
:max_time
]))
query
.
select
(
select_clause
).
order
(
opts
[
:order_with_table
]).
where
(
klass
.
arel_table
[
opts
[
:order_field
]].
lt
(
opts
[
:max_time
]))
end
end
def
construct_shareable_from_others_query
(
opts
)
def
construct_shareable_from_others_query
(
opts
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
spec/models/user/querying_spec.rb
+
15
−
0
Voir le fichier @
83103c47
...
@@ -113,6 +113,21 @@ describe User::Querying do
...
@@ -113,6 +113,21 @@ describe User::Querying do
Factory
(
:status_message
,
:public
=>
true
)
Factory
(
:status_message
,
:public
=>
true
)
bob
.
visible_shareables
(
Post
).
count
.
should
==
0
bob
.
visible_shareables
(
Post
).
count
.
should
==
0
end
end
context
'with two posts with the same timestamp'
do
before
do
aspect_id
=
alice
.
aspects
.
where
(
:name
=>
"generic"
).
first
.
id
Timecop
.
freeze
Time
.
now
do
alice
.
post
:status_message
,
:text
=>
"first"
,
:to
=>
aspect_id
alice
.
post
:status_message
,
:text
=>
"second"
,
:to
=>
aspect_id
end
end
it
"returns them in reverse creation order"
do
bob
.
visible_shareables
(
Post
).
first
.
text
.
should
==
"second"
bob
.
visible_shareables
(
Post
).
last
.
text
.
should
==
"first"
end
end
context
'with many posts'
do
context
'with many posts'
do
before
do
before
do
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter