Skip to content

Commit 4c96f78

Browse files
committed
minor fixes
1 parent cf3417c commit 4c96f78

File tree

7 files changed

+68
-135
lines changed

7 files changed

+68
-135
lines changed

.oxlintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"ignorePatterns": ["services/lumina-node-wasm/**"]
2+
"ignorePatterns": ["services/lumina-node-wasm/**", "services/utils/blob.js", "services/utils/blobtx.js"]
33
}

components/ui/Input.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ watch(
6868
)
6969
7070
const getInputType = computed(() => {
71-
if (!!props.type) return props.type
71+
if (props.type) return props.type
7272
return "text"
7373
})
7474

services/api/rollup.js

Lines changed: 5 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -20,83 +20,6 @@ export const fetchRollups = async ({ categories, type, tags, limit, offset, sort
2020
}
2121
}
2222

23-
// export const fetchRollupsCount = async () => {
24-
// try {
25-
// const url = new URL(`${useServerURL()}/rollup/count`)
26-
27-
// const data = await useFetch(url.href)
28-
// return data
29-
// } catch (error) {
30-
// console.error(error)
31-
// }
32-
// }
33-
34-
// export const fetchRollupByID = async (id) => {
35-
// try {
36-
// const url = new URL(`${useServerURL()}/rollup/${id}`)
37-
38-
// const data = await useFetch(encodeURI(url.href))
39-
// return data
40-
// } catch (error) {
41-
// console.error(error)
42-
// }
43-
// }
44-
45-
// export const fetchRollupBySlug = async (slug) => {
46-
// try {
47-
// const url = new URL(`${useServerURL()}/rollup/slug/${slug}`)
48-
49-
// const data = await useFetch(encodeURI(url.href))
50-
// return data
51-
// } catch (error) {
52-
// console.error(error)
53-
// }
54-
// }
55-
56-
// export const fetchRollupBlobs = async ({ id, limit, offset, sort, sort_by }) => {
57-
// try {
58-
// const url = new URL(`${useServerURL()}/rollup/${id}/blobs`)
59-
60-
// if (limit) url.searchParams.append("limit", limit)
61-
// if (offset) url.searchParams.append("offset", offset)
62-
// if (sort) url.searchParams.append("sort", sort)
63-
// if (sort_by) url.searchParams.append("sort_by", sort_by)
64-
65-
// const data = await useFetch(encodeURI(url.href))
66-
// return data
67-
// } catch (error) {
68-
// console.error(error)
69-
// }
70-
// }
71-
72-
// export const fetchRollupNamespaces = async ({ id, limit, offset }) => {
73-
// try {
74-
// const url = new URL(`${useServerURL()}/rollup/${id}/namespaces`)
75-
76-
// if (limit) url.searchParams.append("limit", limit)
77-
// if (offset) url.searchParams.append("offset", offset)
78-
79-
// const data = await useFetch(encodeURI(url.href))
80-
// return data
81-
// } catch (error) {
82-
// console.error(error)
83-
// }
84-
// }
85-
86-
// export const fetchRollupExportData = async ({ id, from, to }) => {
87-
// try {
88-
// const url = new URL(`${useServerURL()}/rollup/${id}/export`)
89-
90-
// url.searchParams.append("from", from)
91-
// url.searchParams.append("to", to)
92-
93-
// const data = await useFetch(encodeURI(url.href))
94-
// return data
95-
// } catch (error) {
96-
// console.error(error)
97-
// }
98-
// }
99-
10023
export const fetchRollupsCount = () => {
10124
try {
10225
const url = new URL(`${useServerURL()}/rollup/count`)
@@ -202,7 +125,7 @@ export const fetchRollupTVL = async ({ slug, period, from, to }) => {
202125

203126
if (from) url.searchParams.append("from", from)
204127
if (to) url.searchParams.append("to", to)
205-
128+
206129
const data = await $fetch(url.href)
207130
return data
208131
} catch (error) {
@@ -216,7 +139,7 @@ export const fetchRollupOrgs = async ({ limit, offset }) => {
216139

217140
if (limit) url.searchParams.append("limit", limit)
218141
if (offset) url.searchParams.append("offset", offset)
219-
142+
220143
const data = await $fetch(url.href)
221144
return data
222145
} catch (error) {
@@ -255,7 +178,7 @@ export const fetchRollupOrgReposBySlug = async ({ slug, limit, offset, sort_by,
255178
if (offset) url.searchParams.append("offset", offset)
256179
if (sort_by) url.searchParams.append("sort_by", sort_by)
257180
if (sort) url.searchParams.append("sort", sort)
258-
181+
259182
const data = await $fetch(url.href)
260183
return data
261184
} catch (error) {
@@ -264,13 +187,13 @@ export const fetchRollupOrgReposBySlug = async ({ slug, limit, offset, sort_by,
264187
}
265188
}
266189

267-
export const fetchRollupOrgCommitsBySlug = async ({ slug, timeframe = 'week', from, to }) => {
190+
export const fetchRollupOrgCommitsBySlug = async ({ slug, timeframe = "week", from, to }) => {
268191
try {
269192
const url = new URL(`${githubServiceURL}/org/${slug}/commits/${timeframe}`)
270193

271194
if (from) url.searchParams.append("from", from)
272195
if (to) url.searchParams.append("to", to)
273-
196+
274197
const data = await $fetch(url.href)
275198
return data
276199
} catch (error) {

services/api/socket.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ export const init = () => {
1010
const appStore = useAppStore()
1111

1212
const startWs = () => {
13-
1413
socket = new WebSocket(useSocketURL())
1514

16-
socket.addEventListener("open", (e) => {
15+
socket.addEventListener("open", () => {
1716
/** Head Subscription */
1817
socket.send(
1918
JSON.stringify({
@@ -37,13 +36,13 @@ export const init = () => {
3736

3837
socket.addEventListener("message", (e) => {
3938
const data = JSON.parse(e.data)
40-
if (data.channel === 'head') {
41-
appStore.lastHead = data.body;
42-
} else if (data.channel === 'blocks') {
43-
appStore.latestBlocks.unshift(data.body);
39+
if (data.channel === "head") {
40+
appStore.lastHead = data.body
41+
} else if (data.channel === "blocks") {
42+
appStore.latestBlocks.unshift(data.body)
4443
setTimeout(() => {
45-
appStore.latestBlocks.pop();
46-
}, 1000);
44+
appStore.latestBlocks.pop()
45+
}, 1000)
4746
}
4847
})
4948

services/constants/rollups.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export const getRankCategory = (rank) => {
2828

2929
export const getMetricCategory = (metric, score) => {
3030
const metricValue = rankCoefficients[metric]
31-
let rank = roundTo(score / metricValue * 10, 0)
31+
let rank = roundTo((score / metricValue) * 10, 0)
3232

33-
return {...getRankCategory(rank), rank: score / metricValue}
33+
return { ...getRankCategory(rank), rank: score / metricValue }
3434
}
3535

3636
export const lastActivityCategories = [

services/utils/export.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ export async function exportToCSV(data, fileName) {
77
const blob = new Blob([data], { type: "text/csv;charset=utf-8;" })
88
const link = document.createElement("a")
99

10-
link.href = URL.createObjectURL(blob)
10+
link.href = URL.createObjectURL(blob)
1111
link.download = `${fileName}.csv`
1212

1313
link.style.visibility = "hidden"
1414
document.body.appendChild(link)
1515

1616
setTimeout(() => {
1717
link.click()
18-
}, 100);
19-
18+
}, 100)
19+
2020
document.body.removeChild(link)
2121
}
2222

@@ -25,53 +25,54 @@ export async function exportSVGToPNG(svgElement, fileName, width = 1920, height
2525

2626
// Load SVG styles
2727
const styleSheets = Array.from(document.styleSheets)
28-
.filter(style => style.href === null)
29-
.map(sheet => {
28+
.filter((style) => style.href === null)
29+
.map((sheet) => {
3030
try {
3131
return Array.from(sheet.cssRules)
32-
.map(rule => rule.cssText)
33-
.join('\n')
32+
.map((rule) => rule.cssText)
33+
.join("\n")
3434
} catch (e) {
35-
console.warn('Failed to read styles from', sheet.href)
36-
37-
return ''
35+
console.warn("Failed to read styles from", sheet.href, e)
36+
37+
return ""
3838
}
39-
}).join('\n')
39+
})
40+
.join("\n")
4041

4142
// Create clone and <style> element and add to SVG
42-
const svgStyle = document.createElement('style')
43+
const svgStyle = document.createElement("style")
4344
svgStyle.textContent = styleSheets
44-
45+
4546
let svgClone = svgElement.cloneNode(true)
4647
svgClone.prepend(svgStyle)
47-
48+
4849
// Set SVG size
49-
svgClone.setAttribute('width', width);
50-
svgClone.setAttribute('height', height);
50+
svgClone.setAttribute("width", width)
51+
svgClone.setAttribute("height", height)
5152

5253
// Convert SVG to string
5354
const serializer = new XMLSerializer()
5455
const svgString = serializer.serializeToString(svgClone)
5556

5657
// Convert and export SVG
5758
const img = new Image()
58-
const svgBlob = new Blob([svgString], { type: 'image/svg+xml;charset=utf-8' })
59+
const svgBlob = new Blob([svgString], { type: "image/svg+xml;charset=utf-8" })
5960
const url = URL.createObjectURL(svgBlob)
6061

61-
img.onload = function() {
62-
const canvas = document.createElement('canvas')
62+
img.onload = function () {
63+
const canvas = document.createElement("canvas")
6364
canvas.width = width
6465
canvas.height = height
65-
const ctx = canvas.getContext('2d')
66+
const ctx = canvas.getContext("2d")
6667
ctx.drawImage(img, 0, 0, width, height)
67-
const png = canvas.toDataURL('image/png')
68+
const png = canvas.toDataURL("image/png")
6869

6970
// Create link for download
70-
const link = document.createElement('a')
71+
const link = document.createElement("a")
7172
link.href = png
7273
link.download = `${fileName}.png`
7374
document.body.appendChild(link)
74-
link.click();
75+
link.click()
7576
document.body.removeChild(link)
7677

7778
URL.revokeObjectURL(url)

store/rollupsrank.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { defineStore, acceptHMRUpdate } from "pinia"
33
import { DateTime } from "luxon"
44

55
/** Services */
6-
import { capitalizeAndReplace, isMainnet, roundTo, sortArrayOfObjects } from "@/services/utils"
6+
import { capitalizeAndReplace, isMainnet, roundTo } from "@/services/utils"
77
import { rankCoefficients } from "@/services/constants/rollups"
88

99
/** API */
10-
import { fetchRollupOrgs, fetchRollupOrgsState, fetchRollupOrgReposBySlug, fetchRollups, fetchRollupsDailyStats } from "@/services/api/rollup"
10+
import { fetchRollupOrgs, fetchRollupOrgsState, fetchRollups, fetchRollupsDailyStats } from "@/services/api/rollup"
1111

1212
export const useRollupsRankingStore = defineStore("rollups_ranking", () => {
1313
const rollups_ranking = ref({
@@ -30,14 +30,14 @@ export const useRollupsRankingStore = defineStore("rollups_ranking", () => {
3030
initialized.value = true
3131
return
3232
}
33-
33+
3434
const limit = 100
3535
const params = { limit }
3636
const [rollupsData, orgsData, dailyStatsData, orgsState] = await Promise.all([
3737
fetchRollups(params),
3838
fetchRollupOrgs(params),
3939
fetchRollupsDailyStats(params),
40-
fetchRollupOrgsState(params)
40+
fetchRollupOrgsState(params),
4141
])
4242
let maxDailyBlobsCount = 0
4343
let maxAvgPfbSize = 0
@@ -66,21 +66,20 @@ export const useRollupsRankingStore = defineStore("rollups_ranking", () => {
6666
rollupsRanking.value[slug].commits_weekly = od.commits_weekly
6767
}
6868

69-
rollupsData.forEach(r => {
69+
rollupsData.forEach((r) => {
7070
let slug = r.slug
7171
if (!rollupsRanking.value[slug]) {
7272
rollupsRanking.value[slug] = {}
7373
}
7474
rollupsRanking.value[slug].last_message_time = r.last_message_time
75-
7675
})
77-
76+
7877
const quantitative = (value, maxValue) => {
7978
return Math.min(value / maxValue, 1)
8079
}
8180
const timeBased = (maxTime, lastTime, t, timeframe) => {
8281
const diff = maxTime.diff(lastTime, timeframe)[timeframe]
83-
return Math.exp(-( diff / t ))
82+
return Math.exp(-(diff / t))
8483
}
8584
const calculateRanking = (r) => {
8685
let ranking = {
@@ -95,38 +94,49 @@ export const useRollupsRankingStore = defineStore("rollups_ranking", () => {
9594
ranking.commits_weekly = roundTo(quantitative(r.commits_weekly, maxWeeklyCommits) * rankCoefficients.commits_weekly * 100)
9695
}
9796
if (r.day_blobs_count) {
98-
ranking.day_blobs_count = roundTo(quantitative(r.day_blobs_count, maxDailyBlobsCount) * rankCoefficients.day_blobs_count * 100)
97+
ranking.day_blobs_count = roundTo(
98+
quantitative(r.day_blobs_count, maxDailyBlobsCount) * rankCoefficients.day_blobs_count * 100,
99+
)
99100
}
100101
if (r.avg_pfb_size) {
101102
ranking.avg_pfb_size = roundTo(quantitative(r.avg_pfb_size, maxAvgPfbSize) * rankCoefficients.avg_pfb_size * 100)
102103
}
103104
if (r.last_message_time) {
104-
ranking.last_message_time = roundTo(timeBased(DateTime.now(), DateTime.fromISO(r.last_message_time), 12, "hours") * rankCoefficients.last_message_time * 100)
105+
ranking.last_message_time = roundTo(
106+
timeBased(DateTime.now(), DateTime.fromISO(r.last_message_time), 12, "hours") *
107+
rankCoefficients.last_message_time *
108+
100,
109+
)
105110
}
106111
if (r.last_pushed_at) {
107-
ranking.last_pushed_at = roundTo(timeBased(DateTime.fromISO(orgsState), DateTime.fromISO(r.last_pushed_at), 4, "weeks") * rankCoefficients.last_pushed_at * 100)
112+
ranking.last_pushed_at = roundTo(
113+
timeBased(DateTime.fromISO(orgsState), DateTime.fromISO(r.last_pushed_at), 4, "weeks") *
114+
rankCoefficients.last_pushed_at *
115+
100,
116+
)
108117
}
109118

110119
ranking.rank = roundTo(Object.values(ranking).reduce((acc, val) => acc + val, 0))
111120
return ranking
112121
}
113122

114-
Object.keys(rollupsRanking.value).forEach(r => {
123+
Object.keys(rollupsRanking.value).forEach((r) => {
115124
rollupsRanking.value[r].ranking = calculateRanking(rollupsRanking.value[r])
116125
})
117126

118-
const maxRankEntry = Object.entries(rollupsRanking.value).reduce((maxEntry, [key, value]) => {
119-
return value.ranking.rank > maxEntry.rank
120-
? { slug: key, rank: value.ranking.rank }
121-
: maxEntry
122-
}, { slug: null, rank: 0 })
127+
const maxRankEntry = Object.entries(rollupsRanking.value).reduce(
128+
(maxEntry, [key, value]) => {
129+
return value.ranking.rank > maxEntry.rank ? { slug: key, rank: value.ranking.rank } : maxEntry
130+
},
131+
{ slug: null, rank: 0 },
132+
)
123133

124134
rollups_ranking.value = {
125135
ranking: rollupsRanking.value,
126136
top_rollup: {
127137
slug: maxRankEntry.slug,
128138
name: capitalizeAndReplace(maxRankEntry.slug, "-"),
129-
rank: maxRankEntry.rank
139+
rank: maxRankEntry.rank,
130140
},
131141
last_update: DateTime.now().ts,
132142
}

0 commit comments

Comments
 (0)