mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
fix: duplicates in recent section
This commit is contained in:
parent
cd39bbf87c
commit
b1780e0cf8
10
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
10
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -9,7 +9,8 @@ body:
|
||||
attributes:
|
||||
label: Is there an existing issue for this? (Please read the description)
|
||||
description: |
|
||||
PLEASE! Make sure to check if this issue is a duplicate.
|
||||
🚨 PLEASE! Make sure to check if this issue is a duplicate. 🚨
|
||||
|
||||
Don't waste our time, we are working hard to make Spotube better for you.
|
||||
|
||||
Try with multiple similar keywords, and check the closed issues too.
|
||||
@ -60,7 +61,7 @@ body:
|
||||
- type: input
|
||||
attributes:
|
||||
label: Operating System
|
||||
description: The OS in which you used Spotube to face the issue.
|
||||
description: The OS in which you used Spotube to face the issue. Use comma to separate multiple OS.
|
||||
placeholder: Android, Linux, macOS or Windows? Make sure to include the version too.
|
||||
validations:
|
||||
required: true
|
||||
@ -96,7 +97,10 @@ body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Self grab
|
||||
description: If you are a developer and want to work on this issue yourself, you can check this box and wait for maintainer response. Any contributions are welcome!
|
||||
description: |
|
||||
If you are a developer and want to work on this issue yourself, you can check this box and wait for maintainer response. Any contributions are welcome!
|
||||
|
||||
This project is maintained by one person. So PRs are always welcome. This is the best way to get your issue fixed faster.
|
||||
options:
|
||||
- label: I'm ready to work on this issue!
|
||||
required: false
|
||||
|
@ -128,8 +128,8 @@ class AboutSpotubePage extends HookConsumerWidget {
|
||||
colon,
|
||||
const TableCell(
|
||||
child: Hyperlink(
|
||||
"github.com/KRTirtho/spotube/issues",
|
||||
"https://github.com/KRTirtho/spotube/issues",
|
||||
"Discord",
|
||||
"https://discord.gg/uJ94vxB6vg",
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/provider/database/database.dart';
|
||||
|
||||
@ -9,48 +10,40 @@ class RecentlyPlayedItemNotifier extends AsyncNotifier<List<HistoryTableData>> {
|
||||
build() async {
|
||||
final database = ref.watch(databaseProvider);
|
||||
|
||||
final uniqueItemIds = await (database.selectOnly(
|
||||
database.historyTable,
|
||||
distinct: true,
|
||||
)
|
||||
..addColumns([database.historyTable.itemId, database.historyTable.id])
|
||||
..where(
|
||||
database.historyTable.type.isInValues([
|
||||
HistoryEntryType.playlist,
|
||||
HistoryEntryType.album,
|
||||
]),
|
||||
)
|
||||
..limit(10)
|
||||
..orderBy([
|
||||
OrderingTerm(
|
||||
expression: database.historyTable.createdAt,
|
||||
mode: OrderingMode.desc,
|
||||
),
|
||||
]))
|
||||
.map(
|
||||
(row) => row.read(database.historyTable.id),
|
||||
)
|
||||
.get()
|
||||
.then((value) => value.whereNotNull().toList());
|
||||
|
||||
final query = database.select(database.historyTable)
|
||||
..where(
|
||||
(tbl) => tbl.id.isIn(uniqueItemIds),
|
||||
final query = database.customSelect(
|
||||
"""
|
||||
WITH RankedHistory AS (
|
||||
SELECT *, ROW_NUMBER() OVER (PARTITION BY item_id ORDER BY created_at DESC) AS rn
|
||||
FROM history_table
|
||||
WHERE type in ('playlist', 'album')
|
||||
)
|
||||
..orderBy([
|
||||
(tbl) => OrderingTerm(
|
||||
expression: tbl.createdAt,
|
||||
mode: OrderingMode.desc,
|
||||
),
|
||||
]);
|
||||
SELECT *
|
||||
FROM RankedHistory
|
||||
WHERE rn = 1
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 10
|
||||
""",
|
||||
readsFrom: {database.historyTable},
|
||||
).map((rows) async {
|
||||
return await rows.map((row) {
|
||||
final type = row.read<String>('type');
|
||||
return HistoryTableData(
|
||||
id: row.read<int>('id'),
|
||||
itemId: row.read<String>('item_id'),
|
||||
type: HistoryEntryType.values.firstWhere((e) => e.name == type),
|
||||
createdAt: row.read<DateTime>('created_at'),
|
||||
data: jsonDecode(row.read<String>('data')) as Map<String, dynamic>,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
final subscription = query.watch().listen((event) {
|
||||
state = AsyncData(event);
|
||||
final subscription = query.watch().listen((event) async {
|
||||
state = AsyncData(await Future.wait(event));
|
||||
});
|
||||
|
||||
ref.onDispose(() => subscription.cancel());
|
||||
|
||||
final items = await query.get();
|
||||
final items = await Future.wait(await query.get());
|
||||
|
||||
return items;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user