Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 467c3ef

Browse files
database added
1 parent 29bef41 commit 467c3ef

11 files changed

+64
-0
lines changed

‎api/__pycache__/admin.cpython-39.pyc

334 Bytes
Binary file not shown.

‎api/__pycache__/models.cpython-39.pyc

284 Bytes
Binary file not shown.

‎api/__pycache__/views.cpython-39.pyc

364 Bytes
Binary file not shown.

‎api/admin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
from django.contrib import admin
2+
from api.models import leetcodeUsername
3+
4+
class leetcodeUsernameAdmin(admin.ModelAdmin):
5+
list_display = ('username', 'count')
6+
search_fields = ('username',)
27

38
# Register your models here.
9+
admin.site.register(leetcodeUsername, leetcodeUsernameAdmin)

‎api/migrations/0001_initial.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 4.0.4 on 2022年05月10日 19:51
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='leetcodeUsername',
16+
fields=[
17+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('username', models.CharField(max_length=30)),
19+
('count', models.IntegerField(default=0)),
20+
],
21+
),
22+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 4.0.4 on 2022年05月10日 20:03
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api', '0001_initial'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='leetcodeusername',
15+
name='count',
16+
field=models.IntegerField(default=1),
17+
),
18+
]
730 Bytes
Binary file not shown.
611 Bytes
Binary file not shown.

‎api/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
from django.db import models
22

33
# Create your models here.
4+
5+
# Create your models here.
6+
class leetcodeUsername(models.Model):
7+
username = models.CharField(max_length=30)
8+
count = models.IntegerField(default=1)

‎api/views.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import json
55
import pandas as pd
66
from django.utils.html import format_html
7+
from django.db.models import F
8+
9+
from api.models import leetcodeUsername
710

811
# Create your views here.
912

@@ -108,6 +111,11 @@ def svg(request, username):
108111

109112

110113
def svg_icon(request, username):
114+
if leetcodeUsername.objects.filter(username = username).exists():
115+
leetcodeUsername.objects.filter(username=username).update(count=F('count') + 1)
116+
else:
117+
leetcodeUsername.objects.create(username = username).save()
118+
111119
print('dddd')
112120

113121
query = '''
@@ -226,6 +234,11 @@ def svg_icon(request, username):
226234
return HttpResponse(svg_tag, content_type="image/svg+xml")
227235

228236
def svg_icon_theme(request, username, theme):
237+
if leetcodeUsername.objects.filter(username = username).exists():
238+
leetcodeUsername.objects.filter(username=username).update(count=F('count') + 1)
239+
else:
240+
leetcodeUsername.objects.create(username = username).save()
241+
229242
if(theme.lower() == 'dark'):
230243
# print('dddd')
231244

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /