Skip to content

Commit

Permalink
dev: Remove redundant HAPPY_WORDS and move them to OneConfig.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin42 committed Jan 11, 2025
1 parent 038332b commit 00ff2a9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 87 deletions.
31 changes: 31 additions & 0 deletions PB/include/pb/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,37 @@ const std::unordered_map<std::string, unsigned> TASK_CRUNCHER_POOLS_INFO = {
{"upl-to-spl-map", 4}, {"search-files", 1}, {"lut-icons", 1},
{"thumbnails-job", 1}, {"default", 1}};

#ifdef SIMULATE_FEW_HAPPY_WORDS
const std::vector<std::string> HAPPY_WORDS = {"Joyful", "Blissful"};
#else
const std::vector<std::string> HAPPY_WORDS = {
"Joyful", "Blissful", "Radiant", "Cheerful",
"Exuberant", "Jubilant", "Gleeful", "Delighted",
"Content", "Ecstatic", "Merry", "Jovial",
"Upbeat", "Elated", "Happy", "Sunny",
"Lighthearted", "Buoyant", "Festive", "Vibrant",
"Grateful", "Satisfied", "Pleased", "Overjoyed",
"Optimistic", "Pleased", "Thrilled", "Euphoric",
"Playful", "Carefree", "Radiant", "Wonderful",
"Jolly", "Zestful", "Bubbly", "Heartwarming",
"Cheery", "Upbeat", "Chirpy", "Sanguine",
"Enthusiastic", "Serene", "Up-lifting", "Giddy",
"Gleaming", "Bountiful", "Exultant", "Merry-making",
"Comical", "Hilarious", "Dynamic", "Sweet",
"Whimsical", "Spirited", "Sprightly", "Delightful",
"Radiant", "Uplifting", "Optimistic", "Tickled",
"Chipper", "Pleasant", "Buoyant", "Lively",
"Sparkling", "Tickled", "Exhilarating", "Bouncy",
"Festal", "Vivacious", "Gladsome", "Pleased",
"Elated", "Blithesome", "Merry-hearted", "Gleamy",
"Zippy", "Snappy", "Piquant", "Buoyant",
"Enlivened", "Beaming", "Radiant", "Jocund",
"Grinning", "Giggly", "Sunny", "Uplifted",
"Hopeful", "Amused", "Merry-making", "Overjoyed",
"Glad", "Contented", "Radiant", "Effervescent",
"Spry", "Snug", "Jovial", "Untroubled"};
#endif

} // namespace OneConfig

class Noir {
Expand Down
1 change: 0 additions & 1 deletion PB/include/pb/project/Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace PB {

class Project final {
public:
static std::string generateAlbumName(std::function<bool(std::string)>);

PaperSettings paperSettings = OneConfig::A4_LANDSCAPE_PAPER;
std::string name;
Expand Down
53 changes: 0 additions & 53 deletions PB/src/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,5 @@

namespace PB {

#ifdef SIMULATE_FEW_HAPPY_WORDS
std::vector<std::string> Project::HAPPY_WORDS = {"Joyful", "Blissful"};
#else
std::vector<std::string> Project::HAPPY_WORDS = {
"Joyful", "Blissful", "Radiant", "Cheerful",
"Exuberant", "Jubilant", "Gleeful", "Delighted",
"Content", "Ecstatic", "Merry", "Jovial",
"Upbeat", "Elated", "Happy", "Sunny",
"Lighthearted", "Buoyant", "Festive", "Vibrant",
"Grateful", "Satisfied", "Pleased", "Overjoyed",
"Optimistic", "Pleased", "Thrilled", "Euphoric",
"Playful", "Carefree", "Radiant", "Wonderful",
"Jolly", "Zestful", "Bubbly", "Heartwarming",
"Cheery", "Upbeat", "Chirpy", "Sanguine",
"Enthusiastic", "Serene", "Up-lifting", "Giddy",
"Gleaming", "Bountiful", "Exultant", "Merry-making",
"Comical", "Hilarious", "Dynamic", "Sweet",
"Whimsical", "Spirited", "Sprightly", "Delightful",
"Radiant", "Uplifting", "Optimistic", "Tickled",
"Chipper", "Pleasant", "Buoyant", "Lively",
"Sparkling", "Tickled", "Exhilarating", "Bouncy",
"Festal", "Vivacious", "Gladsome", "Pleased",
"Elated", "Blithesome", "Merry-hearted", "Gleamy",
"Zippy", "Snappy", "Piquant", "Buoyant",
"Enlivened", "Beaming", "Radiant", "Jocund",
"Grinning", "Giggly", "Sunny", "Uplifted",
"Hopeful", "Amused", "Merry-making", "Overjoyed",
"Glad", "Contented", "Radiant", "Effervescent",
"Spry", "Snug", "Jovial", "Untroubled"};
#endif

// TODO: move this to ProjectPersistence
std::string
Project::generateAlbumName(std::function<bool(std::string)> stoppingCondition)
{
auto size = HAPPY_WORDS.size();
std::srand(static_cast<unsigned int>(std::time(0)));
int randomIndex = std::rand() % size;
if (!stoppingCondition) {
return HAPPY_WORDS.at(randomIndex);
}

std::string prefix = HAPPY_WORDS.at(randomIndex);
int index = 0;
std::string name = prefix;

while (!stoppingCondition(name)) {
name = prefix + std::to_string(index);
index++;
PBDev::basicAssert(index < 1000);
}
return name;
}

} // namespace PB
35 changes: 2 additions & 33 deletions PB/src/ProjectManagementService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,13 @@
#include <pb/components/ThumbnailsTask.h>

namespace PB::Service {
#ifdef SIMULATE_FEW_HAPPY_WORDS
std::vector<std::string> ProjectManagementService::HAPPY_WORDS = {"Joyful",
"Blissful"};
#else
std::vector<std::string> ProjectManagementService::HAPPY_WORDS = {
"Joyful", "Blissful", "Radiant", "Cheerful",
"Exuberant", "Jubilant", "Gleeful", "Delighted",
"Content", "Ecstatic", "Merry", "Jovial",
"Upbeat", "Elated", "Happy", "Sunny",
"Lighthearted", "Buoyant", "Festive", "Vibrant",
"Grateful", "Satisfied", "Pleased", "Overjoyed",
"Optimistic", "Pleased", "Thrilled", "Euphoric",
"Playful", "Carefree", "Radiant", "Wonderful",
"Jolly", "Zestful", "Bubbly", "Heartwarming",
"Cheery", "Upbeat", "Chirpy", "Sanguine",
"Enthusiastic", "Serene", "Up-lifting", "Giddy",
"Gleaming", "Bountiful", "Exultant", "Merry-making",
"Comical", "Hilarious", "Dynamic", "Sweet",
"Whimsical", "Spirited", "Sprightly", "Delightful",
"Radiant", "Uplifting", "Optimistic", "Tickled",
"Chipper", "Pleasant", "Buoyant", "Lively",
"Sparkling", "Tickled", "Exhilarating", "Bouncy",
"Festal", "Vivacious", "Gladsome", "Pleased",
"Elated", "Blithesome", "Merry-hearted", "Gleamy",
"Zippy", "Snappy", "Piquant", "Buoyant",
"Enlivened", "Beaming", "Radiant", "Jocund",
"Grinning", "Giggly", "Sunny", "Uplifted",
"Hopeful", "Amused", "Merry-making", "Overjoyed",
"Glad", "Contented", "Radiant", "Effervescent",
"Spry", "Snug", "Jovial", "Untroubled"};
#endif

std::string ProjectManagementService::newAlbumName()
{
auto size = HAPPY_WORDS.size();
auto size = OneConfig::HAPPY_WORDS.size();
std::srand(static_cast<unsigned int>(std::time(0)));
int randomIndex = std::rand() % size;
std::string prefix = HAPPY_WORDS.at(randomIndex);
std::string prefix = OneConfig::HAPPY_WORDS.at(randomIndex);
int index = 0;
std::string name = prefix;

Expand Down

0 comments on commit 00ff2a9

Please sign in to comment.