Skip to content

Commit

Permalink
Merge pull request #188 from eye-on-surveillance/feedback/v2
Browse files Browse the repository at this point in the history
feat: filter feedback_cards by version
  • Loading branch information
marvinmarnold authored Dec 14, 2023
2 parents 254cf7f + b2e0b59 commit 0d9d505
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ NEXT_PUBLIC_SUPABASE_URL=https://xxxxxxxxxxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
NEXT_PUBLIC_TGI_API_ENDPOINT=http://localhost:8080
SUPABASE_SERVICE_ROLE_SECRET=""
NEXT_PUBLIC_FEEDBACK_VERSION=v0.0.2
25 changes: 15 additions & 10 deletions packages/web/app/feedback/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ export default function UserFeedback() {
// };

const randQuestionId = () => {
return Math.floor(Math.random() * 291);
return Math.floor(Math.random() * 237);
};

const shuffleArray = (array: Number[]) => {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
};
// const shuffleArray = (array: Number[]) => {
// for (let i = array.length - 1; i > 0; i--) {
// const j = Math.floor(Math.random() * (i + 1));
// [array[i], array[j]] = [array[j], array[i]];
// }
// return array;
// };

// const shuffledQuestionIds = shuffleArray(question_idArray);
const [currentIndex, setCurrentIndex] = useState<number>(0);
Expand All @@ -69,13 +69,14 @@ export default function UserFeedback() {
useEffect(() => {
const getCard = async () => {
const randId = randQuestionId();
console.log("Fetching cards " + randId);
// console.log("Fetching cards " + randId);
try {
const cardsArray: Array<Array<ICard>> = [];
const { data: newCards, error } = await supabase
.from(TABLES.FEEDBACK_CARDS)
.select("*")
.eq("question_id", randId);
.eq("question_id", randId)
.eq("model_version", process.env.NEXT_PUBLIC_FEEDBACK_VERSION);
if (newCards) {
setCards(newCards);
}
Expand Down Expand Up @@ -154,6 +155,10 @@ export default function UserFeedback() {
Next question
</button>
)}

<p className="mt-6 text-right text-xs">
{process.env.NEXT_PUBLIC_FEEDBACK_VERSION}
</p>
</div>
<div className="md:grow"></div>
</div>
Expand Down

0 comments on commit 0d9d505

Please sign in to comment.