feat(app/web): update ratelimit and placeholders (#826)

This commit is contained in:
Simon Lecoq
2022-01-28 02:22:42 +01:00
committed by GitHub
parent 9f4e255c85
commit 3945af02d1
12 changed files with 3124 additions and 28 deletions

View File

@@ -1,3 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
@@ -28,7 +29,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></path></svg>
Search a GitHub user
</h2>
<small :class="{'error-text':!requests.remaining}">{{ requests.remaining }} GitHub requests remaining</small>
<small :class="{'error-text':(!requests.rest.remaining)||(!requests.graphql.remaining)}">Remaining GitHub requests: {{ requests.rest.remaining }} REST / {{ requests.graphql.remaining }} GraphQL</small>
<small>Send feedback on <a href="https://github.com/lowlighter/metrics/discussions/229" target="_blank">GitHub discussions</a>!</small>
</div>
<div class="inputs">
@@ -42,6 +43,10 @@
</template>
</button>
</div>
<div class="warning" v-if="(!requests.rest.remaining)||(!requests.graphql.remaining)">
This web instance has run out of GitHub API requests.
Please wait until {{ rlreset }} to generate metrics again.
</div>
<small class="info">
Display rankings, contributions, highlights, commits calendar, used languages and recent activity from any user account!
</small>
@@ -237,7 +242,7 @@
<div class="chart-bars">
<div class="entry" v-for="h in 24">
<span class="value">{{ habits[h] }}</span>
<div class="bar" :style="{height:(habits[h]/habits.max)*150, backgroundColor:`var(--color-calendar-graph-day-L${Math.ceil((habits[h]/habits.max)/0.25)}-bg)`}"></div>
<div class="bar" :style="{height:`${((habits[h]||0)/(habits.max||1))*150}px`, backgroundColor:`var(--color-calendar-graph-day-L${Math.ceil(((habits[h]||0)/(habits.max||1))/0.25)}-bg)`}"></div>
<span class="label">{{ `${h}`.padStart(2, 0) }}</span>
</div>
</div>
@@ -369,6 +374,6 @@
<!-- Scripts -->
<script src="/.js/axios.min.js"></script>
<script src="/.js/vue.min.js"></script>
<script src="/about/.statics/script.js?v=3.18"></script>
<script src="/about/.statics/script.js?v=3.19"></script>
</body>
</html>

View File

@@ -93,6 +93,10 @@
}
finally {
this.pending = false
try {
const { data: requests } = await axios.get("/.requests")
this.requests = requests
} catch {}
}
},
},
@@ -111,6 +115,7 @@
return this.metrics?.rendered.plugins.followup ?? null
},
habits() {
console.log(this.metrics?.rendered.plugins.habits.commits.hours)
return this.metrics?.rendered.plugins.habits.commits.hours ?? null
},
isocalendar() {
@@ -142,6 +147,10 @@
preview() {
return /-preview$/.test(this.version)
},
rlreset() {
const reset = new Date(Math.max(this.requests.graphql.reset, this.requests.rest.reset))
return `${reset.getHours()}:${reset.getMinutes()}`
}
},
//Data initialization
data: {
@@ -151,7 +160,7 @@
embed: false,
localstorage: false,
searchable: false,
requests: { limit: 0, used: 0, remaining: 0, reset: 0 },
requests: {rest:{limit:0, used:0, remaining:0, reset:NaN}, graphql:{limit:0, used:0, remaining:0, reset:NaN}},
palette: "light",
metrics: null,
pending: false,