Fix compiler warnings

This commit is contained in:
Zed 2021-12-20 03:11:12 +01:00
parent f02515fda2
commit 7af71ec480
12 changed files with 21 additions and 23 deletions

View File

@ -7,3 +7,4 @@
# disable annoying warnings
warning("GcUnsafe2", off)
warning("ObservableStores", off)
warning("HoleEnumConv", off)

View File

@ -88,7 +88,7 @@ proc getTweet*(id: string; after=""): Future[Conversation] {.async.} =
proc resolve*(url: string; prefs: Prefs): Future[string] {.async.} =
let client = newAsyncHttpClient(maxRedirects=0)
try:
let resp = await client.request(url, $HttpHead)
let resp = await client.request(url, HttpHead)
result = resp.headers["location"].replaceUrl(prefs)
except:
discard

View File

@ -104,12 +104,9 @@ proc getTweetTime*(tweet: Tweet): string =
proc getShortTime*(tweet: Tweet): string =
let now = now()
var then = tweet.time.local()
then.utcOffset = 0
let since = now - tweet.time
let since = now - then
if now.year != then.year:
if now.year != tweet.time.year:
result = tweet.time.format("d MMM yyyy")
elif since.inDays >= 1:
result = tweet.time.format("MMM d")

View File

@ -93,8 +93,8 @@ proc parsePoll(js: JsonNode): Poll =
result.options.add vals{choice & "_label"}.getStrVal
let time = vals{"end_datetime_utc", "string_value"}.getDateTime
if time > getTime():
let timeLeft = $(time - getTime())
if time > now():
let timeLeft = $(time - now())
result.status = timeLeft[0 ..< timeLeft.find(",")]
else:
result.status = "Final results"
@ -269,12 +269,11 @@ proc parseTweet(js: JsonNode): Tweet =
result.gif = some(parseGif(m))
else: discard
let withheldInCountries = (
let withheldInCountries: seq[string] =
if js{"withheld_in_countries"}.kind == JArray:
js{"withheld_in_countries"}.to(seq[string])
else:
newSeq[string]()
)
if js{"withheld_copyright"}.getBool or
# XX - Content is withheld in all countries

View File

@ -43,14 +43,14 @@ template getError*(js: JsonNode): Error =
if js.kind != JArray or js.len == 0: null
else: Error(js[0]{"code"}.getInt)
template parseTime(time: string; f: static string; flen: int): Time =
template parseTime(time: string; f: static string; flen: int): DateTime =
if time.len != flen: return
parse(time, f).toTime
parse(time, f, utc())
proc getDateTime*(js: JsonNode): Time =
proc getDateTime*(js: JsonNode): DateTime =
parseTime(js.getStr, "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'", 20)
proc getTime*(js: JsonNode): Time =
proc getTime*(js: JsonNode): DateTime =
parseTime(js.getStr, "ddd MMM dd hh:mm:ss \'+0000\' yyyy", 30)
proc getId*(id: string): string {.inline.} =

View File

@ -22,7 +22,7 @@ proc migrate*(key, match: string) {.async.} =
let list = await r.scan(newCursor(0), match, 100000)
r.startPipelining()
for item in list:
if item != "p:" or item == match:
if item == match:
discard await r.del(item)
await r.setk(key, "true")
discard await r.flushPipeline()
@ -35,6 +35,7 @@ proc initRedisPool*(cfg: Config) {.async.} =
await migrate("snappyRss", "rss:*")
await migrate("oldFrosty", "*")
await migrate("userBuckets", "p:")
await migrate("profileDates", "p:")
pool.withAcquire(r):
await r.configSet("hash-max-ziplist-entries", "1000")

View File

@ -1,8 +1,8 @@
import asyncdispatch, strutils, sequtils, uri, options
import asyncdispatch, strutils, options
import jester
import ".."/[types, api], ../views/embed
export embed
export api, embed
proc createEmbedRouter*(cfg: Config) =
router embed:

View File

@ -3,7 +3,7 @@ import strutils
import jester
import router_utils
import ".."/[query, types, redis_cache, api]
import ".."/[types, redis_cache, api]
import ../views/[general, timeline, list]
export getListTimeline, getGraphList

View File

@ -3,7 +3,7 @@ import strutils
import jester
import router_utils
import ".."/[query, types, api]
import ".."/[types, api]
import ../views/general
template respResolved*(url, kind: string): untyped =

View File

@ -1,4 +1,4 @@
import asyncdispatch, strutils, tables, times, sequtils, hashes, supersnappy
import asyncdispatch, strutils, tables, times, hashes, supersnappy
import jester

View File

@ -1,4 +1,4 @@
import strutils, sequtils, uri
import strutils, uri
import jester

View File

@ -46,7 +46,7 @@ type
verified*: bool
protected*: bool
suspended*: bool
joinDate*: Time
joinDate*: DateTime
VideoType* = enum
m3u8 = "application/x-mpegURL"
@ -152,7 +152,7 @@ type
replyId*: int64
profile*: Profile
text*: string
time*: Time
time*: DateTime
reply*: seq[string]
pinned*: bool
hasThread*: bool