Skip to content

Commit

Permalink
Small fixes and a info blur
Browse files Browse the repository at this point in the history
  • Loading branch information
fatfingers23 committed Apr 23, 2024
1 parent 1b51f95 commit 712ebea
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 13 deletions.
31 changes: 22 additions & 9 deletions trackscape-discord-shared/src/database/clan_mates.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::pb_records_db::PersonalBestRecordsModel;
use crate::database::clan_mate_collection_log_totals::ClanMateCollectionLogTotalModel;
use crate::database::ClanMatesDb;
use anyhow::Error;
Expand Down Expand Up @@ -198,6 +199,7 @@ impl ClanMates for ClanMatesDb {
async fn remove_clan_mate(&self, guild_id: u64, player_name: String) -> Result<(), Error> {
//TODO add a bit to clean up other collections too

//TODO dont forget to remove PBs
let collection = self
.db
.collection::<ClanMateModel>(ClanMateModel::COLLECTION_NAME);
Expand All @@ -212,25 +214,36 @@ impl ClanMates for ClanMatesDb {
let player = possible_player.unwrap();

//Removes other data from db may move else where
let collection_log_collection = self
.db
.collection::<ClanMateCollectionLogTotalModel>(ClanMateCollectionLogTotalModel::COLLECTION_NAME);

let filter = doc! {
let delete_filter = doc! {
"guild_id": bson::to_bson(&guild_id).unwrap(),
"player_id": player.id.clone(),
};
let collection_log_result = collection_log_collection.delete_many(filter, None).await;

let collection_log_collection = self.db.collection::<ClanMateCollectionLogTotalModel>(
ClanMateCollectionLogTotalModel::COLLECTION_NAME,
);

let collection_log_result = collection_log_collection
.delete_many(delete_filter.clone(), None)
.await;
if collection_log_result.is_err() {
println!(
"Failed to remove collection log totals for clan mate: {}",
player_name
);
println!("Error: {:?}", collection_log_result.err());
return Err(anyhow::anyhow!(format!(
"Failed to remove collection log totals for clan mate: {}",
}

let pb_collection = self
.db
.collection::<PersonalBestRecordsModel>(PersonalBestRecordsModel::COLLECTION_NAME);
let pb_records_result = pb_collection.delete_many(delete_filter, None).await;
if pb_records_result.is_err() {
println!(
"Failed to remove personal best records for clan mate: {}",
player_name
)));
);
println!("Error: {:?}", pb_records_result.err());
}
//End of removing from other collections

Expand Down
7 changes: 6 additions & 1 deletion trackscape-discord-ui/src/components/General/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
type: String,
required: false,
default: ""
},
noResultsMessage: {
type: String,
required: false,
default: "No results found"
}
});
Expand Down Expand Up @@ -94,7 +99,7 @@
<tbody>
<tr v-if="filteredData.length === 0"
class="text-center min-w-full">
<td><p>No results found</p></td>
<td :colspan="props.columns?.length">{{ props.noResultsMessage }}</td>
</tr>
<tr v-for="(item, index) in filteredData"
Expand Down
3 changes: 3 additions & 0 deletions trackscape-discord-ui/src/stores/PbStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const usePbStore = defineStore('pb', {
selectedActivityName: '',
clanId: '',
records: [] as PbRecord[],
loading: false
};
},
actions: {
Expand All @@ -23,10 +24,12 @@ export const usePbStore = defineStore('pb', {

});
this.records = records;
this.loading = false;
router.replace({ name: 'personal-best', params: { clanId: this.clanId, activityId: this.selectedActivity } });
});
},
async setSelectedActivity(activity: PbActivity, guildId: string) {
this.loading = true;
this.selectedActivity = activity._id;
this.selectedActivityName = activity.activity_name;
this.clanId = guildId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ const leaderBoardMenus = [
];
</script>
<template>
<div v-if="route.name === 'personal-best'"
role="alert"
class="alert shadow-lg alert-info">
<svg xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
class="stroke-current shrink-0 w-6 h-6"><path stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<div>
<h3 class="text-sm text-bold">Personal Best Leaderboards are still a work in progress.</h3>
<a class="underline text-sm"
href="https://github.com/fatfingers23/trackscape-discord-bot/issues/29">View or add bugs for PBs</a>

</div>

</div>
<div class="pt-1 justify-between items-center flex md:flex-row flex-col">
<div
role="tablist"
Expand All @@ -53,6 +71,7 @@ const leaderBoardMenus = [
<PersonalBestActivitySelect v-if="route.name === 'personal-best' && clanId"
:clan-id="clanId"/>
</div>

<div class="container bg-base-200">

<router-view v-slot="{ Component}" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ const osrsTimeDisplay = (timeInSeconds: number) => {
<div class="">
<TransitionGroup name="slide-fade">

<SkeletonTable v-if="store.records.length === 0"
<SkeletonTable v-if="store.loading"
:search-field="true"
:columns="3"/>


<DataTable
v-else

no-results-message="No personal bests found for this activity in your clan, can record yours with the RuneLite !pb command."
:columns="columns"
:data="store.getRecords"
search-field="clan_mate.player_name"
Expand Down

0 comments on commit 712ebea

Please sign in to comment.