Compare commits
7 Commits
b343438f9e
...
main
Author | SHA1 | Date | |
---|---|---|---|
9ab29a3a15 | |||
6c5fe1bc00 | |||
8f9396c791 | |||
83023a31a7 | |||
a1aab1ac1f | |||
bb950b97a7 | |||
4ce1b29d86 |
@@ -22,4 +22,5 @@
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
||||
README.md
|
||||
PersonalNotes
|
5
PersonalNotes/faster-query.md
Executable file
5
PersonalNotes/faster-query.md
Executable file
@@ -0,0 +1,5 @@
|
||||
# How did I go from 4 second on each API request to under 1 second?
|
||||
|
||||
### 1. Using projection to limit fields
|
||||
### 2. Using proper indexes
|
||||
### 3. Using $sample along with aggregation
|
15
Program.cs
15
Program.cs
@@ -2,6 +2,7 @@
|
||||
using CatsOfMastodonBot.Models;
|
||||
using CatsOfMastodonBot.Services;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using mstdnCats.Services;
|
||||
@@ -41,12 +42,22 @@ public class MastodonBot
|
||||
{
|
||||
options.ListenAnyIP(5005); // Listen on port 5005
|
||||
});
|
||||
webBuilder.ConfigureServices(services =>
|
||||
{
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(options =>
|
||||
{
|
||||
options.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyOrigin();
|
||||
});
|
||||
});
|
||||
} );
|
||||
ServerStartup.Serverstartup(db);
|
||||
webBuilder.UseStartup<ServerStartup>();
|
||||
})
|
||||
.Build();
|
||||
|
||||
|
||||
|
||||
// Setup bot
|
||||
TelegramBotClient bot;
|
||||
|
@@ -19,7 +19,7 @@ public class ServerStartup
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
app.UseRouting();
|
||||
|
||||
app.UseCors();
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapGet("/", async context =>
|
||||
|
@@ -3,9 +3,10 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Cats of Mastodon!</title><style>
|
||||
<title>Cats of Mastodon! - Mahdium</title><style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Atma:wght@300;400;500;600;700&display=swap');
|
||||
body {
|
||||
font-family: 'Comic Neue', cursive;
|
||||
font-family: "Atma", system-ui;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
@@ -197,7 +198,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<h2 class="mastodon-title">Cats of Mastodon!</h2>
|
||||
<p class="welcome-message">Welcome to Daily Catventures! Get your daily dose of purr-fectly adorable feline fun! <span>✨</span><br>Posts gathered across Mastodon 🤝</p>
|
||||
<p class="welcome-message">Welcome to Daily Catventures! </br> Get your daily dose of purr-fectly adorable feline fun! <span>✨</span><br>Posts gathered across Mastodon 🤝</p>
|
||||
|
||||
<div class="post-container">
|
||||
<div class="post-content" style="display: none;">
|
||||
@@ -268,11 +269,13 @@
|
||||
|
||||
postImage.onload = () => {
|
||||
postImage.classList.remove('loading');
|
||||
window.scrollTo(0, document.body.scrollHeight);
|
||||
};
|
||||
|
||||
postImage.onerror = () => {
|
||||
console.error("Error loading image:", imageUrl);
|
||||
postImage.src = "https://s6.uupload.ir/files/a69d5fc9e900cc51_1920_kmnr.png";
|
||||
loadNewPost();
|
||||
postImage.classList.remove('loading');
|
||||
};
|
||||
|
||||
|
@@ -11,8 +11,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DotNetEnv" Version="3.1.1" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="3.1.0" />
|
||||
<PackageReference Include="Telegram.Bot" Version="22.3.0" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="3.3.0" />
|
||||
<PackageReference Include="Telegram.Bot" Version="22.4.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user