increased todo and archive limits slightly

This commit is contained in:
Toastie 2025-01-31 13:49:31 +13:00
parent c6ea3fd36f
commit 4fb4a2d0c3
Signed by: toastie_t0ast
GPG key ID: 0861BE54AD481DC7
4 changed files with 39 additions and 8 deletions

View file

@ -150,7 +150,26 @@ public partial class Utility
[Cmd]
public async Task TodoArchiveAdd([Leftover] string name)
{
var result = await _service.ArchiveTodosAsync(ctx.User.Id, name);
var result = await _service.ArchiveTodosAsync(ctx.User.Id, name, false);
if (result == ArchiveTodoResult.NoTodos)
{
await Response().Error(strs.todo_no_todos).SendAsync();
return;
}
if (result == ArchiveTodoResult.MaxLimitReached)
{
await Response().Error(strs.todo_archive_max_limit).SendAsync();
return;
}
await ctx.OkAsync();
}
[Cmd]
public async Task TodoArchiveDone([Leftover] string name)
{
var result = await _service.ArchiveTodosAsync(ctx.User.Id, name, true);
if (result == ArchiveTodoResult.NoTodos)
{
await Response().Error(strs.todo_no_todos).SendAsync();
@ -193,7 +212,7 @@ public partial class Utility
foreach (var archivedList in items)
{
eb.AddField($"id: {archivedList.Id.ToString()}", archivedList.Name, true);
eb.AddField($"id: {new kwum(archivedList.Id)}", archivedList.Name, true);
}
return eb;
@ -202,7 +221,7 @@ public partial class Utility
}
[Cmd]
public async Task TodoArchiveShow(int id)
public async Task TodoArchiveShow(kwum id)
{
var list = await _service.GetArchivedTodoListAsync(ctx.User.Id, id);
if (list == null || list.Items.Count == 0)
@ -234,7 +253,7 @@ public partial class Utility
}
[Cmd]
public async Task TodoArchiveDelete(int id)
public async Task TodoArchiveDelete(kwum id)
{
if (!await _service.ArchiveDeleteAsync(ctx.User.Id, id))
{

View file

@ -6,8 +6,8 @@ namespace EllieBot.Modules.Utility;
public sealed class TodoService : IEService
{
private const int ARCHIVE_MAX_COUNT = 9;
private const int TODO_MAX_COUNT = 27;
private const int ARCHIVE_MAX_COUNT = 18;
private const int TODO_MAX_COUNT = 36;
private readonly DbService _db;
@ -111,7 +111,7 @@ public sealed class TodoService : IEService
.DeleteAsync();
}
public async Task<ArchiveTodoResult> ArchiveTodosAsync(ulong userId, string name)
public async Task<ArchiveTodoResult> ArchiveTodosAsync(ulong userId, string name, bool onlyDone)
{
// create a new archive
@ -140,7 +140,7 @@ public sealed class TodoService : IEService
var updated = await ctx
.GetTable<TodoModel>()
.Where(x => x.UserId == userId && x.ArchiveId == null)
.Where(x => x.UserId == userId && (!onlyDone || x.IsDone) && x.ArchiveId == null)
.Set(x => x.ArchiveId, inserted.Id)
.UpdateAsync();

View file

@ -1441,6 +1441,11 @@ todoarchivedelete:
- del
- remove
- rm
todoarchivedone:
- done
- compelete
- finish
- completed
todoedit:
- edit
- change

View file

@ -4524,6 +4524,13 @@ todoarchiveadd:
params:
- name:
desc: "The name of the archive to be created."
todoarchivedone:
desc: Creates a new archive with the specified name using only completed current todos.
ex:
- Success!
params:
- name:
desc: "The name of the archive to be created."
todoarchivelist:
desc: Lists all archived todo lists.
ex: