REFACTOR: SQL should use single-quotes; octal literals should start with '0o'
This commit is contained in:
parent
9f31037ad7
commit
1f44fb0961
@ -17,7 +17,7 @@ var (
|
||||
const TWEETS_ALL_SQL_FIELDS = `
|
||||
tweets.id id, tweets.user_id, text, posted_at, num_likes, num_retweets, num_replies, num_quote_tweets, in_reply_to_id,
|
||||
quoted_tweet_id, mentions, reply_mentions, hashtags, ifnull(space_id, '') space_id,
|
||||
ifnull(tombstone_types.short_name, "") tombstone_type, ifnull(tombstone_types.tombstone_text, "") tombstone_text,
|
||||
ifnull(tombstone_types.short_name, '') tombstone_type, ifnull(tombstone_types.tombstone_text, '') tombstone_text,
|
||||
case when likes.user_id is null then 0 else 1 end is_liked_by_current_user,
|
||||
is_expandable, is_stub, is_content_downloaded, is_conversation_scraped, last_scraped_at`
|
||||
|
||||
|
@ -599,7 +599,7 @@ func (p Profile) NextPage(c Cursor, current_user_id scraper.UserID) (Feed, error
|
||||
` + liked_by_filter_join_clause + `
|
||||
` + bookmarked_by_filter_join_clause + `
|
||||
` + where_clause + ` ` + c.SortOrder.OrderByClause() + ` limit ?
|
||||
)` + c.SortOrder.OrderByClause() + ` limit ?`
|
||||
) ` + c.SortOrder.OrderByClause() + ` limit ?`
|
||||
|
||||
bind_values = append([]interface{}{current_user_id}, bind_values...)
|
||||
bind_values = append(bind_values, c.PageSize)
|
||||
|
@ -48,7 +48,7 @@ func NewProfile(target_dir string) (Profile, error) {
|
||||
|
||||
// Create the directory
|
||||
fmt.Printf("Creating new profile: %s\n", target_dir)
|
||||
err := os.Mkdir(target_dir, os.FileMode(0755))
|
||||
err := os.Mkdir(target_dir, os.FileMode(0o755))
|
||||
if err != nil {
|
||||
return Profile{}, fmt.Errorf("Error creating directory %q:\n %w", target_dir, err)
|
||||
}
|
||||
@ -60,41 +60,41 @@ func NewProfile(target_dir string) (Profile, error) {
|
||||
|
||||
// Create `profile_images`
|
||||
fmt.Printf("Creating............. %s/\n", profile_images_dir)
|
||||
err = os.Mkdir(profile_images_dir, os.FileMode(0755))
|
||||
err = os.Mkdir(profile_images_dir, os.FileMode(0o755))
|
||||
if err != nil {
|
||||
return Profile{}, fmt.Errorf("Error creating %q:\n %w", profile_images_dir, err)
|
||||
}
|
||||
// Put the default profile image in it
|
||||
fmt.Printf("Creating............. %s/\n", default_profile_image_file)
|
||||
err = os.WriteFile(default_profile_image_file, default_profile_image, os.FileMode(0644))
|
||||
err = os.WriteFile(default_profile_image_file, default_profile_image, os.FileMode(0o644))
|
||||
if err != nil {
|
||||
return Profile{}, fmt.Errorf("Error creating default profile image file %q:\n %w", default_profile_image, err)
|
||||
}
|
||||
|
||||
// Create `link_thumbnail_images`
|
||||
fmt.Printf("Creating............. %s/\n", link_thumbnails_dir)
|
||||
err = os.Mkdir(link_thumbnails_dir, os.FileMode(0755))
|
||||
err = os.Mkdir(link_thumbnails_dir, os.FileMode(0o755))
|
||||
if err != nil {
|
||||
return Profile{}, fmt.Errorf("Error creating %q:\n %w", link_thumbnails_dir, err)
|
||||
}
|
||||
|
||||
// Create `images`
|
||||
fmt.Printf("Creating............. %s/\n", images_dir)
|
||||
err = os.Mkdir(images_dir, os.FileMode(0755))
|
||||
err = os.Mkdir(images_dir, os.FileMode(0o755))
|
||||
if err != nil {
|
||||
return Profile{}, fmt.Errorf("Error creating %q:\n %w", images_dir, err)
|
||||
}
|
||||
|
||||
// Create `videos`
|
||||
fmt.Printf("Creating............. %s/\n", videos_dir)
|
||||
err = os.Mkdir(videos_dir, os.FileMode(0755))
|
||||
err = os.Mkdir(videos_dir, os.FileMode(0o755))
|
||||
if err != nil {
|
||||
return Profile{}, fmt.Errorf("Error creating %q:\n %w", videos_dir, err)
|
||||
}
|
||||
|
||||
// Create `video_thumbnails`
|
||||
fmt.Printf("Creating............. %s/\n", video_thumbnails_dir)
|
||||
err = os.Mkdir(video_thumbnails_dir, os.FileMode(0755))
|
||||
err = os.Mkdir(video_thumbnails_dir, os.FileMode(0o755))
|
||||
if err != nil {
|
||||
return Profile{}, fmt.Errorf("Error creating %q:\n %w", video_thumbnails_dir, err)
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ create table list_users(rowid integer primary key,
|
||||
);
|
||||
create index if not exists index_list_users_list_id on list_users (list_id);
|
||||
create index if not exists index_list_users_user_id on list_users (user_id);
|
||||
insert into lists(rowid, name) values (1, "Offline Follows");
|
||||
insert into lists(rowid, name) values (1, 'Offline Follows');
|
||||
insert into list_users(list_id, user_id) select 1, id from users where is_followed = 1;
|
||||
|
||||
create table follows(rowid integer primary key,
|
||||
@ -139,7 +139,7 @@ create table urls (rowid integer primary key,
|
||||
tweet_id integer not null,
|
||||
domain text,
|
||||
text text not null,
|
||||
short_text text not null default "",
|
||||
short_text text not null default '',
|
||||
title text,
|
||||
description text,
|
||||
creator_id integer,
|
||||
@ -201,8 +201,8 @@ create table videos (rowid integer primary key,
|
||||
height integer not null,
|
||||
remote_url text not null unique,
|
||||
local_filename text not null unique,
|
||||
thumbnail_remote_url text not null default "missing",
|
||||
thumbnail_local_filename text not null default "missing",
|
||||
thumbnail_remote_url text not null default 'missing',
|
||||
thumbnail_local_filename text not null default 'missing',
|
||||
duration integer not null default 0,
|
||||
view_count integer not null default 0,
|
||||
is_gif boolean default 0,
|
||||
@ -372,8 +372,8 @@ create table chat_message_videos (rowid integer primary key,
|
||||
height integer not null,
|
||||
remote_url text not null unique,
|
||||
local_filename text not null unique,
|
||||
thumbnail_remote_url text not null default "missing",
|
||||
thumbnail_local_filename text not null default "missing",
|
||||
thumbnail_remote_url text not null default 'missing',
|
||||
thumbnail_local_filename text not null default 'missing',
|
||||
duration integer not null default 0,
|
||||
view_count integer not null default 0,
|
||||
is_gif boolean default 0,
|
||||
@ -388,7 +388,7 @@ create table chat_message_urls (rowid integer primary key,
|
||||
chat_message_id integer not null,
|
||||
domain text,
|
||||
text text not null,
|
||||
short_text text not null default "",
|
||||
short_text text not null default '',
|
||||
title text,
|
||||
description text,
|
||||
creator_id integer,
|
||||
|
@ -22,8 +22,8 @@ func (p Profile) SaveSpace(s scraper.Space) error {
|
||||
on conflict do update
|
||||
set id=:id,
|
||||
created_by_id=case when created_by_id is not null then created_by_id else nullif(:created_by_id, 0) end,
|
||||
short_url=case when short_url == "" then :short_url else short_url end,
|
||||
state=case when :state != "" then :state else state end,
|
||||
short_url=case when short_url == '' then :short_url else short_url end,
|
||||
state=case when :state != '' then :state else state end,
|
||||
title=case when :is_details_fetched then :title else title end,
|
||||
updated_at=max(:updated_at, updated_at),
|
||||
ended_at=max(:ended_at, ended_at),
|
||||
|
@ -124,7 +124,7 @@ func (p Profile) GetTweetById(id TweetID) (Tweet, error) {
|
||||
var t Tweet
|
||||
err := db.Get(&t, `
|
||||
select id, user_id, text, posted_at, num_likes, num_retweets, num_replies, num_quote_tweets, in_reply_to_id, quoted_tweet_id,
|
||||
mentions, reply_mentions, hashtags, ifnull(space_id, '') space_id, ifnull(tombstone_types.short_name, "") tombstone_type,
|
||||
mentions, reply_mentions, hashtags, ifnull(space_id, '') space_id, ifnull(tombstone_types.short_name, '') tombstone_type,
|
||||
is_expandable,
|
||||
is_stub, is_content_downloaded, is_conversation_scraped, last_scraped_at
|
||||
from tweets left join tombstone_types on tweets.tombstone_type = tombstone_types.rowid
|
||||
|
Loading…
x
Reference in New Issue
Block a user