Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
Qui est-ce
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
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
Steel
Qui est-ce
Validations
e08c47c8
Valider
e08c47c8
rédigé
Il y a 9 mois
par
Steel
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
better caching
parent
d87e118b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
4
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
4 fichiers modifiés
src/app.html
+0
-1
0 ajout, 1 suppression
src/app.html
src/lib/data.ts
+18
-5
18 ajouts, 5 suppressions
src/lib/data.ts
src/routes/quiz/+page.server.ts
+1
-1
1 ajout, 1 suppression
src/routes/quiz/+page.server.ts
static/favicon.png
+0
-0
0 ajout, 0 suppression
static/favicon.png
avec
19 ajouts
et
7 suppressions
src/app.html
+
0
−
1
Voir le fichier @
e08c47c8
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
<html
lang=
"fr"
class=
"h-full"
>
<html
lang=
"fr"
class=
"h-full"
>
<head>
<head>
<meta
charset=
"utf-8"
/>
<meta
charset=
"utf-8"
/>
<link
rel=
"icon"
href=
"%sveltekit.assets%/favicon.png"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<link
rel=
"apple-touch-icon"
sizes=
"180x180"
href=
"/apple-touch-icon.png"
/>
<link
rel=
"apple-touch-icon"
sizes=
"180x180"
href=
"/apple-touch-icon.png"
/>
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/lib/data.ts
+
18
−
5
Voir le fichier @
e08c47c8
...
@@ -12,7 +12,8 @@ const cache = new Map<number, PromoCache>();
...
@@ -12,7 +12,8 @@ const cache = new Map<number, PromoCache>();
// 1 hour
// 1 hour
const
CACHE_DURATION_MS
=
1000
*
60
*
60
;
const
CACHE_DURATION_MS
=
1000
*
60
*
60
;
async
function
cacheImages
(
users
:
UserId
[]):
Promise
<
void
>
{
async
function
cacheImages
(
users
:
Iterable
<
UserId
>
):
Promise
<
void
>
{
let
count
=
0
;
for
(
const
user
of
users
)
{
for
(
const
user
of
users
)
{
const
response
=
await
client
.
query
(
USER_DETAILS_QUERY
,
{
idList
:
[
user
]
});
const
response
=
await
client
.
query
(
USER_DETAILS_QUERY
,
{
idList
:
[
user
]
});
...
@@ -23,17 +24,22 @@ async function cacheImages(users: UserId[]): Promise<void> {
...
@@ -23,17 +24,22 @@ async function cacheImages(users: UserId[]): Promise<void> {
const
photo
=
response
.
data
?.
page
.
nodes
[
0
].
photo
;
const
photo
=
response
.
data
?.
page
.
nodes
[
0
].
photo
;
if
(
!
photo
?.
url
)
continue
;
if
(
!
photo
?.
url
)
continue
;
await
fetch
(
photo
.
url
,
{
method
:
"
HEAD
"
});
await
fetch
(
photo
.
url
,
{
method
:
"
HEAD
"
});
count
++
;
}
}
console
.
log
(
"
cached
"
,
users
.
length
,
"
images
"
);
console
.
log
(
"
cached
"
,
count
,
"
images
"
);
}
// background task
async
function
cachePromotionImages
(
year
:
number
)
{
const
promo
=
cache
.
get
(
year
);
if
(
!
promo
)
return
;
await
cacheImages
(
promo
.
promotion
);
}
}
async
function
fetchPromotion
(
year
:
number
):
Promise
<
PromoCache
>
{
async
function
fetchPromotion
(
year
:
number
):
Promise
<
PromoCache
>
{
const
array
=
await
Array
.
fromAsync
(
pageIterator
(
PROMOTION_QUERY
,
{
year
}));
const
array
=
await
Array
.
fromAsync
(
pageIterator
(
PROMOTION_QUERY
,
{
year
}));
const
users
=
array
.
map
((
node
)
=>
node
.
id
);
const
users
=
array
.
map
((
node
)
=>
node
.
id
);
// background task
cacheImages
(
users
);
return
{
return
{
lastUpdateMs
:
new
Date
().
getTime
(),
lastUpdateMs
:
new
Date
().
getTime
(),
promotion
:
new
Set
(
users
),
promotion
:
new
Set
(
users
),
...
@@ -49,6 +55,7 @@ export async function getPromotion(year: number): Promise<Set<UserId>> {
...
@@ -49,6 +55,7 @@ export async function getPromotion(year: number): Promise<Set<UserId>> {
console
.
log
(
"
year
"
,
year
,
"
not in cache, fetching
"
);
console
.
log
(
"
year
"
,
year
,
"
not in cache, fetching
"
);
const
freshData
=
await
fetchPromotion
(
year
);
const
freshData
=
await
fetchPromotion
(
year
);
cache
.
set
(
year
,
freshData
);
cache
.
set
(
year
,
freshData
);
cachePromotionImages
(
year
);
return
freshData
.
promotion
;
return
freshData
.
promotion
;
}
}
...
@@ -70,3 +77,9 @@ export function getPromotionRange(
...
@@ -70,3 +77,9 @@ export function getPromotionRange(
(
array
)
=>
new
Set
(
array
),
(
array
)
=>
new
Set
(
array
),
);
);
}
}
setInterval
(()
=>
{
for
(
const
year
of
cache
.
keys
())
{
cachePromotionImages
(
year
);
}
},
CACHE_DURATION_MS
/
2
);
Ce diff est replié.
Cliquez pour l'agrandir.
src/routes/quiz/+page.server.ts
+
1
−
1
Voir le fichier @
e08c47c8
...
@@ -66,7 +66,7 @@ export async function load(event) {
...
@@ -66,7 +66,7 @@ export async function load(event) {
}
}
const
MAX_POINTS
=
10
;
const
MAX_POINTS
=
10
;
const
MIN_POINTS
=
0
;
const
MIN_POINTS
=
3
;
// Durée maximale pour obtenir le score maximal
// Durée maximale pour obtenir le score maximal
const
SERVER_DELAY_MAX
=
3
;
const
SERVER_DELAY_MAX
=
3
;
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
static/favicon.png
supprimé
100644 → 0
+
0
−
0
Voir le fichier @
d87e118b
1,53 ko
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