Skip to content

Commit

Permalink
add readme how wisdoms checker work, IMPORTANT: change back to one . …
Browse files Browse the repository at this point in the history
…(dot)
  • Loading branch information
nikola-bozin-org committed Jun 8, 2024
1 parent 352ab46 commit 6445371
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
51 changes: 51 additions & 0 deletions worker_wisdoms_checker/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Adding new wisdom

1. Update wisdoms.json file.

Example:

#### Previous

```typescript
[
{"description": "Every day, every minute, every second, we are creating evidence for our self that we are qualified for the life we want!"},
{"description":"Hope it works!"},
{"description": "Knowledge is power."},
{"description": "Time is money."}
]
```

#### New


```typescript
[
{"description": "Every day, every minute, every second, we are creating evidence for our self that we are qualified for the life we want!"},
{"description":"Hope it works!"},
{"description": "Knowledge is power."},
{"description": "Time is money."},
{"description": "New Wisdom"}
]
```

2. Run command

```shell
base64 wisdoms.json
```

Result should be something like this:

```
WwogICAgeyJkZXNjcmlwdGlvbiI6ICJFdmVyeSBkYXksIGV2ZXJ5IG1pbnV0ZSwgZXZlcnkgc2Vj
b25kLCB3ZSBhcmUgY3JlYXRpdwdqdwdqddqdqwdqdqwd...ciBzZWxmIHRoYXQgd2UgYXJlIHF1
ICAgeyJkZXNjcmlwdGlvbiI6IkFBQUFBQUFBQUFBQUFBQUFBIn0sCiAgICB7ImRlc2NyaXB0aW9u
IjoiQkJCQkJCQkJCQkJCQkJCQkJCQiJ9Cl0KICA=
```

3. Copy the result


4. Paste the result into file `encoded-wisdoms.b64`

5. If the `worker-wisdoms-checker` is running, it will pick up the changes and update the database.
7 changes: 3 additions & 4 deletions worker_wisdoms_checker/src/wisdoms_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub async fn worker_thread(pool: PgPool) {
tokio::time::sleep(Duration::from_secs(5)).await;

//Its one dot (.) because we are running the worker it from the root.
let base64_string = match fs::read_to_string("./encoded-wisdoms.b64") {
let base64_string = match fs::read_to_string("../encoded-wisdoms.b64") {
Ok(content) => content.replace(['\n', '\r'], ""),
Err(e) => {
send_tg_message(
Expand Down Expand Up @@ -113,7 +113,8 @@ pub async fn worker_thread(pool: PgPool) {
.execute(&pool)
.await
{
Ok(_) => {}
Ok(_) => {
}
Err(e) => {
send_tg_message(
bot,
Expand All @@ -125,8 +126,6 @@ pub async fn worker_thread(pool: PgPool) {
return;
}
};
} else {
println!("Wisdom already exists, skipping: {:?}", wisdom);
}
}

Expand Down

0 comments on commit 6445371

Please sign in to comment.